]> granicus.if.org Git - neomutt/commitdiff
travis: add deploy script
authorRichard Russon <rich@flatcap.org>
Thu, 18 May 2017 14:40:00 +0000 (15:40 +0100)
committerRichard Russon <rich@flatcap.org>
Mon, 16 Jul 2018 10:58:12 +0000 (11:58 +0100)
[ci skip]

.travis.yml
.travis/deploy.sh [new file with mode: 0755]
.travis/generate-webpage.sh [new file with mode: 0755]
.travis/prep.sh [new file with mode: 0755]
.travis/stats.sh [new file with mode: 0755]
.travis/travis-deploy-github.enc [new file with mode: 0644]

index 957e618338dfeddb0c6917776346c6d279e8fbd2..c41f910356a27a67ee629d632514c387f5815591 100644 (file)
@@ -10,51 +10,23 @@ dist: trusty
 
 language: c
 compiler: gcc
-cache: ccache
 
 addons:
   apt:
     packages:
-      - autopoint
-      - docbook-simple
-      - docbook-xsl
       - gettext
-      - libdb-dev
-      - libgdbm-dev
-      - libgnutls-dev
-      - libgpgme11-dev
-      - libgss-dev
-      - libkyotocabinet-dev
-      - liblmdb-dev
-      - liblua5.2-dev
-      - libnotmuch-dev
-      - libqdbm-dev
-      - libsasl2-dev
-      - libslang2-dev
-      - libssl-dev
-      - libtokyocabinet-dev
-      - libxml2-utils
-      - lua5.2
-      - lynx
-      - xsltproc
 
 git:
   depth: 3
 
-install:
-  - git clone --depth 1 https://github.com/neomutt/travis-build.git ~/config
-
-before_script:
-  - ccache --zero-stats
-  - export ANSI_CLEAR
-  - export -f travis_fold
-  - export -f travis_nanoseconds
-  - export -f travis_time_finish
-  - export -f travis_time_start
+env:
+  global:
+  - DEPLOY_REPO="git@github.com:neomutt/neomutt.github.io.git"
+  - DEPLOY_DIR="~/website"
+  - DEPLOY_FILE="translate.html"
 
 script:
-  - ~/config/build
-
-after_script:
-  - ccache --show-stats
+- .travis/stats.sh
 
