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.
This commit is contained in:
1 parent
bd7c9abaa3
commit
87e7ac8774
15 files changed
+25
-17
No files matched your search
@@ -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: |
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
+2
-1
@@ -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 中完成首启数据目录设置 |
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export const AREAS = [
|
||||
];
|
||||
const MARKER = "<!-- reims-diagnosis:";
|
||||
const BOT = "github-actions[bot]";
|
||||
const EXCLUDES = "**/*_test.go,**/*.test.ts,**/*.test.tsx,frontend/src/i18n/domains/**,**/testdata/**";
|
||||
const EXCLUDES = "**/*_test.go,**/*.test.ts,**/*.test.tsx,frontend/src/i18n/domains/**,frontend/src/components/*.gen.ts,**/testdata/**";
|
||||
const TOKEN_BUDGET = 10_000_000;
|
||||
const MAX_OPEN_ISSUES = 6;
|
||||
const MAX_NEW_ISSUES = 2;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -23,6 +23,7 @@ const PROTOCOLS = new Set(["anthropic", "openai", "openai-responses"]);
|
||||
const DEFAULT_EXCLUDES = [
|
||||
"frontend/wailsjs/**",
|
||||
"frontend/src/i18n/domains/*.gen.ts",
|
||||
"frontend/src/components/*.gen.ts",
|
||||
"go.sum",
|
||||
"**/package-lock.json",
|
||||
"**/pnpm-lock.yaml",
|
||||
@@ -567,16 +568,18 @@ export function resumeSessionDir(settings = process.env) {
|
||||
}
|
||||
|
||||
function stateKey(stateDirectory, settings) {
|
||||
const checkout = basename(settings.GITHUB_WORKSPACE || process.cwd());
|
||||
try {
|
||||
const owner = JSON.parse(readFileSync(join(stateDirectory, "state.json"), "utf8"));
|
||||
if (typeof owner.repository === "string" && Number.isInteger(owner.pr)) {
|
||||
if (!REPOSITORY.test(owner.repository)) throw new Error("Invalid GitHub repository name");
|
||||
return owner.repository.split("/").join("-") + "-" + owner.pr;
|
||||
}
|
||||
return checkout;
|
||||
} catch {
|
||||
// Fall through to the checkout name.
|
||||
// An unreadable or invalid owner record falls back to the checkout name.
|
||||
return checkout;
|
||||
}
|
||||
return basename(settings.GITHUB_WORKSPACE || process.cwd());
|
||||
}
|
||||
|
||||
// OCR names each session directory after the repository path: it strips the
|
||||
File renamed without changes.
+9
-2
@@ -8,12 +8,16 @@ import { createTemporaryFiles } from './debug/temporary-files.mjs'
|
||||
|
||||
const frontend = path.join(REPO_ROOT, 'frontend')
|
||||
const goTrees = ['./cmd/...', './internal/...', './pkg/...', './scripts/...']
|
||||
const ciTests = fs.readdirSync(path.join(REPO_ROOT, 'scripts', 'ci'))
|
||||
.filter((name) => name.endsWith('.test.mjs'))
|
||||
.sort()
|
||||
.map((name) => path.join('scripts', 'ci', name))
|
||||
const hostInputs = [
|
||||
'REIMS_GO_TEST_CTL', 'REIMS_GO_TEST_QEMU_IMG', 'REIMS_GO_TEST_OPENCORE', 'REIMS_GO_TEST_OFFLINE_IMG',
|
||||
]
|
||||
const usage = `Usage: node scripts/test.mjs <profile>
|
||||
quick go ./internal/<package> [./pkg/<package> ...]
|
||||
quick frontend | storage | tooling
|
||||
quick frontend | storage | tooling | automation
|
||||
ci
|
||||
release
|
||||
webview2 <windows-executable>
|
||||
@@ -49,7 +53,7 @@ function select(args) {
|
||||
}
|
||||
return { profile, area, packages }
|
||||
}
|
||||
if (['frontend', 'storage', 'tooling'].includes(area) && packages.length === 0) return { profile, area }
|
||||
if (['frontend', 'storage', 'tooling', 'automation'].includes(area) && packages.length === 0) return { profile, area }
|
||||
throw new Error(usage)
|
||||
}
|
||||
|
||||
@@ -85,6 +89,7 @@ async function main(args) {
|
||||
const go = (targets, flags = []) => run('Go', 'go', ['test', '-timeout=5m', `-p=${jobs}`, ...flags, ...targets], env)
|
||||
const front = (script) => run(`Frontend ${script}`, process.execPath, ['--run', script], env, frontend)
|
||||
const tooling = () => run('Tooling', process.execPath, ['--test', 'scripts/debug/debug.test.mjs'], env)
|
||||
const automation = () => run('GitHub automation', process.execPath, ['--test', ...ciTests], env)
|
||||
|
||||
if (profile === 'webview2') {
|
||||
if (process.platform !== 'win32') throw new Error('WebView2 smoke requires Windows')
|
||||
@@ -99,12 +104,14 @@ async function main(args) {
|
||||
}
|
||||
if (area === 'frontend') await front('test')
|
||||
if (area === 'tooling') await tooling()
|
||||
if (area === 'automation') await automation()
|
||||
} else {
|
||||
await front('test')
|
||||
await front('typecheck')
|
||||
const flags = profile === 'release' ? ['-count=1', '-shuffle=on', '-tags=desktop,production'] : []
|
||||
await go(goTrees, ['-vet=all', ...flags])
|
||||
await tooling()
|
||||
await automation()
|
||||
}
|
||||
|
||||
files.close(directory)
|
||||
|
||||
Reference in new issue
Block a user