From 2ce4a7483a82f952ba689df13a5ec35d7d474cbc Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Tue, 23 Jun 2026 07:11:23 +0800 Subject: [PATCH] fix(ci): use workflow revision for proof checks Checkout the trusted workflow revision for the Real behavior proof gate so old PR events with stale base SHAs can still run the current checker scripts. Proof: - `tbx_01kvrrqq6tnwee3r41p22sy0qk`: touched-file format check passed. - `tbx_01kvrrqq6tnwee3r41p22sy0qk`: `corepack pnpm test:serial test/scripts/ci-workflow-guards.test.ts` passed. - `tbx_01kvrrqq6tnwee3r41p22sy0qk`: `corepack pnpm check:changed` passed for tooling. - PR CI passed with no failing or pending checks. --- .github/workflows/real-behavior-proof.yml | 4 +++- test/scripts/ci-workflow-guards.test.ts | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/real-behavior-proof.yml b/.github/workflows/real-behavior-proof.yml index 015810240f06..55d6b2a9ea03 100644 --- a/.github/workflows/real-behavior-proof.yml +++ b/.github/workflows/real-behavior-proof.yml @@ -24,7 +24,9 @@ jobs: steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 with: - ref: ${{ github.event.pull_request.base.sha }} + # Old PR events can carry a stale base SHA that predates current + # trusted checker scripts. Use the workflow revision instead. + ref: ${{ github.workflow_sha }} persist-credentials: false - uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3 id: app-token diff --git a/test/scripts/ci-workflow-guards.test.ts b/test/scripts/ci-workflow-guards.test.ts index 7a4e114dbff8..f5ecb1c47d44 100644 --- a/test/scripts/ci-workflow-guards.test.ts +++ b/test/scripts/ci-workflow-guards.test.ts @@ -15,6 +15,10 @@ function readWorkflowSanityWorkflow() { return parse(readFileSync(".github/workflows/workflow-sanity.yml", "utf8")); } +function readRealBehaviorProofWorkflow() { + return parse(readFileSync(".github/workflows/real-behavior-proof.yml", "utf8")); +} + function readCriticalQualityWorkflow() { return readFileSync(".github/workflows/codeql-critical-quality.yml", "utf8"); } @@ -84,6 +88,18 @@ describe("ci workflow guards", () => { expect(findUnpinnedExternalActions()).toEqual([]); }); + it("runs real behavior proof from the trusted workflow revision", () => { + const workflow = readRealBehaviorProofWorkflow(); + const source = readFileSync(".github/workflows/real-behavior-proof.yml", "utf8"); + const checkout = workflow.jobs["real-behavior-proof"].steps.find( + (step) => step.uses === CHECKOUT_V6, + ); + + expect(checkout.with.ref).toBe("${{ github.workflow_sha }}"); + expect(checkout.with.ref).not.toBe("${{ github.event.pull_request.base.sha }}"); + expect(source).toContain("Old PR events can carry a stale base SHA"); + }); + it("keeps docs-change detection fail-safe and fixture-aware", () => { const action = readFileSync(".github/actions/detect-docs-changes/action.yml", "utf8"); @@ -467,7 +483,7 @@ describe("ci workflow guards", () => { expect(runStep.env.OPENCLAW_TEST_PROJECTS_PARALLEL).toBe("2"); expect(runStep.env.OPENCLAW_NODE_TEST_ENV_JSON).toBe("${{ toJson(matrix.env) }}"); expect(runStep.run).toContain("env: JSON.parse(process.env.OPENCLAW_NODE_TEST_ENV_JSON"); - expect(runStep.run).toContain("if (plan.env && typeof plan.env === \"object\""); + expect(runStep.run).toContain('if (plan.env && typeof plan.env === "object"'); expect(runStep.run).toContain("childEnv[key] = value"); });