Skip to content

Commit

Permalink
Merge pull request #7222 from freedomofpress/l10n-gha
Browse files Browse the repository at this point in the history
Migrate translation-tests to GitHub Actions
  • Loading branch information
cfm authored Aug 15, 2024
2 parents bd56cb7 + 92798a6 commit 8387df8
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 58 deletions.
58 changes: 0 additions & 58 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,47 +101,6 @@ jobs:
DOCKER_BUILD_ARGUMENTS="--cache-from securedrop-test-focal-py3:${fromtag:-latest}" securedrop/bin/dev-shell \
bash -c "/opt/venvs/securedrop-app-code/bin/pip3 install --require-hashes -r requirements/python3/develop-requirements.txt && make -C .. verify-mo"
translation-tests:
machine:
image: ubuntu-2004:current
enabled: true
environment:
DOCKER_API_VERSION: 1.24
BASE_OS: focal
parallelism: 21
steps:
- run:
name: Only run on translation pull requests
command: |
if [ "$CIRCLE_PR_USERNAME" != "weblate-fpf" ]; then
circleci-agent step halt
fi
- checkout
- *rebaseontarget
- *createcachedir
- *restorecache
- *loadimagelayers
- *dockerimagebuild
- *saveimagelayers
- *savecache

- run:
name: Run tests
command: |
sudo apt update && sudo apt install python3-sh python3-babel
NUM_SUPPORTED_LOCALES="$(make count-supported-locales)"
[[ "$NUM_SUPPORTED_LOCALES" -eq "$CIRCLE_NODE_TOTAL" ]] || { echo "Parallelism (${CIRCLE_NODE_TOTAL} must equal the number of supported languages (${NUM_SUPPORTED_LOCALES})."; exit 1; }
export LOCALES="$(make supported-locales | jq --raw-output 'join("\n")' | circleci tests split)"
fromtag=$(docker images | grep securedrop-test-focal-py3 | head -n1 | awk '{print $2}')
DOCKER_BUILD_ARGUMENTS="--cache-from securedrop-test-focal-py3:${fromtag:-latest}" make translation-test
- store_test_results:
path: ~/project/test-results

- store_artifacts:
path: ~/project/test-results

staging-test-with-rebase:
machine:
image: ubuntu-2004:current
Expand Down Expand Up @@ -189,12 +148,6 @@ workflows:
context:
- circleci-slack
<<: *slack-fail-post-step
- translation-tests:
requires:
- lint
context:
- circleci-slack
<<: *slack-fail-post-step

nightly:
triggers:
Expand All @@ -206,14 +159,3 @@ workflows:
- develop
jobs:
- staging-test-with-rebase

weekly:
triggers:
- schedule:
cron: "0 0 * * 0"
filters:
branches:
only:
- develop
jobs:
- translation-tests
58 changes: 58 additions & 0 deletions .github/workflows/translation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Translation
on:
push:
branches:
- 'l10n-*'
pull_request:
schedule:
# Weekly on Sundays
- cron: '0 3 * * 0'

# Only build for latest push/PR unless it's main or release/
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !startsWith( github.ref, 'refs/heads/release/' ) }}

jobs:
locales:
runs-on: ubuntu-latest
outputs:
locales: ${{ steps.locales.outputs.locales }}
steps:
- uses: actions/checkout@v4
- name: Generate locale list
id: locales
run: |
# We only want to run if it's:
# 1. A pull request from the weblate-fpf user
# 2. A scheduled run
# 3. A push to a `l10n-*` branch
# Two and Three are checked above, so we just need to check One.
if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.actor }}" = "weblate-fpf" ]; then
echo "locales=$(make supported-locales)" >> "$GITHUB_OUTPUT"
else
if [ "${{ github.event_name }}" != "pull_request" ]; then
echo "locales=$(make supported-locales)" >> "$GITHUB_OUTPUT"
else
# skip: non weblate-fpf PR, just output an empty list
echo "locales=[]" >> "$GITHUB_OUTPUT"
fi
fi
test:
runs-on: ubuntu-latest
needs: locales
# If we're in the skip case above, we'll have an empty list
if: "join(fromJSON(needs.locales.outputs.locales), '') != ''"
strategy:
fail-fast: false
matrix:
locale: ${{ fromJson(needs.locales.outputs.locales) }}
steps:
- uses: actions/checkout@v4
- name: Build image
run: |
DOCKER_BUILD_VERBOSE=true ./securedrop/bin/dev-shell true
- name: Run translation tests
run: |
LOCALES="${{ matrix.locale }}" make translation-test

0 comments on commit 8387df8

Please sign in to comment.