Skip to content

feat(ci): 翻译目录自动化——PR 内自动补译 + 每日兜底同步 - #608

Merged
gansx merged 3 commits into
mainfrom
gansx/translation-catalog-automation
Oct 28, 2026
Merged

gansx merged 3 commits into
mainfrom
gansx/translation-catalog-automation

Conversation

@gansx

@gansx gansx commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

背景

源文案变更后需要作者本地手动跑 catalog:import-legacy + catalog:translate,漏跑就会被翻译完整性检查卡住(#599 的教训)。本 PR 把这两步自动化,方案与实施计划见:

  • docs/design/translation-catalog-automation.md
  • docs/design/translation-catalog-automation-implementation-plan.md

改动

  1. translate-pr-catalogs.yml(主链路):PR 改动四个真源文件(两个 TS locale + 两个 additional JSON)时,checkout PR head → 导入 → 增量翻译 53 个语言 → 有 diff 才以 App bot 身份提交推回 PR 分支。
    • 仅同仓库分支执行(fork PR 整 job 跳过,不给写权限跑不可信代码)
    • 推送前重新校验 head SHA 防止覆盖作者新提交
    • 机器人只提交 catalogs/*.json,不在触发路径内,不会自我循环
    • 按 PR 编号并发分组,新 push 取消旧翻译
  2. sync-translation-catalogs.yml(辅链路):每日 03:41 UTC + 手动触发,仅 main;漂移时推送 automation/translation-catalogs 分支 → 开/更新 PR → --auto --squash --match-head-commit 走正常门禁自动合并。结构与模型目录同步完全对齐。
  3. scripts/ci/automation-pr.mjs:通用化的"唯一开放自动化 PR"选择器(fail-closed),不动既有 provider-model-catalog-pr.mjs。
  4. 契约测试:automation-pr.test.mjs + translation-workflows.test.mjs,包含用模拟 gh/git 真实执行工作流 shell 步骤(edit/create/歧义/跨仓库全路径),CI 的 common lane 会自动跑。

安全

  • 复用现有 MODEL_CATALOG_APP_* 凭证,不新增 App/secret;内置权限保持 contents: read,写权限只在仓库级 App token 的短命凭证里
  • 机翻结果仍须通过 catalog:check(占位符/受保护 token/sourceHash/完整性),门禁标准不变

验证

  • node --test scripts/ci/automation-pr.test.mjs scripts/ci/translation-workflows.test.mjs 12 项全绿
  • import-legacy-web-catalogs.mjs 在当前 main 上幂等(无 diff)
  • 两个 workflow YAML 解析通过,触发器/作业结构符合预期
  • 合并后按计划用测试 PR 实测主链路,并 workflow_dispatch 空跑兜底链路

…stop

Source-string changes currently require authors to run the localization
pipeline by hand; skipping it fails the catalog completeness check late in
review (e.g. #599). Automate the two manual steps with the installed catalog
GitHub App:

- translate-pr-catalogs.yml: on PRs touching the en-US/zh-CN TS sources or
  additional JSON, import sources and incrementally translate all 53 target
  locales, committing catalog diffs back to the PR branch. Same-repository
  heads only (fork PRs skip), head SHA re-checked before push, and bot commits
  touch only catalogs/*.json so the workflow cannot retrigger itself.
- sync-translation-catalogs.yml: daily + dispatch backstop on main that opens
  or refreshes an automation/translation-catalogs PR and auto-merges it through
  the normal required checks, mirroring sync-provider-model-catalog.yml.
- scripts/ci/automation-pr.mjs: generalized sole-open-PR selector with
  fail-closed validation, plus workflow contract tests that execute the shell
  steps against simulated gh/git.

Design contract and plan: docs/design/translation-catalog-automation*.md
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T04:20:44.275415Z f218791 New commits
🔒 Security Review ✅ Completed 2026-10-28T04:22:49.806964Z f218791 New commits

Security findings

Advisory findings (1)

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3600c5ad03

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…rces

The importer resolves the workspace typescript dependency; fresh runners have
no node_modules. Install the pinned pnpm store (cached) in both translation
workflows ahead of the import step, and assert the ordering in the workflow
contract tests.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5fa5113502

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 5fa5113502

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

…ll scripts

setup-node's pnpm cache resolves pnpm store path, which fails before pnpm
exists; mirror ci.yml's pnpm/action-setup ordering. Lifecycle scripts from
checked-out code could persist shims through GITHUB_PATH, so install with
--ignore-scripts; the importer and translator only need module resolution.
Contract tests assert both orderings.
@gansx
gansx merged commit 3a7c4a8 into main Oct 28, 2026
15 checks passed
@gansx
gansx deleted the gansx/translation-catalog-automation branch October 28, 2026 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant