Skip to content

Commit c19c1b1

Browse files
authored
Check that all jobs are in all-tests-passed.needs (#432)
1 parent f3121ef commit c19c1b1

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import * as fs from "node:fs";
2+
import * as yaml from "js-yaml";
3+
4+
interface WorkflowJob {
5+
needs?: string[];
6+
[key: string]: unknown;
7+
}
8+
9+
interface Workflow {
10+
jobs: Record<string, WorkflowJob>;
11+
[key: string]: unknown;
12+
}
13+
14+
const workflow = yaml.load(
15+
fs.readFileSync("../workflows/test.yml", "utf8"),
16+
) as Workflow;
17+
const jobs = Object.keys(workflow.jobs);
18+
const allTestsPassed = workflow.jobs["all-tests-passed"];
19+
const needs: string[] = allTestsPassed.needs || [];
20+
21+
const expectedNeeds = jobs.filter((j) => j !== "all-tests-passed");
22+
const missing = expectedNeeds.filter((j) => !needs.includes(j));
23+
24+
if (missing.length > 0) {
25+
console.error(
26+
`Missing jobs in all-tests-passed needs: ${missing.join(", ")}`,
27+
);
28+
console.info(
29+
"Please add the missing jobs to the needs section of all-tests-passed in test.yml.",
30+
);
31+
process.exit(1);
32+
}
33+
console.log(
34+
"All jobs in test.yml are in the needs section of all-tests-passed.",
35+
);

.github/workflows/test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ jobs:
2929
npm install
3030
- run: |
3131
npm run all
32+
- name: Check all jobs are in all-tests-passed.needs
33+
run: |
34+
tsc check-all-tests-passed-needs.ts
35+
node check-all-tests-passed-needs.js
36+
working-directory: .github/scripts
3237
- name: Make sure no changes from linters are detected
3338
run: |
3439
git diff --exit-code || (echo "::error::Please run 'npm run all' to fix the issues" && exit 1)
@@ -548,9 +553,13 @@ jobs:
548553
- test-activate-environment
549554
- test-musl
550555
- test-cache-local
556+
- test-setup-cache
551557
- test-restore-cache
558+
- test-setup-cache-requirements-txt
552559
- test-restore-cache-requirements-txt
560+
- test-setup-cache-dependency-glob
553561
- test-restore-cache-dependency-glob
562+
- test-setup-cache-local
554563
- test-restore-cache-local
555564
- test-tilde-expansion-cache-local-path
556565
- test-tilde-expansion-cache-dependency-glob

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
},
3939
"devDependencies": {
4040
"@biomejs/biome": "1.9.4",
41+
"@types/js-yaml": "^4.0.9",
4142
"@types/node": "^22.15.21",
4243
"@types/semver": "^7.7.0",
4344
"@vercel/ncc": "^0.38.3",

0 commit comments

Comments
 (0)