From 87e7ac877443a2ebb3b7c8f2e9388cbd0d92e4ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=83=E5=B7=9D=E7=99=BD=E6=B5=AA?= <1679659@qq.com> Date: Fri, 4 Dec 2026 23:15:24 -0700 Subject: [PATCH] refactor(ci): move GitHub automation scripts under scripts/ci The repository had three script roots with three test entry points. The automation scripts now live in scripts/ci and run through scripts/test.mjs, which gained a quick automation profile and includes them in the ci and release profiles. The workflows keep checking the scripts out from the workflow commit, never from the PR branch. stateKey now returns its fallback explicitly, because the file is inside the empty-catch guard once it sits under scripts/. The review and diagnosis exclude lists also skip the generated frontend wordmark module. --- .github/workflows/ci.yml | 3 --- .github/workflows/code-diagnosis.yml | 2 +- .github/workflows/issue-triage.yml | 4 ++-- .github/workflows/pr-model.yml | 4 ++-- .github/workflows/pr-review.yml | 6 +++--- docs/testing.md | 3 ++- {.github/scripts => scripts/ci}/code-diagnosis.mjs | 2 +- .../scripts => scripts/ci}/issue-automation.test.mjs | 0 {.github/scripts => scripts/ci}/issue-triage.mjs | 0 {.github/scripts => scripts/ci}/pr-model.mjs | 0 {.github/scripts => scripts/ci}/pr-model.test.mjs | 0 .../scripts => scripts/ci}/pr-review-language.mjs | 0 {.github/scripts => scripts/ci}/pr-review.mjs | 7 +++++-- {.github/scripts => scripts/ci}/pr-review.test.mjs | 0 scripts/test.mjs | 11 +++++++++-- 15 files changed, 25 insertions(+), 17 deletions(-) rename {.github/scripts => scripts/ci}/code-diagnosis.mjs (99%) rename {.github/scripts => scripts/ci}/issue-automation.test.mjs (100%) rename {.github/scripts => scripts/ci}/issue-triage.mjs (100%) rename {.github/scripts => scripts/ci}/pr-model.mjs (100%) rename {.github/scripts => scripts/ci}/pr-model.test.mjs (100%) rename {.github/scripts => scripts/ci}/pr-review-language.mjs (100%) rename {.github/scripts => scripts/ci}/pr-review.mjs (99%) rename {.github/scripts => scripts/ci}/pr-review.test.mjs (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6aba44a..66da195 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,9 +52,6 @@ jobs: cache: pnpm cache-dependency-path: frontend/pnpm-lock.yaml - - name: Test GitHub automation scripts - run: node --test ".github/scripts/*.test.mjs" - - name: Verify CHANGELOG.md matches current version shell: pwsh run: | diff --git a/.github/workflows/code-diagnosis.yml b/.github/workflows/code-diagnosis.yml index 92a9aa9..57e1b96 100644 --- a/.github/workflows/code-diagnosis.yml +++ b/.github/workflows/code-diagnosis.yml @@ -66,4 +66,4 @@ jobs: PR_REVIEW_LLM_MODEL: ${{ vars.PR_REVIEW_LLM_MODEL || 'glm-5.4' }} PR_REVIEW_LLM_PROTOCOL: ${{ vars.PR_REVIEW_LLM_PROTOCOL || 'anthropic' }} PR_REVIEW_LLM_EXTRA_BODY: ${{ vars.PR_REVIEW_LLM_EXTRA_BODY }} - run: node .github/scripts/code-diagnosis.mjs + run: node scripts/ci/code-diagnosis.mjs diff --git a/.github/workflows/issue-triage.yml b/.github/workflows/issue-triage.yml index a554556..19ed032 100644 --- a/.github/workflows/issue-triage.yml +++ b/.github/workflows/issue-triage.yml @@ -34,7 +34,7 @@ jobs: ref: ${{ github.workflow_sha }} persist-credentials: false sparse-checkout-cone-mode: false - sparse-checkout: /.github/scripts/ + sparse-checkout: /scripts/ci/ - name: Triage issue env: GITHUB_TOKEN: ${{ github.token }} @@ -43,4 +43,4 @@ jobs: PR_REVIEW_LLM_MODEL: ${{ vars.PR_REVIEW_LLM_MODEL || 'glm-5.3-flash' }} PR_REVIEW_LLM_PROTOCOL: ${{ vars.PR_REVIEW_LLM_PROTOCOL || 'anthropic' }} PR_REVIEW_LLM_EXTRA_BODY: ${{ vars.PR_REVIEW_LLM_EXTRA_BODY }} - run: node .github/scripts/issue-triage.mjs + run: node scripts/ci/issue-triage.mjs diff --git a/.github/workflows/pr-model.yml b/.github/workflows/pr-model.yml index 9c27b3d..a6a7b02 100644 --- a/.github/workflows/pr-model.yml +++ b/.github/workflows/pr-model.yml @@ -20,8 +20,8 @@ jobs: ref: ${{ github.workflow_sha }} persist-credentials: false sparse-checkout-cone-mode: false - sparse-checkout: /.github/scripts/pr-model.mjs + sparse-checkout: /scripts/ci/pr-model.mjs - name: Check the model and coding tool declarations env: GITHUB_TOKEN: ${{ github.token }} - run: node .github/scripts/pr-model.mjs + run: node scripts/ci/pr-model.mjs diff --git a/.github/workflows/pr-review.yml b/.github/workflows/pr-review.yml index a0ff81c..6c911b9 100644 --- a/.github/workflows/pr-review.yml +++ b/.github/workflows/pr-review.yml @@ -46,8 +46,8 @@ jobs: persist-credentials: false sparse-checkout-cone-mode: false sparse-checkout: | - /.github/scripts/pr-review.mjs - /.github/scripts/pr-review-language.mjs + /scripts/ci/pr-review.mjs + /scripts/ci/pr-review-language.mjs /.opencodereview/rule.json /docs/pr-review-guidelines.md /docs/design-guidelines.md @@ -108,4 +108,4 @@ jobs: PR_REVIEW_STATE_DIR: ${{ runner.temp }}/pr-review-state/sessions PR_REVIEW_SESSION_HOME: ${{ runner.temp }}/pr-review-state/sessions PR_REVIEW_REUSE_INCOMPLETE: "true" - run: node .github/scripts/pr-review.mjs + run: node scripts/ci/pr-review.mjs diff --git a/docs/testing.md b/docs/testing.md index 8a4a4ad..c194e2f 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -8,7 +8,8 @@ | 改动前端 | `node scripts/test.mjs quick frontend` | 界面逻辑、国际化、架构约束和静态检查 | | 改动持久化或升级 | `node scripts/test.mjs quick storage` | 配置和数据目录、迁移及插件状态存储,使用真实临时文件 | | 改动调试工具 | `node scripts/test.mjs quick tooling` | 临时目录和工单工具自测 | -| 跨模块改动或提 PR | `node scripts/test.mjs ci` | 前端测试和类型检查、`cmd/`、`internal/`、`pkg/`、`scripts/` 下的 Go 测试与 vet、调试工具自测 | +| 改动 GitHub 自动化脚本 | `node scripts/test.mjs quick automation` | `scripts/ci/` 下 PR 审核、Issue 分诊、代码诊断和申报校验脚本的自测 | +| 跨模块改动或提 PR | `node scripts/test.mjs ci` | 前端测试和类型检查、`cmd/`、`internal/`、`pkg/`、`scripts/` 下的 Go 测试与 vet、调试工具自测、GitHub 自动化脚本自测 | | 核对发布候选 | `node scripts/test.mjs release` | 使用 `desktop,production` 构建标签运行同一套 Go 检查,禁用测试结果缓存并随机化用例顺序 | | Windows 桌面冒烟 | `node scripts/test.mjs webview2 build/bin/reims-go.exe` | 启动已构建的客户端,在真实 WebView2 中完成首启数据目录设置 | diff --git a/.github/scripts/code-diagnosis.mjs b/scripts/ci/code-diagnosis.mjs similarity index 99% rename from .github/scripts/code-diagnosis.mjs rename to scripts/ci/code-diagnosis.mjs index ab87ab8..01a51b6 100644 --- a/.github/scripts/code-diagnosis.mjs +++ b/scripts/ci/code-diagnosis.mjs @@ -18,7 +18,7 @@ export const AREAS = [ ]; const MARKER = "