Merge branch 'translation-workflow'

This commit is contained in:
Adriaan de Groot 2019-11-24 21:48:43 +01:00
commit 2ad8ff4228
3 changed files with 96 additions and 1 deletions

View File

@ -17,10 +17,13 @@
# * pulling translations
# * updating the language list
# * switching to the right branch
# The release can fail for various reasons: doesn't build, tests fail,
# or the string freeze has been violated.
#
# You can influence the script a little with these options:
# * `-B` do not build (before tagging)
# * `-P` do not package (tag, sign, tarball)
# * `-T` do not respect string freeze
#
# The build / package settings can be influenced via environment variables:
# * BUILD_DEFAULT set to `false` to avoid first build with gcc
@ -37,8 +40,9 @@ which cmake > /dev/null 2>&1 || { echo "No cmake(1) available." ; exit 1 ; }
test -z "$BUILD_DEFAULT" && BUILD_DEFAULT=true
test -z "$BUILD_CLANG" && BUILD_CLANG=true
test -z "$BUILD_ONLY" && BUILD_ONLY=false
STRING_FREEZE=true
while getopts "hBP" opt ; do
while getopts "hBPT" opt ; do
case "$opt" in
h|\?)
sed -e '1,/USAGE/d' -e '/END.USAGE/,$d' < "$0"
@ -51,10 +55,17 @@ while getopts "hBP" opt ; do
P)
BUILD_ONLY=true
;;
T)
STRING_FREEZE=false
;;
esac
done
if $STRING_FREEZE ; then
sh ci/txcheck.sh || { echo "! String freeze failed." ; exit 1 ; }
fi
### Setup
#
#

70
ci/txcheck.sh Normal file
View File

@ -0,0 +1,70 @@
#! /bin/sh
# Does the translation tag (from a previous txpush) exist?
# This assumes that the release host has also locally done
# a translations push, which works for the current development
# workflow .. but it could be improved by looking for one of
# the typical txpush log messages instead of the tag.
if git describe translation > /dev/null 2>&1 ; then
:
else
echo "! No 'translation' tag exists for enforcing the string-freeze."
exit 1
fi
# The tag exists, so now check that there's no unsaved changes
if test `git describe` = `git describe --dirty` ; then
:
else
echo "! There are local changes."
exit 1
fi
# No unsaved changes; enforce a string freeze of one week
DATE_PREV=$( git log -1 translation --date=unix | sed -e '/^Date:/s+.*:++p' -e d )
DATE_HEAD=$( date +%s -d "1 week ago" )
test "$DATE_PREV" -le "$DATE_HEAD" || { echo "! Translation tag has not aged enough." ; git log -1 translation ; exit 1 ; }
# Tag is good, do real work of checking strings: collect names of relevant files
test -f ".tx/config" || { echo "! No Transifex configuration is present." ; exit 1 ; }
# Print part after = for each source_file line and delete all the rest
TX_FILE_LIST=$( sed -e '/^source_file/s+.*=++p' -e d .tx/config )
for f in $TX_FILE_LIST ; do
test -f $f || { echo "! Translation file '$f' does not exist." ; exit 1 ; }
done
# The state of translations
tx_sum()
{
WORKTREE_NAME="$1"
WORKTREE_TAG="$2"
git worktree add $WORKTREE_NAME $WORKTREE_TAG > /dev/null 2>&1 || { echo "! Could not create worktree." ; exit 1 ; }
( cd $WORKTREE_NAME && sh ci/txpush.sh --no-tx ) > /dev/null 2>&1 || { echo "! Could not re-create translations." ; exit 1 ; }
_SUM=$( cd $WORKTREE_NAME && cat $TX_FILE_LIST | sha256sum )
echo "$_SUM"
}
# Check from the translation tag as well
HEAD_SUM=`tx_sum build-txcheck-head ""`
PREV_SUM=`tx_sum build-txcheck-prev translation`
# An error message will have come from the shell function
test -d build-txcheck-head || { echo "$HEAD_SUM" ; exit 1 ; }
test -d build-txcheck-prev || { echo "$PREV_SUM" ; exit 1 ; }
if test "$HEAD_SUM" = "$PREV_SUM" ; then
:
else
echo "! Translations have changed."
for f in $TX_FILE_LIST ; do
echo "! $f"
diff -u build-txcheck-prev/$f build-txcheck-head/$f
done
exit 1
fi
# Cleanup artifacs of checking
git worktree remove --force build-txcheck-head
git worktree remove --force build-txcheck-prev
git branch -D build-txcheck-head > /dev/null 2>&1
exit 0

View File

@ -28,9 +28,20 @@ test -f ".tx/config" || { echo "! Not at Calamares top-level" ; exit 1 ; }
test -f "calamares.desktop" || { echo "! Not at Calamares top-level" ; exit 1 ; }
if test "x$1" = "x--no-tx" ; then
# tx is the transifex command -- eat its arguments and do nothing
tx() {
echo "Skipped tx $*"
}
# txtag is used to tag in git to measure changes -- skip it too
txtag() {
echo "Skipped tx tagging."
}
else
# tx is the regular transifex command
# txtag is used to tag in git to measure changes
txtag() {
git tag -f translations
}
fi
### CREATE TRANSLATIONS
@ -84,3 +95,6 @@ if test -n "$SHARED_PYTHON" ; then
tx set -r calamares.python --source -l en "$POTFILE"
tx push --source --no-interactive -r calamares.python
fi
txtag
exit 0