@@ -50,24 +50,27 @@ describe("ci workflow guards", () => {
|
50 | 50 | |
51 | 51 | it("kills timed manual checkout fetches after the grace period", () => { |
52 | 52 | const workflowPaths = [ |
53 | | -".github/workflows/ci.yml", |
54 | | -".github/workflows/workflow-sanity.yml", |
55 | | -".github/workflows/ci-check-testbox.yml", |
56 | | -".github/workflows/ci-check-arm-testbox.yml", |
57 | | -".github/workflows/ci-build-artifacts-testbox.yml", |
58 | | -".github/workflows/crabbox-hydrate.yml", |
| 53 | +[".github/workflows/ci.yml", "120s"], |
| 54 | +[".github/workflows/workflow-sanity.yml", "30s"], |
| 55 | +[".github/workflows/ci-check-testbox.yml", "120s"], |
| 56 | +[".github/workflows/ci-check-arm-testbox.yml", "120s"], |
| 57 | +[".github/workflows/ci-build-artifacts-testbox.yml", "120s"], |
| 58 | +[".github/workflows/crabbox-hydrate.yml", "30s"], |
59 | 59 | ]; |
60 | 60 | |
61 | | -for (const workflowPath of workflowPaths) { |
| 61 | +for (const [workflowPath, timeoutSeconds] of workflowPaths) { |
62 | 62 | const workflow = readFileSync(workflowPath, "utf8"); |
63 | 63 | const fetchTimeouts = workflow.match( |
64 | | -/timeout --signal=TERM[^\n]* (?:30s|120s) git(?: -C "(?:\$workdir|\$GITHUB_WORKSPACE|clawhub-source)")?/g, |
| 64 | +new RegExp( |
| 65 | +`timeout --signal=TERM[^\\n]* ${timeoutSeconds} git(?: -C "(?:\\$workdir|\\$GITHUB_WORKSPACE|clawhub-source)")?`, |
| 66 | +"g", |
| 67 | +), |
65 | 68 | ); |
66 | 69 | |
67 | 70 | expect(fetchTimeouts?.length, workflowPath).toBeGreaterThan(0); |
68 | 71 | expect( |
69 | 72 | fetchTimeouts?.every((line) => |
70 | | -/^timeout --signal=TERM --kill-after=10s (?:30s|120s) git/.test(line), |
| 73 | +line.startsWith(`timeout --signal=TERM --kill-after=10s ${timeoutSeconds} git`), |
71 | 74 | ), |
72 | 75 | workflowPath, |
73 | 76 | ).toBe(true); |
|