Skip to content

Commit f58a355

Browse files
Merge pull request #1449 from ember-cli/nvp/nvp/split-acceptance-tests-for-easier-retries
Spit node-tests in to parallel jobs for easier retries (we have a very short testem timeout)
2 parents ed38a49 + f2ca396 commit f58a355

File tree

2 files changed

+71
-3
lines changed

2 files changed

+71
-3
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI Build
1+
name: CI
22

33
on:
44
push:
@@ -11,6 +11,23 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14+
setup:
15+
name: 'Setup'
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 2
18+
outputs:
19+
matrix: ${{ steps.set-matrix.outputs.matrix }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-node@v4
23+
with:
24+
# This version is different, because we want newer node features
25+
# so that we can skip pnpm install for this job
26+
node-version: 24
27+
- id: set-matrix
28+
run: |
29+
echo "matrix=$(node ./node-tests/list.mjs)" >> $GITHUB_OUTPUT
30+
1431
lint:
1532
name: Lints
1633
runs-on: ubuntu-latest
@@ -49,9 +66,13 @@ jobs:
4966
working-directory: ${{ matrix.app.dir }}
5067

5168
test-node:
52-
name: Node Tests
69+
name: "Mocha | ${{ matrix.name }}"
70+
needs: ["setup"]
5371
runs-on: ubuntu-latest
5472
timeout-minutes: 30
73+
strategy:
74+
fail-fast: false
75+
matrix: ${{fromJson(needs.setup.outputs.matrix)}}
5576

5677
steps:
5778
- uses: actions/checkout@v4
@@ -61,7 +82,7 @@ jobs:
6182
node-version: 18
6283
cache: 'pnpm'
6384
- run: pnpm install
64-
- run: pnpm test:node
85+
- run: ${{ matrix.command }}
6586

6687
floating-dependencies:
6788
name: "Floating Dependencies"

node-tests/list.mjs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* This file is used by CI to list all the test files we have to generate a matrix to run.
3+
* Since our node-tests dirty the working directory, we don't want to have different test files stepping on each other.
4+
*
5+
* Additionally, this allows us to run each test file in parallel with the other test files.
6+
*
7+
* The code here was copied from https://github.com/embroider-build/try/blob/main/cli.js
8+
* (ish)
9+
*/
10+
import assert from "node:assert";
11+
// We run this file on node 24
12+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
13+
import { glob } from "node:fs/promises";
14+
15+
let files = [
16+
{
17+
name: "Unit",
18+
command: "pnpm mocha 'node-tests/unit/**/*-test.js'",
19+
},
20+
];
21+
22+
for await (const entry of glob(
23+
"node-tests/acceptance/**/*-test.{js,ts,mjs,cjs,mts,cts}",
24+
)) {
25+
let name = entry.replace("node-tests/acceptance/", "");
26+
files.push({
27+
name,
28+
include: {
29+
name,
30+
command: `pnpm mocha ${entry}`,
31+
},
32+
});
33+
}
34+
35+
assert(
36+
files.length > 0,
37+
`There were no found test files -- this is unexpected`,
38+
);
39+
40+
process.stdout.write(
41+
JSON.stringify({
42+
name: files.map((s) => s.name),
43+
// always include an empty env by default, so that it's convenient to pass
44+
// `${{ matrix.env }}` in github actions
45+
include: files.map((s) => ({ env: {}, ...s.include })),
46+
}),
47+
);

0 commit comments

Comments
 (0)