Skip to content

Commit 7c256f1

Browse files
committed
ci: tighten push workflow parity
1 parent 5077baa commit 7c256f1

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
permissions:
88
contents: read
99

10+
concurrency:
11+
group: ci-${{ github.ref }}
12+
cancel-in-progress: true
13+
1014
jobs:
1115
test:
1216
name: Test on Node.js ${{ matrix.node-version }}

test/ci-workflows.test.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ function readWorkflow(name: string): string {
88
return readFileSync(join(projectRoot, ".github", "workflows", name), "utf-8");
99
}
1010

11+
function extractJobBlock(workflow: string, jobName: string): string {
12+
const start = workflow.indexOf(` ${jobName}:`);
13+
if (start === -1) {
14+
throw new Error(`Missing workflow job: ${jobName}`);
15+
}
16+
const nextMatch = workflow
17+
.slice(start + 1)
18+
.match(/\n [a-z0-9][a-z0-9-]*:\n/);
19+
const end = nextMatch ? start + 1 + nextMatch.index + 1 : workflow.length;
20+
return workflow.slice(start, end);
21+
}
22+
1123
describe("CI workflow parity", () => {
1224
it("keeps push CI aligned with the PR release harness checks", () => {
1325
const ci = readWorkflow("ci.yml");
@@ -24,13 +36,25 @@ describe("CI workflow parity", () => {
2436
}
2537
});
2638

39+
it("keeps push CI using the same stale-run cancellation as PR CI", () => {
40+
const ci = readWorkflow("ci.yml");
41+
const prCi = readWorkflow("pr-ci.yml");
42+
43+
expect(prCi).toContain("concurrency:");
44+
expect(prCi).toContain("cancel-in-progress: true");
45+
expect(ci).toContain("concurrency:");
46+
expect(ci).toContain("cancel-in-progress: true");
47+
});
48+
2749
it("keeps Windows script typecheck coverage in push and PR CI", () => {
2850
const ci = readWorkflow("ci.yml");
2951
const prCi = readWorkflow("pr-ci.yml");
52+
const ciWindowsJob = extractJobBlock(ci, "scripts-windows");
53+
const prWindowsJob = extractJobBlock(prCi, "scripts-windows");
3054

31-
expect(ci).toContain("runs-on: windows-latest");
32-
expect(ci).toContain("npm run typecheck:scripts");
33-
expect(prCi).toContain("runs-on: windows-latest");
34-
expect(prCi).toContain("npm run typecheck:scripts");
55+
expect(ciWindowsJob).toContain("runs-on: windows-latest");
56+
expect(ciWindowsJob).toContain("npm run typecheck:scripts");
57+
expect(prWindowsJob).toContain("runs-on: windows-latest");
58+
expect(prWindowsJob).toContain("npm run typecheck:scripts");
3559
});
3660
});

0 commit comments

Comments
 (0)