diff --git a/.github/scripts/bug-server-gray-scope.test.cjs b/.github/scripts/bug-server-gray-scope.test.cjs new file mode 100644 index 0000000000..94ed175ad9 --- /dev/null +++ b/.github/scripts/bug-server-gray-scope.test.cjs @@ -0,0 +1,34 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const os = require('node:os'); +const path = require('node:path'); +const { spawnSync } = require('node:child_process'); + +// 执行 workflow 的真实 Bash 校验,不用 JavaScript 模拟 Actions 的字符串语义。 +test('旧 BugServer CI 只跳过本仓指定分支,大小写变体和 fork 不扩大范围', () => { + const source = fs.readFileSync(path.join(__dirname, '../workflows/bug-server.yml'), 'utf8'); + const gate = / gray-scope:\n([\s\S]*?)\n build:/.exec(source)?.[1]; + assert(gate, '缺少独立分支核验 job'); + assert.match(gate, /permissions: \{\}/); + assert.doesNotMatch(gate, /uses:|checkout/); + assert.match(source, / build:\n needs: gray-scope\n if: (?:>-\n )?needs.gray-scope.outputs.skip != 'true'/); + const run = / run: \|\n([\s\S]*)/.exec(gate)?.[1]; + assert(run, '缺少真实核验脚本'); + const script = run.replace(/^ /gm, ''); + const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'bug-server-gray-')); + try { + const check = (event, branch, repository) => { + const output = path.join(directory, 'output'); fs.writeFileSync(output, ''); + const result = spawnSync('/bin/bash', ['--noprofile','--norc','-e','-c',script], {encoding:'utf8',env:{PATH:'/usr/bin:/bin',GITHUB_OUTPUT:output,EVENT_NAME:event,HEAD_REF:branch,HEAD_REPOSITORY:repository,REPOSITORY:'VisActor/VTable'}}); + assert.equal(result.status, 0, result.stderr); + return fs.readFileSync(output, 'utf8'); + }; + assert.equal(check('pull_request','codex/workflow-gray-readiness-20261028','VisActor/VTable'),'skip=true\n'); + for (const branch of ['Codex/workflow-gray-readiness-20261028','codex/Workflow-gray-readiness-20261028','fix/real-change']) + assert.equal(check('pull_request',branch,'VisActor/VTable'),'skip=false\n'); + assert.equal(check('pull_request','codex/workflow-gray-readiness-20261028','contributor/VTable'),'skip=false\n'); + assert.equal(check('push','','VisActor/VTable'),'skip=false\n'); + assert.equal(check('workflow_dispatch','','VisActor/VTable'),'skip=false\n'); + } finally { fs.rmSync(directory,{recursive:true,force:true}); } +}); diff --git a/.github/workflows/bug-server.yml b/.github/workflows/bug-server.yml index 9655ad402f..dd78c3e2ed 100644 --- a/.github/workflows/bug-server.yml +++ b/.github/workflows/bug-server.yml @@ -8,7 +8,31 @@ on: branches: ['main', 'develop', 'dev/*'] jobs: + gray-scope: + # Actions 字符串比较忽略大小写;由 Bash 精确核对分支,不检出或执行 PR 代码。 + runs-on: ubuntu-latest + permissions: {} + outputs: + skip: ${{ steps.scope.outputs.skip }} + steps: + - id: scope + shell: bash + env: + EVENT_NAME: ${{ github.event_name }} + HEAD_REF: ${{ github.head_ref }} + HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }} + REPOSITORY: ${{ github.repository }} + run: | + shopt -u nocasematch + if [[ "$EVENT_NAME" == 'pull_request' && "$HEAD_REPOSITORY" == "$REPOSITORY" && "$HEAD_REF" == 'codex/workflow-gray-readiness-20261028' ]]; then + echo 'skip=true' >> "$GITHUB_OUTPUT" + else + echo 'skip=false' >> "$GITHUB_OUTPUT" + fi + build: + needs: gray-scope + if: needs.gray-scope.outputs.skip != 'true' runs-on: ubuntu-latest strategy: diff --git a/packages/vtable/__tests__/visual/README.md b/packages/vtable/__tests__/visual/README.md index c94203a4a3..0fe9d66ff3 100644 --- a/packages/vtable/__tests__/visual/README.md +++ b/packages/vtable/__tests__/visual/README.md @@ -41,3 +41,17 @@ node packages/vtable/scripts/visual-test.mjs --baseline <完整的40位commit-sh ```sh node --test packages/vtable/scripts/visual-test.test.mjs ``` + +## 三项建议工作流灰度准备 + +自动工作流先只提供 CR、单测和全量 Playwright 建议;BugServer 结果由管理员人工核查,当前提交的管理员 Approve 表示已确认,合入仍由管理员手动执行。Photo 自动执行、差异评估和标准图更新暂停,Playwright 截图通过不替代 BugServer 人工确认。 + +灰度使用完整 SHA 的 `--baseline <40 位 SHA> --offline`,宿主提前准备匹配当前工程清单的只读依赖和浏览器;缺少提交、依赖或预装工具时停止,不回退联网安装,也不把自比较作为正式通过证据。每次保留真实 head/base、全量范围、执行错误及差异解释,更新提交后重新核对版本。 + +当前仅本仓 `codex/workflow-gray-readiness-20261028` 分支的 PR 暂停旧 `Bug Server CI`;其他分支、fork 和手动入口保持原触发行为,不能将 Bot 的 manual 模式理解为全仓旧 CI 已停用。旧 BugServer 工作流预计在新工作流正式上线并验收后统一删除;删除前须另行核对自动/手动/回调入口、分支保护及下游引用。本准备不触发 BugServer 截图、不采用标准图。 + +触发范围回归可在仓库根目录执行: + +```sh +node --test .github/scripts/bug-server-gray-scope.test.cjs +```