+after_success:
+- .travis/deploy.sh
diff --git a/.travis/deploy.sh b/.travis/deploy.sh
new file mode 100755 (executable)
index 0000000..2346505
--- /dev/null
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+set -o errexit # set -e
+set -o nounset # set -u
+
+function calc_percentage()
+{
+       local FILE="$1"
+       local TNUM=0
+       local FNUM=0
+       local UNUM=0
+       local LINE
+
+       LINE="$(msgfmt --statistics -c -o /dev/null "$FILE" 2>&1 | sed 's/ \(message\|translation\)s*\.*//g')"
+
+       # filename: 104 translated, 22 fuzzy, 11 untranslated
+       if [[ "$LINE" =~ ([0-9]+)[[:space:]]translated,[[:space:]]([0-9]+)[[:space:]]fuzzy,[[:space:]]([0-9]+)[[:space:]]untranslated ]]; then
+               TNUM=${BASH_REMATCH[1]} # translated
+               FNUM=${BASH_REMATCH[2]} # fuzzy
+               UNUM=${BASH_REMATCH[3]} # untranslated
+       # filename: 320 translated, 20 untranslated
+       elif [[ "$LINE" =~ ([0-9]+)[[:space:]]translated,[[:space:]]([0-9]+)[[:space:]]untranslated ]]; then
+               TNUM=${BASH_REMATCH[1]} # translated
+               UNUM=${BASH_REMATCH[2]} # untranslated
+       # filename: 5 translated, 13 fuzzy
+       elif [[ "$LINE" =~ ([0-9]+)[[:space:]]translated,[[:space:]]([0-9]+)[[:space:]]fuzzy ]]; then
+               TNUM=${BASH_REMATCH[1]} # translated
+               FNUM=${BASH_REMATCH[2]} # fuzzy
+       # filename: 63 translated
+       elif [[ "$LINE" =~ ([0-9]+)[[:space:]]translated ]]; then
+               TNUM=${BASH_REMATCH[1]} # translated
+       fi
+
+       # number of translated strings
+       local TOTAL=$((TNUM+FNUM+UNUM))
+       # percentage complete
+       echo $((100*TNUM/TOTAL))
+}
+
+
+echo "DEPLOY_DIR          = $DEPLOY_DIR"
+echo "DEPLOY_FILE         = $DEPLOY_FILE"
+echo "DEPLOY_REPO         = $DEPLOY_REPO"
+echo "TRAVIS_BRANCH       = $TRAVIS_BRANCH"
+echo "TRAVIS_COMMIT       = $TRAVIS_COMMIT"
+echo "TRAVIS_PULL_REQUEST = $TRAVIS_PULL_REQUEST"
+
+if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
+       echo "This is a Pull Request.  Done."
+       exit 0
+fi
+
+if [ "$TRAVIS_BRANCH" != "translate" ]; then
+       echo "This isn't branch 'translate'.  Done."
+       exit 0
+fi
+
+FILES="$(git diff --name-only "$TRAVIS_COMMIT^..$TRAVIS_COMMIT" -- 'po/*.po')"
+FILE_COUNT="$(echo "$FILES" | wc -w)"
+
+if [ "$FILE_COUNT" = 1 ]; then
+       AUTHOR="$(git log -n1 --format="%aN" "$TRAVIS_COMMIT")"
+       PO="${FILES##*/}"
+       PO="${PO%.po}"
+       PCT=$(calc_percentage "$FILES")
+       MESSAGE="$AUTHOR, $PO, $PCT%"
+else
+       MESSAGE="update leaderboard"
+fi
+
+.travis/prep.sh
+
+set -v
+eval "$(ssh-agent -s)"
+ssh-add .travis/travis-deploy-github.pem
+
+git clone "$DEPLOY_REPO" "$DEPLOY_DIR"
+.travis/generate-webpage.sh po/*.po > "$DEPLOY_DIR/$DEPLOY_FILE"
+
+cd "$DEPLOY_DIR"
+git add "$DEPLOY_FILE"
+git commit -m "[AUTO] translation: $MESSAGE" -m "[ci skip]"
+git push origin
+
diff --git a/.travis/generate-webpage.sh b/.travis/generate-webpage.sh
new file mode 100755 (executable)
index 0000000..50db592
--- /dev/null
@@ -0,0 +1,169 @@
+#!/bin/bash
+
+function lookup_lang()
+{
+       case "${1##*/}" in
+               eu)    IMG="basque.png";              NAME="Basque";;
+               bg)    IMG="bulgarian.png";           NAME="Bulgarian";;
+               ca)    IMG="catalan.png";             NAME="Catalan";;
+               zh_CN) IMG="chinese-simplified.png";  NAME="Chinese (Simplified)";;
+               zh_TW) IMG="chinese-traditional.png"; NAME="Chinese (Traditional)";;
+               cs)    IMG="czech.png";               NAME="Czech";;
+               da)    IMG="danish.png";              NAME="Danish";;
+               nl)    IMG="dutch.png";               NAME="Dutch";;
+               en_GB) IMG="english.png";             NAME="English (British)";;
+               eo)    IMG="esperanto.png";           NAME="Esperanto";;
+               et)    IMG="estonian.png";            NAME="Estonian";;
+               fr)    IMG="french.png";              NAME="French";;
+               gl)    IMG="galician.png";            NAME="Galician";;
+               de)    IMG="german.png";              NAME="German";;
+               el)    IMG="greek.png";               NAME="Greek";;
+               hu)    IMG="hungarian.png";           NAME="Hungarian";;
+               id)    IMG="indonesian.png";          NAME="Indonesian";;
+               ga)    IMG="irish.png";               NAME="Irish";;
+               it)    IMG="italian.png";             NAME="Italian";;
+               ja)    IMG="japanese.png";            NAME="Japanese";;
+               ko)    IMG="korean.png";              NAME="Korean";;
+               lt)    IMG="lithuanian.png";          NAME="Lithuanian";;
+               pl)    IMG="polish.png";              NAME="Polish";;
+               pt_BR) IMG="portuguese-brazil.png";   NAME="Portuguese (Brazil)";;
+               ru)    IMG="russian.png";             NAME="Russian";;
+               sk)    IMG="slovak.png";              NAME="Slovak";;
+               es)    IMG="spanish.png";             NAME="Spanish";;
+               sv)    IMG="swedish.png";             NAME="Swedish";;
+               tr)    IMG="turkish.png";             NAME="Turkish";;
+               uk)    IMG="ukrainian.png";           NAME="Ukrainian";;
+       esac
+}
+
+function html_header()
+{
+       echo "---"
+       echo "layout: concertina"
+       echo "title: Translations"
+       echo "---"
+       echo ""
+       echo "<h2>Translating NeoMutt</h2>"
+       echo ""
+       echo "<p>"
+       echo "  NeoMutt has been translated into 30 languages."
+       echo "  Unfortunately, some of the translations are out-of-date."
+       echo "</p>"
+       echo ""
+       echo "<p>"
+       echo "  Do <b>YOU</b> speak one of these languages?"
+       echo "  If so, <a href=\"mailto:rich@flatcap.org\">please help us</a>."
+       echo "</p>"
+       echo ""
+       echo "<p>"
+       echo "  Read more about what would be involved in"
+       echo "  <a href=\"/dev/translate\">translating NeoMutt</a>."
+       echo "</p>"
+       echo ""
+       echo "<table class=\"lang\" summary=\"list of languages\">"
+       echo "  <thead>"
+       echo "    <tr>"
+       echo "      <th>Language</th>"
+       echo "      <th style=\"text-align: center;\">"
+       echo "      <span style=\"border: 1px solid black; background: #6f6; padding: 3px;\">Complete</span>"
+       echo "      <span style=\"border: 1px solid black; background: #ff6; padding: 3px;\">Fuzzy</span>"
+       echo "      <span style=\"border: 1px solid black; background: #f66; padding: 3px;\">Incomplete</span>"
+       echo "      </th>"
+       echo "    </tr>"
+       echo "  </thead>"
+       echo "  <tbody>"
+       echo "    <tr>"
+       echo "      <td><img src=\"/images/flags/english.png\">English</td>"
+       echo "      <td>"
+       echo "      <div style=\"background: #6f6; min-width: 500px;\">Base Language</div></td>"
+       echo "    </tr>"
+}
+
+function html_line()
+{
+       local LINE="$1"
+       local LANG=""
+       local TNUM=0
+       local FNUM=0
+       local UNUM=0
+
+       # filename: 104 translated, 22 fuzzy, 11 untranslated
+       if [[ "$LINE" =~ (.*):[[:space:]]+([0-9]+)[[:space:]]translated,[[:space:]]([0-9]+)[[:space:]]fuzzy,[[:space:]]([0-9]+)[[:space:]]untranslated ]]; then
+               LANG="${BASH_REMATCH[1]}"
+               TNUM=${BASH_REMATCH[2]} # translated
+               FNUM=${BASH_REMATCH[3]} # fuzzy
+               UNUM=${BASH_REMATCH[4]} # untranslated
+       # filename: 320 translated, 20 untranslated
+       elif [[ "$LINE" =~ (.*):[[:space:]]+([0-9]+)[[:space:]]translated,[[:space:]]([0-9]+)[[:space:]]untranslated ]]; then
+               LANG="${BASH_REMATCH[1]}"
+               TNUM=${BASH_REMATCH[2]} # translated
+               UNUM=${BASH_REMATCH[3]} # untranslated
+       # filename: 5 translated, 13 fuzzy
+       elif [[ "$LINE" =~ (.*):[[:space:]]+([0-9]+)[[:space:]]translated,[[:space:]]([0-9]+)[[:space:]]fuzzy ]]; then
+               LANG="${BASH_REMATCH[1]}"
+               TNUM=${BASH_REMATCH[2]} # translated
+               FNUM=${BASH_REMATCH[3]} # fuzzy
+       # filename: 63 translated
+       elif [[ "$LINE" =~ (.*):[[:space:]]+([0-9]+)[[:space:]]translated ]]; then
+               LANG="${BASH_REMATCH[1]}"
+               TNUM=${BASH_REMATCH[2]} # translated
+       else
+               return
+       fi
+
+       lookup_lang "$LANG"
+
+       local TOTAL=$((TNUM+FNUM+UNUM)) # number of translated strings
+       local PC=$((100*TNUM/TOTAL)) # percentage complete
+
+       local TPX=$((500*TNUM/TOTAL)) # pixels for translated
+       local FPX=$((500*FNUM/TOTAL)) # pixels for fuzzy
+       local UPX=$((500*UNUM/TOTAL)) # pixels for untranslated
+
+       [ $FPX -gt 0 ] && [ $FPX -lt 10 ] && TPX=$((TPX-5)) # adjust for the size of a non-breaking space
+       [ $UPX -gt 0 ] && [ $UPX -lt 10 ] && TPX=$((TPX-7))
+
+       local TITLE="$NAME: $TNUM translated"
+       [ $FNUM -gt 0 ] && TITLE="$TITLE, $FNUM fuzzy"
+       [ $UNUM -gt 0 ] && TITLE="$TITLE, $UNUM untranslated"
+
+       echo "    <tr title=\"$TITLE\">"
+       echo "      <td><img src=\"/images/flags/$IMG\">$NAME</td>"
+       echo "      <td>"
+       if [ $TPX -gt 0 ]; then
+               echo "        <div style=\"background: #6f6; min-width: ${TPX}px;\">${PC}%</div>"
+       fi
+       if [ $FPX -gt 0 ]; then
+               echo "        <div style=\"background: #ff6; min-width: ${FPX}px; border-left: 1px solid black; border-right: 1px solid black;\">&#160;</div>"
+       fi
+       if [ $UPX -gt 0 ]; then
+               echo "        <div style=\"background: #f66; min-width: ${UPX}px;\">&#160;</div>"
+       fi
+       echo "      </td>"
+       echo "    </tr>"
+}
+
+function html_footer()
+{
+       echo "  </tbody>"
+       echo "</table>"
+       echo "<br>"
+       echo "Last updated: $(date --utc '+%F %R') UTC"
+}
+
+
+[ $# = 0 ] && ARGS="*.po" || ARGS="$*"
+
+html_header
+for i in $ARGS; do
+       echo -ne "${i%.po}:\t"
+       msgfmt --statistics -c -o /dev/null "$i" 2>&1
+done \
+       | grep -wv "en_GB" \
+       | sed 's/ \(message\|translation\)s*\.*//g' \
+       | sort -nr -k2 -k4 -k6 \
+       | while read -r line; do
+       html_line "$line"
+done
+html_footer
+
diff --git a/.travis/prep.sh b/.travis/prep.sh
new file mode 100755 (executable)
index 0000000..7edfd87
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+set -o errexit # set -e
+set -o nounset # set -u
+
+git config --global user.email "rich@flatcap.org"
+git config --global user.name "Richard Russon (DEPLOY)"
+
+mkdir -p ~/.ssh
+echo "Host github.com" >> ~/.ssh/config
+echo "        StrictHostKeyChecking no" >> ~/.ssh/config
+chmod 600 ~/.ssh/config
+
+cd .travis
+openssl aes-256-cbc -K $encrypted_ff1b3f8609ac_key -iv $encrypted_ff1b3f8609ac_iv -in travis-deploy-github.enc -out travis-deploy-github.pem -d
+chmod 0400 travis-deploy-github.pem
+
diff --git a/.travis/stats.sh b/.travis/stats.sh
new file mode 100755 (executable)
index 0000000..7b967ea
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+if [ $# = 0 ]; then
+       [ -d po ] && ARGS="po/*.po" || ARGS="*.po"
+else
+       ARGS="$*"
+fi
+
+ERROR=0
+
+TMP_FILE=$(mktemp)
+
+for i in $ARGS; do
+       L=${i##*/}
+       echo -ne "${L%.po}:\\t"
+       msgfmt --statistics -c -o /dev/null "$i" 2>&1
+       [ $? = 1 ] && ERROR=1
+done > "$TMP_FILE"
+
+sed 's/ \(message\|translation\)s*\.*//g' "$TMP_FILE" | sort -nr -k2 -k4 -k6
+rm -f "$TMP_FILE"
+
+exit $ERROR
+
diff --git a/.travis/travis-deploy-github.enc b/.travis/travis-deploy-github.enc
new file mode 100644 (file)
index 0000000..d65a1e1
Binary files /dev/null and b/.travis/travis-deploy-github.enc differ