xiaozhi-esp32-server/.github/workflows/upstream-sync-check.yml
lapy cd83c805f5 chore(westernization): add rebase-verification tooling and docs
The October rebase silently shipped runtime-breaking merge artifacts that
neither the web build nor the test suites caught (blank models page,
ReferenceError on role open, broken provider management). Make every one
of those failure classes fail loudly and early:

- manager-web/scripts/integrity-check.js: AST pass (acorn + eslint-scope)
  for undefined identifiers (lost imports, dropped function params and
  const bindings), vue-template-compiler pass for mismatched tags, and a
  duplicate-options-key pass (double 'computed:' clobbering). Negative-
  tested against reproductions of all three shipped bugs.
- manager-web/scripts/check-i18n.js rewritten for the fork: base locale
  is en, locales discovered dynamically, plus a pass that fails when any
  $t('a.b') key referenced in src/ has no definition (upstream rebases
  kept adding views with keys never added downstream).
- scripts/westernization_rebase_check.sh: one-command gate chaining audit,
  integrity, i18n parity, snapshot/contract/unit tests and the production
  build; heavier Java/Python suites run only when toolchains exist.
- scripts/translate_han_llm.py: vendored from the one-off /tmp tool used
  for the translation sweep; repo-relative paths, endpoint/model via
  TRANSLATE_API/TRANSLATE_MODEL env, cache gitignored.
- CI: the Vue job now runs integrity-check, check:i18n, test:snapshot and
  test:contract before test:unit; new nightly Upstream Sync Check workflow
  dry-merges upstream/main into a throwaway branch and runs the same web
  gates so a breaking incoming merge alerts before a human sync.
- westernization.md: tooling table, five known merge-corruption failure
  classes with symptoms and repair strategy, translator usage, updated
  rebase order and good-outcome checklist.

acorn and eslint-scope are now explicit devDependencies.
2026-10-13 11:35:11 +01:00

51 lines
1.8 KiB
YAML

name: Upstream Sync Check
# Nightly dry-run: merge upstream/main into the downstream branch in a
# throwaway workspace and run the web verification gates against the merged
# result. This gives an early, loud signal ("the next sync will break") the
# night before a human performs the real sync, instead of after deploy.
# It never pushes anything.
on:
schedule:
- cron: '30 4 * * *' # 04:30 UTC daily
workflow_dispatch:
jobs:
dry-merge:
name: Merge upstream/main and run web gates
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure git identity
run: |
git config user.email "ci@localhost"
git config user.name "upstream-sync-check"
- name: Merge upstream/main (dry run)
run: |
git remote add upstream https://github.com/xinnan-tech/xiaozhi-esp32-server.git || true
git fetch upstream main
git checkout -B sync-dry-run
if ! git merge --no-commit --no-ff upstream/main; then
echo "::error::upstream/main no longer merges cleanly into this branch; resolve conflicts before syncing"
git diff --name-only --diff-filter=U || true
exit 1
fi
echo "MERGED_CLEAN=1" >> "$GITHUB_ENV"
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: main/manager-web/package-lock.json
- name: Web gates on merged tree
working-directory: main/manager-web
run: |
npm ci --no-audit --no-fund
node scripts/integrity-check.js
npm run --silent check:i18n
npm run --silent test:snapshot
npm run --silent test:contract
- name: Westernization audit on merged tree
run: bash scripts/westernization_audit.sh