rusackas commented on code in PR #39443:
URL: https://github.com/apache/superset/pull/39443#discussion_r3229411484
##########
.github/workflows/superset-translations.yml:
##########
@@ -47,25 +50,102 @@ jobs:
babel-extract:
runs-on: ubuntu-24.04
+ permissions:
+ contents: read
+ pull-requests: read
steps:
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
submodules: recursive
+
- name: Check for file changes
id: check
uses: ./.github/actions/change-detector/
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Python
- if: steps.check.outputs.python
+ if: steps.check.outputs.python == 'true' ||
steps.check.outputs.frontend == 'true'
uses: ./.github/actions/setup-backend/
- - name: Install msgcat
- run: sudo apt update && sudo apt install gettext
+ - name: Install gettext tools
+ if: steps.check.outputs.python == 'true' ||
steps.check.outputs.frontend == 'true'
+ run: sudo apt-get update && sudo apt-get install -y gettext
+
+ # Fetch the base ref so we can compare PR-introduced regressions
+ # against a fair baseline (also runs babel_update against the base
+ # source) — this isolates the PR's contribution from any pre-existing
+ # drift on the base branch.
+ - name: Fetch base ref and create comparison worktree
+ if: steps.check.outputs.python == 'true' ||
steps.check.outputs.frontend == 'true'
+ run: |
+ # For PRs use the base branch; for direct pushes compare against the
previous commit.
+ BASE_REF="${{ github.event.pull_request.base.ref }}"
+ if [ -n "$BASE_REF" ]; then
+ git fetch --depth=1 origin "$BASE_REF"
+ else
+ git fetch --depth=2 origin "${{ github.ref }}"
+ fi
+ git worktree add /tmp/base-worktree FETCH_HEAD
+
+ # Run babel_update against BASE source + BASE translations. Any drift
+ # already present on the base branch (source strings that have changed
+ # without .po updates) shows up here as fuzzies — and will also show
+ # up in the PR run, so it cancels out in the comparison.
+ - name: Baseline — run babel_update against BASE source
+ if: steps.check.outputs.python == 'true' ||
steps.check.outputs.frontend == 'true'
+ working-directory: /tmp/base-worktree
+ run: ./scripts/translations/babel_update.sh
+
+ - name: Record baseline translation counts
+ if: steps.check.outputs.python == 'true' ||
steps.check.outputs.frontend == 'true'
+ run: |
+ python scripts/translations/check_translation_regression.py \
+ --count \
+ --translations-dir /tmp/base-worktree/superset/translations \
+ > /tmp/before.json
+
+ # Reset the PR worktree's translations to the pristine BASE state so
+ # both babel_update runs start from the same .po files. The only
+ # difference between the runs is the source code.
+ - name: Reset PR worktree translations to pristine BASE
+ if: steps.check.outputs.python == 'true' ||
steps.check.outputs.frontend == 'true'
+ run: git checkout FETCH_HEAD -- superset/translations/
- - name: Test babel extraction
- if: steps.check.outputs.python
+ - name: Run babel_update against PR source
+ if: steps.check.outputs.python == 'true' ||
steps.check.outputs.frontend == 'true'
run: ./scripts/translations/babel_update.sh
Review Comment:
Addressed in d15b869542 — dropped the "Reset PR worktree translations to
pristine BASE" step entirely. The PR run now extracts from PR source + PR
translations, so a contributor can fix a regression by committing `.po` updates
(matching the script's own remediation message). The base-worktree baseline
still absorbs any pre-existing drift on master, so the check still answers the
right question: "did this PR's net translated count drop below master's current
net translated count?"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]