Skip to content

Commit e74271a

Browse files
mmckyclaude
andauthored
Migrate translation workflows to @v0 and the upstream review template (#73)
* Migrate translation workflows to @v0 and the upstream review template Moves review and rebase off the exact `@v0.16.1` pin onto the floating `@v0` tag, per the pin policy settled in QuantEcon/project-translation#9, and replaces the original `translate setup` review workflow with the upstream template from action-translation docs/user/tutorials/connect-existing.md. This was the least-protected review workflow in the estate. It had no `labeled` trigger, no concurrency group and no `permissions` block, so: - a sync's `labeled` events started no review at all on that event type, and nothing serialised concurrent runs against the same PR; - v0.17.0's review dedupe deletes superseded comments, which needs `pull-requests: write` — absent here, so dedupe could not work. The pin was also two releases behind. v0.18.0 carries the fix for a review-mode defect where a model response missing a criterion score became NaN and rendered as an automatic FAIL on otherwise clean PRs See QuantEcon/action-translation#102 — this repo is exposed to it today. The job-level (not workflow-level) concurrency placement is deliberate and field-verified: the group is entered only after the job's `if` has passed, so a `labeled` event for 'automated' skips out without cancelling the in-flight real review. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Rebase: also match resync/* branches (action-translation v0.18.1) The rebase workflow only fired for `translation-sync-*` branches, which the Action's sync mode creates. The CLI's `translate forward --github` creates `resync/{stem}` branches, so merging one resync PR never rebased its siblings — during a drift-recovery wave that leaves a stack of open PRs whose bases go stale with every merge. Fixed engine-side in action-translation v0.18.1, but the action-side half is not sufficient on its own: this `if` gates whether the job runs at all, and it runs before the action does. Both layers must list both prefixes or the result is a job that never starts. Brings this file in step with the upstream template as of that release. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d5a4f5b commit e74271a

2 files changed

Lines changed: 40 additions & 9 deletions

File tree

.github/workflows/rebase-translations.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Rebase Translation PRs
22
#
33
# Install this workflow in the TARGET (translated) repository.
4-
# When a translation-sync PR is merged, this workflow automatically
5-
# rebases other open translation-sync PRs against the updated main branch.
4+
# When a translation PR is merged, this workflow automatically rebases the
5+
# other open translation PRs against the updated main branch. It covers both
6+
# kinds this tool creates: `translation-sync-*` branches from the Action's sync
7+
# mode, and `resync/*` branches from the CLI's `forward --github`.
68
#
79
# This eliminates merge conflicts caused by multiple upstream PRs
810
# modifying the same files. See: https://github.com/QuantEcon/action-translation/issues/63
@@ -17,10 +19,16 @@ on:
1719

1820
jobs:
1921
rebase:
20-
# Only run when a translation-sync PR is merged
22+
# Only run when a translation PR is merged. Both prefixes must be listed:
23+
# sync mode creates `translation-sync-*`, while the CLI's `forward --github`
24+
# creates `resync/*`, and a wave of resync PRs goes stale the same way.
25+
# Keep this in step with `isTranslationBranch` in the action's src/branch-naming.ts
26+
# — this `if` decides whether the job runs, that predicate decides which open PRs
27+
# it then rebases, so a prefix matching only one of them is a no-op run.
2128
if: >
2229
github.event.pull_request.merged == true &&
23-
startsWith(github.event.pull_request.head.ref, 'translation-sync-')
30+
(startsWith(github.event.pull_request.head.ref, 'translation-sync-') ||
31+
startsWith(github.event.pull_request.head.ref, 'resync/'))
2432
runs-on: ubuntu-latest
2533

2634
permissions:
@@ -34,7 +42,7 @@ jobs:
3442

3543
steps:
3644
- name: Rebase open translation PRs
37-
uses: QuantEcon/action-translation@v0.16.1
45+
uses: QuantEcon/action-translation@v0
3846
with:
3947
mode: rebase
4048
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}

.github/workflows/review-translations.yml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,44 @@
1-
# Auto-generated by `translate setup`
1+
# Review Translations — Quality check on translation PRs
2+
# When a PR is opened/updated that carries the 'action-translation' label,
3+
# this workflow runs a quality review and posts a comment.
4+
#
5+
# Mirrors the upstream template in action-translation
6+
# docs/user/tutorials/connect-existing.md — keep it in step with that.
27
name: Review Translations
38

49
on:
510
pull_request:
6-
types: [opened, synchronize]
11+
types: [opened, synchronize, labeled, reopened]
712

813
jobs:
914
review:
10-
if: contains(github.event.pull_request.labels.*.name, 'action-translation')
15+
# Ignore `labeled` events for every other label: a sync adds its labels in a single
16+
# addLabels call, but GitHub emits one `labeled` event per label, and each would
17+
# otherwise start a full (billed) review of the same diff.
18+
if: >
19+
contains(github.event.pull_request.labels.*.name, 'action-translation') &&
20+
(github.event.action != 'labeled' || github.event.label.name == 'action-translation')
1121
runs-on: ubuntu-latest
1222

23+
# v0.17.0's review dedupe deletes superseded comments, which needs pull-requests: write.
24+
permissions:
25+
contents: read
26+
pull-requests: write
27+
28+
# One review per PR — supersede an in-flight review instead of running both.
29+
# Job-level (not workflow-level) on purpose: the group is entered only after the `if`
30+
# above has passed, so a `labeled` event for 'automated' skips out without cancelling
31+
# the real review. At workflow level it would cancel first and skip second, leaving none.
32+
concurrency:
33+
group: review-translations-${{ github.event.pull_request.number }}
34+
cancel-in-progress: true
35+
1336
steps:
1437
- uses: actions/checkout@v4
1538
with:
1639
fetch-depth: 2
1740

18-
- uses: QuantEcon/action-translation@v0.16.1
41+
- uses: QuantEcon/action-translation@v0
1942
with:
2043
mode: review
2144
source-repo: QuantEcon/lecture-python-programming

0 commit comments

Comments
 (0)