From 9f90ef637711ac07a3bfaa0c5217302c8b5014d2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 18 Nov 2019 17:07:08 +0100 Subject: [PATCH 1/7] CI: when pushing translations, mark it with a git tag --- ci/txpush.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ci/txpush.sh b/ci/txpush.sh index 84166fac6..15b301109 100755 --- a/ci/txpush.sh +++ b/ci/txpush.sh @@ -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 From b5cca9aabf1126070924c5130099a5e151ec3639 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 21 Nov 2019 13:52:39 +0100 Subject: [PATCH 2/7] CI: Add tool to enforce the string freeze - check for conventional translation tag - diff the generated translation files to enforce consistency --- ci/txcheck.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 ci/txcheck.sh diff --git a/ci/txcheck.sh b/ci/txcheck.sh new file mode 100644 index 000000000..b2c2ab11a --- /dev/null +++ b/ci/txcheck.sh @@ -0,0 +1,48 @@ +#! /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, 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 here +HEAD_SUM=$( cat $TX_FILE_LIST | sha256sum ) + +# Check from the translation tag as well +git worktree add build-txcheck translation +( cd build-txcheck && sh ci/txpush.sh --no-tx ) || { echo "! Could not re-create translations." ; exit 1 ; } +PREV_SUM=$( cd build-txcheck && cat $TX_FILE_LIST | sha256sum ) + +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/$f $f + done + exit 1 +fi + +exit 0 From e6a23842940d4bdd0e8cc5229135a72a57673c04 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 21 Nov 2019 13:57:56 +0100 Subject: [PATCH 3/7] CI: do all tx checking in worktrees --- ci/txcheck.sh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/ci/txcheck.sh b/ci/txcheck.sh index b2c2ab11a..39b4fdcb0 100644 --- a/ci/txcheck.sh +++ b/ci/txcheck.sh @@ -26,13 +26,27 @@ for f in $TX_FILE_LIST ; do test -f $f || { echo "! Translation file '$f' does not exist." ; exit 1 ; } done -# The state of translations here -HEAD_SUM=$( cat $TX_FILE_LIST | sha256sum ) +# 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 -git worktree add build-txcheck translation -( cd build-txcheck && sh ci/txpush.sh --no-tx ) || { echo "! Could not re-create translations." ; exit 1 ; } -PREV_SUM=$( cd build-txcheck && cat $TX_FILE_LIST | sha256sum ) +HEAD_SUM=`tx_sum build-txcheck-head ""` +PREV_SUM=`tx_sum build-txcheck-prev translation` + +test -d build-txcheck-head || exit 1 +test -d build-txcheck-prev || exit 1 + +echo "HEAD=$HEAD_SUM" +echo "PREV=$PREV_SUM" if test "$HEAD_SUM" = "$PREV_SUM" ; then : @@ -40,7 +54,7 @@ else echo "! Translations have changed." for f in $TX_FILE_LIST ; do echo "! $f" - diff -u build-txcheck/$f $f + diff -u build-txcheck-prev/$f build-txcheck-head/$f done exit 1 fi From bf21e8a4f54464cb114eb247e2dfa0608a132d4e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 21 Nov 2019 14:07:41 +0100 Subject: [PATCH 4/7] CI: clean up after tx checking --- ci/txcheck.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ci/txcheck.sh b/ci/txcheck.sh index 39b4fdcb0..f94f035fd 100644 --- a/ci/txcheck.sh +++ b/ci/txcheck.sh @@ -42,11 +42,9 @@ tx_sum() HEAD_SUM=`tx_sum build-txcheck-head ""` PREV_SUM=`tx_sum build-txcheck-prev translation` -test -d build-txcheck-head || exit 1 -test -d build-txcheck-prev || exit 1 - -echo "HEAD=$HEAD_SUM" -echo "PREV=$PREV_SUM" +# 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 : @@ -59,4 +57,9 @@ else 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 + exit 0 From a0556d1dd720ece5c4ab75026087db5b7ed7b160 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 21 Nov 2019 14:23:00 +0100 Subject: [PATCH 5/7] CI: enforce 1 week of string freeze --- ci/txcheck.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ci/txcheck.sh b/ci/txcheck.sh index f94f035fd..1fe01c477 100644 --- a/ci/txcheck.sh +++ b/ci/txcheck.sh @@ -18,7 +18,12 @@ else echo "! There are local changes." exit 1 fi -# No unsaved changes, collect names of relevant files +# 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 ) From d3cc4ec395d0cf89ca957ba2b6afbc91ae3d17ac Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 21 Nov 2019 14:23:46 +0100 Subject: [PATCH 6/7] CI: silence git branch during cleanup of txcheck --- ci/txcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/txcheck.sh b/ci/txcheck.sh index 1fe01c477..be984d22d 100644 --- a/ci/txcheck.sh +++ b/ci/txcheck.sh @@ -65,6 +65,6 @@ 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 +git branch -D build-txcheck-head > /dev/null 2>&1 exit 0 From f51111d0f3d5c5163d74181dc53b4d03c17db4d3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 21 Nov 2019 14:29:54 +0100 Subject: [PATCH 7/7] CI: Make string-freeze checking part of release process --- ci/RELEASE.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ci/RELEASE.sh b/ci/RELEASE.sh index f79b0ed4a..b3c6592b1 100755 --- a/ci/RELEASE.sh +++ b/ci/RELEASE.sh @@ -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 # #