Skip to content

Commit 314ce08

Browse files
authored
test: rebalance test suite (#5972)
* test: glob no longer in use by test suite * test: remove manual balancing of tests * chore: remove tools package * test: match workflow parallelism count to matrix machine count * chore: npm audit fix * chore: update documentation around test balancing
1 parent ef21c2b commit 314ce08

10 files changed

+211
-432
lines changed

.github/workflows/workflow.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ jobs:
198198
env:
199199
# split tests across multiple machines
200200
CI_NODE_INDEX: ${{ matrix.machine }}
201-
CI_NODE_TOTAL: 4
201+
CI_NODE_TOTAL: 5
202202
with:
203203
timeout_minutes: 30
204204
max_attempts: 3

CONTRIBUTING.md

-6
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ See our [testing documentation](packages/build/tests/README.md) to learn about o
5151

5252
After submitting the pull request, please make sure the Continuous Integration checks (GitHub actions) are passing.
5353

54-
### Testing in CI
55-
56-
To speed up CI, we load balance the tests across multiple machines. The information required to load balance the tests
57-
is stored in `tests-metadata.json`, and later used by our test [runner](ava.config.js#L10). To regenerate the data (e.g.
58-
when adding a new test file) run `npm test:measure` and commit the changes to GitHub.
59-
6054
### Testing locally
6155

6256
The `@netlify/testing` package will need to be built regardless of which package you are working on. In order to do this

ava.base.js

-20
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,12 @@
1-
import fs, { existsSync } from 'fs'
2-
import path from 'path'
31
import process from 'process'
42

5-
import { isCI } from 'ci-info'
63
import * as execa from 'execa'
74

85
const { execaCommand } = execa
96
if (process.argv.includes('-w')) {
107
execaCommand('tsc -w', { cleanup: true })
118
}
129

13-
// `tests-metadata.json` is created by running `npx lerna run test:measure --scope @netlify/build`
14-
const testData = existsSync('tests-metadata.json') ? JSON.parse(fs.readFileSync('tests-metadata.json', 'utf-8')) : {}
15-
16-
const getOrder = (file) => {
17-
const fileRelative = path.relative(process.cwd(), file).replace(/\\/g, '/')
18-
if (testData[fileRelative]) {
19-
return testData[fileRelative].order
20-
}
21-
22-
console.warn(`Missing test metadata for ${fileRelative}`)
23-
return Number.MAX_SAFE_INTEGER
24-
}
25-
26-
const sortTestFiles = (file1, file2) => getOrder(file1) - getOrder(file2)
27-
2810
const config = {
2911
files: ['packages/**/tests/*.{cjs,mjs,js}', 'packages/**/tests/**/tests.{cjs,mjs,js}'],
3012
verbose: true,
@@ -34,8 +16,6 @@ const config = {
3416
environmentVariables: {
3517
FORCE_COLOR: '1',
3618
},
37-
// we only sort in CI to split efficiently across machines
38-
...(isCI && { sortTestFiles }),
3919
}
4020

4121
export default config

0 commit comments

Comments
 (0)