Skip to content

Commit

Permalink
GHA: More robust OTA updates action
Browse files Browse the repository at this point in the history
Make the OTA translation updates action more robust:

Split checking PO validity and uploading into separate steps and if
there are errors, still upload the rest of the files. Otherwise one bad
translation was blocking everything else.

Add a separate step for checking validity so that the run fails on
errors.

Add logging of failed files and their content for easier debugging.
  • Loading branch information
vslavik committed Jul 10, 2024
1 parent 16308ff commit 2bd36e4
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
44 changes: 36 additions & 8 deletions .github/workflows/build-ota-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,56 @@ on:
- cron: '11 10 * * *'

jobs:
build-ota-translations:
name: Build OTA translations
download-translations:
name: Download translations from Crowdin
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install GNU gettext
run: sudo apt-get install gettext

- name: Install Crowdin CLI
run: npm i -g @crowdin/cli

- name: Download latest translations from Crowdin
run: |
echo 'api_token: "${{secrets.CROWDIN_PERSONAL_TOKEN}}"' >>crowdin.yaml
crowdin download
rm crowdin.yaml
- uses: actions/upload-artifact@v4
with:
name: translations
path: locales/*.po

check-po-validity:
name: Check translations
runs-on: ubuntu-latest
needs: download-translations
steps:
- uses: actions/download-artifact@v4
with:
name: translations
path: locales
- name: Install GNU gettext
run: sudo apt-get install gettext
- name: Check PO files with msgfmt -v -c
run: |
for i in locales/*.po ; do
echo "checking $i..."
msgfmt -v -c -o /dev/null $i
done
build-ota-translations:
name: Build OTA translations
runs-on: ubuntu-latest
needs: download-translations
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: translations
path: locales
- name: Install GNU gettext
run: sudo apt-get install gettext
- name: Build OTA updates
run: scripts/build-ota-translations.sh

- name: Upload OTA updates
run: |
VERSION=$(sed -n -e 's/.*POEDIT_VERSION.* "\([0-9]*\)\.\([0-9]*\).*".*/\1.\2/p' src/version.h)
Expand Down
11 changes: 11 additions & 0 deletions scripts/build-ota-translations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ function finish {
}
trap finish EXIT

# check PO files for errors and remove the ones that won't compile:
for po in locales/*.po ; do
if ! stderr=$(msgfmt -c -o /dev/null "$po" 2>&1) ; then
echo "::error title=Failed to compile $po::`echo $stderr`"
echo "::group::cat -n $po"
cat -n "$po"
echo "::endgroup::"
rm "$po"
fi
done

# compile PO files, taking care to make them reproducible, i.e. not change if the actual
# translations didn't change:
for po in locales/*.po ; do
Expand Down

0 comments on commit 2bd36e4

Please sign in to comment.