|
| 1 | +import { readFileSync } from "node:fs"; |
| 2 | +import { join, resolve } from "node:path"; |
| 3 | +import { describe, expect, it } from "vitest"; |
| 4 | + |
| 5 | +const projectRoot = resolve(process.cwd()); |
| 6 | + |
| 7 | +function readWorkflow(name: string): string { |
| 8 | + return readFileSync(join(projectRoot, ".github", "workflows", name), "utf-8"); |
| 9 | +} |
| 10 | + |
| 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 | + |
| 23 | +describe("CI workflow parity", () => { |
| 24 | + it("keeps push CI aligned with the PR release harness checks", () => { |
| 25 | + const ci = readWorkflow("ci.yml"); |
| 26 | + const prCi = readWorkflow("pr-ci.yml"); |
| 27 | + const requiredCommands = [ |
| 28 | + "npm run typecheck:scripts", |
| 29 | + "npm run pack:check", |
| 30 | + "npm run vendor:verify", |
| 31 | + ]; |
| 32 | + |
| 33 | + for (const command of requiredCommands) { |
| 34 | + expect(prCi).toContain(command); |
| 35 | + expect(ci).toContain(command); |
| 36 | + } |
| 37 | + }); |
| 38 | + |
| 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 | + |
| 49 | + it("keeps Windows script typecheck coverage in push and PR CI", () => { |
| 50 | + const ci = readWorkflow("ci.yml"); |
| 51 | + const prCi = readWorkflow("pr-ci.yml"); |
| 52 | + const ciWindowsJob = extractJobBlock(ci, "scripts-windows"); |
| 53 | + const prWindowsJob = extractJobBlock(prCi, "scripts-windows"); |
| 54 | + |
| 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"); |
| 59 | + }); |
| 60 | +}); |
0 commit comments