diff --git a/test/scripts/ci-workflow-guards.test.ts b/test/scripts/ci-workflow-guards.test.ts index c5001dfb6d8..b61541b8a66 100644 --- a/test/scripts/ci-workflow-guards.test.ts +++ b/test/scripts/ci-workflow-guards.test.ts @@ -50,24 +50,27 @@ describe("ci workflow guards", () => { it("kills timed manual checkout fetches after the grace period", () => { const workflowPaths = [ - ".github/workflows/ci.yml", - ".github/workflows/workflow-sanity.yml", - ".github/workflows/ci-check-testbox.yml", - ".github/workflows/ci-check-arm-testbox.yml", - ".github/workflows/ci-build-artifacts-testbox.yml", - ".github/workflows/crabbox-hydrate.yml", + [".github/workflows/ci.yml", "120s"], + [".github/workflows/workflow-sanity.yml", "30s"], + [".github/workflows/ci-check-testbox.yml", "120s"], + [".github/workflows/ci-check-arm-testbox.yml", "120s"], + [".github/workflows/ci-build-artifacts-testbox.yml", "120s"], + [".github/workflows/crabbox-hydrate.yml", "30s"], ]; - for (const workflowPath of workflowPaths) { + for (const [workflowPath, timeoutSeconds] of workflowPaths) { const workflow = readFileSync(workflowPath, "utf8"); const fetchTimeouts = workflow.match( - /timeout --signal=TERM[^\n]* (?:30s|120s) git(?: -C "(?:\$workdir|\$GITHUB_WORKSPACE|clawhub-source)")?/g, + new RegExp( + `timeout --signal=TERM[^\\n]* ${timeoutSeconds} git(?: -C "(?:\\$workdir|\\$GITHUB_WORKSPACE|clawhub-source)")?`, + "g", + ), ); expect(fetchTimeouts?.length, workflowPath).toBeGreaterThan(0); expect( fetchTimeouts?.every((line) => - /^timeout --signal=TERM --kill-after=10s (?:30s|120s) git/.test(line), + line.startsWith(`timeout --signal=TERM --kill-after=10s ${timeoutSeconds} git`), ), workflowPath, ).toBe(true);