Skip to content

Commit d8ea470

Browse files
authored
Move tests to their own GitHub Actions workflow (#440)
Tests are their own thing!
1 parent 9bfea51 commit d8ea470

File tree

19 files changed

+209
-163
lines changed

19 files changed

+209
-163
lines changed

.github/workflows/run-tests.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Run tests on PRs
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Check out repository
13+
uses: actions/checkout@v4
14+
15+
- name: Set up everything
16+
uses: ./.github/workflows/set-up-everything
17+
18+
# Yarn constraints are kinda like tests.
19+
- name: Check Yarn constraints
20+
run: yarn constraints
21+
# TODO: Maybe write up a job summary per https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary
22+
23+
- name: Run tests
24+
run: yarn test
25+
# TODO: Annotations of test files that fail?
26+
# TODO: Maybe write up a job summary per https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary

workspaces/adventure-pack/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@
6969
"@code-chronicles/eslint-config": "workspace:*",
7070
"@code-chronicles/util": "workspace:*",
7171
"@jest/globals": "29.7.0",
72-
"@types/node": "22.7.0",
73-
"@types/react": "18.3.9",
72+
"@types/node": "22.7.4",
73+
"@types/react": "18.3.10",
7474
"@types/react-dom": "18.3.0",
7575
"@types/react-syntax-highlighter": "15.5.13",
7676
"cross-env": "7.0.3",
@@ -84,7 +84,7 @@
8484
"tsx": "4.19.1",
8585
"type-fest": "4.26.1",
8686
"typescript": "5.6.2",
87-
"webpack": "5.94.0",
87+
"webpack": "5.95.0",
8888
"webpack-cli": "5.1.4",
8989
"zod": "3.23.8"
9090
}

workspaces/chrome-extension-hello-world/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
},
1818
"devDependencies": {
1919
"@code-chronicles/eslint-config": "workspace:*",
20-
"@types/node": "22.7.0",
20+
"@types/node": "22.7.4",
2121
"cross-env": "7.0.3",
2222
"prettier": "3.3.3",
2323
"ts-loader": "9.5.1",
2424
"tsx": "4.19.1",
2525
"typescript": "5.6.2",
26-
"webpack": "5.94.0",
26+
"webpack": "5.95.0",
2727
"webpack-cli": "5.1.4"
2828
}
2929
}

workspaces/download-leetcode-submissions/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
},
3030
"devDependencies": {
3131
"@code-chronicles/eslint-config": "workspace:*",
32-
"@types/node": "22.7.0",
32+
"@types/node": "22.7.4",
3333
"cross-env": "7.0.3",
3434
"eslint": "9.11.1",
3535
"prettier": "3.3.3",
3636
"ts-loader": "9.5.1",
3737
"tsx": "4.19.1",
3838
"typescript": "5.6.2",
39-
"webpack": "5.94.0",
39+
"webpack": "5.95.0",
4040
"webpack-cli": "5.1.4"
4141
}
4242
}

workspaces/fetch-leetcode-problem-list/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
},
2828
"devDependencies": {
2929
"@code-chronicles/eslint-config": "workspace:*",
30-
"@types/node": "22.7.0",
30+
"@types/node": "22.7.4",
3131
"cross-env": "7.0.3",
3232
"eslint": "9.11.1",
3333
"prettier": "3.3.3",
3434
"ts-loader": "9.5.1",
3535
"tsx": "4.19.1",
3636
"typescript": "5.6.2",
37-
"webpack": "5.94.0",
37+
"webpack": "5.95.0",
3838
"webpack-cli": "5.1.4"
3939
}
4040
}

workspaces/fetch-recent-accepted-leetcode-submissions/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
},
2828
"devDependencies": {
2929
"@code-chronicles/eslint-config": "workspace:*",
30-
"@types/node": "22.7.0",
30+
"@types/node": "22.7.4",
3131
"cross-env": "7.0.3",
3232
"eslint": "9.11.1",
3333
"prettier": "3.3.3",
3434
"ts-loader": "9.5.1",
3535
"tsx": "4.19.1",
3636
"typescript": "5.6.2",
37-
"webpack": "5.94.0",
37+
"webpack": "5.95.0",
3838
"webpack-cli": "5.1.4"
3939
}
4040
}

workspaces/generate-health-report/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"devDependencies": {
2828
"@code-chronicles/eslint-config": "workspace:*",
29-
"@types/node": "22.7.0",
29+
"@types/node": "22.7.4",
3030
"eslint": "9.11.1",
3131
"prettier": "3.3.3",
3232
"typescript": "5.6.2"

workspaces/generate-health-report/src/main.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ import { maybeThrow } from "@code-chronicles/util/maybeThrow";
1010
import { spawnWithSafeStdio } from "@code-chronicles/util/spawnWithSafeStdio";
1111

1212
const COMMANDS = [
13-
"yarn constraints",
14-
"yarn test",
1513
"yarn workspace @code-chronicles/adventure-pack build-app",
1614
"yarn workspace @code-chronicles/adventure-pack build-chrome-extension",
1715
"yarn workspace @code-chronicles/chrome-extension-hello-world build",
1816
"yarn workspace @code-chronicles/fetch-leetcode-problem-list build",
1917
"yarn workspace @code-chronicles/fetch-recent-accepted-leetcode-submissions build",
20-
"yarn workspace @code-chronicles/leetcode-api validate-graphql-schema",
2118
"yarn workspace @code-chronicles/leetcode-zen-mode build",
2219
"yarn workspace @code-chronicles/post-leetcode-potd-to-discord build",
2320
];

workspaces/javascript-leetcode-month/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@code-chronicles/eslint-config": "workspace:*",
2424
"@code-chronicles/util": "workspace:*",
2525
"@types/mdast": "4.0.4",
26-
"@types/node": "22.7.0",
26+
"@types/node": "22.7.4",
2727
"eslint": "9.11.1",
2828
"mdast": "3.0.0",
2929
"prettier": "3.3.3",
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import type { Config } from "jest";
2+
3+
const config: Config = {
4+
preset: "ts-jest",
5+
testEnvironment: "node",
6+
};
7+
8+
export default config;
9+
10+
// Hack to make this config runnable as a script, since the combination of
11+
// Jest, ESM, and a TypeScript config has been painful to get working otherwise.
12+
import("node:process").then(async ({ default: process }) => {
13+
if (import.meta.filename !== process.argv[1]) {
14+
return;
15+
}
16+
17+
try {
18+
const { spawnWithSafeStdio } = await import(
19+
"@code-chronicles/util/spawnWithSafeStdio"
20+
);
21+
await spawnWithSafeStdio(
22+
"jest",
23+
["--color", "-c", JSON.stringify(config), ...process.argv.slice(2)],
24+
{
25+
stdio: "inherit",
26+
env: {
27+
...process.env,
28+
NODE_OPTIONS: [
29+
"--experimental-vm-modules",
30+
process.env.NODE_OPTIONS?.trim(),
31+
]
32+
.filter(Boolean)
33+
.join(" "),
34+
},
35+
},
36+
);
37+
} catch (err) {
38+
console.error(
39+
(err as Record<string, unknown> | null | undefined)?.message ?? err,
40+
);
41+
// eslint-disable-next-line require-atomic-updates -- Updating `process.exitCode` on error is logical.
42+
process.exitCode = 1;
43+
}
44+
});

0 commit comments

Comments
 (0)