Skip to content

Commit b3aff77

Browse files
committed
[ci] Improve parallelism of yarn test
Changes the `ci` argument to be an enum instead so the tests use all available workers in GitHub actions. - When `ci === 'github'` also increase maxConcurrency to 10 - Increase timeout of ReactMultiChildText-test.js - Chunk test files ghstack-source-id: 730499d Pull Request resolved: #30033
1 parent c515419 commit b3aff77

File tree

4 files changed

+85
-41
lines changed

4 files changed

+85
-41
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ jobs:
368368
steps:
369369
- checkout
370370
- setup_node_modules
371-
- run: yarn test <<parameters.args>> --ci
371+
- run: yarn test <<parameters.args>> --ci=circleci
372372

373373
yarn_test_build:
374374
docker: *docker

.github/workflows/runtime_test.yml

Lines changed: 65 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,74 @@ on:
88
- 'compiler/**'
99

1010
jobs:
11-
test:
12-
name: yarn test
11+
build_test_params:
12+
name: Build test params
1313
runs-on: ubuntu-latest
14+
outputs:
15+
params: ${{ steps.define-params.outputs.result }}
16+
steps:
17+
- uses: actions/github-script@v7
18+
id: define-params
19+
with:
20+
script: |
21+
return [
22+
"-r=stable --env=development",
23+
"-r=stable --env=production",
24+
"-r=experimental --env=development",
25+
"-r=experimental --env=production",
26+
"-r=www-classic --env=development --variant=false",
27+
"-r=www-classic --env=production --variant=false",
28+
"-r=www-classic --env=development --variant=true",
29+
"-r=www-classic --env=production --variant=true",
30+
"-r=www-modern --env=development --variant=false",
31+
"-r=www-modern --env=production --variant=false",
32+
"-r=www-modern --env=development --variant=true",
33+
"-r=www-modern --env=production --variant=true",
34+
"-r=xplat --env=development --variant=false",
35+
"-r=xplat --env=development --variant=true",
36+
"-r=xplat --env=production --variant=false",
37+
"-r=xplat --env=production --variant=true",
38+
// TODO: Test more persistent configurations?
39+
"-r=stable --env=development --persistent",
40+
"-r=experimental --env=development --persistent"
41+
];
42+
43+
chunk_tests:
44+
name: Chunk tests
45+
runs-on: ubuntu-latest
46+
needs: build_test_params
47+
strategy:
48+
matrix:
49+
params: ${{ fromJSON(needs.build_test_params.outputs.params) }}
1450
continue-on-error: true
51+
outputs:
52+
test_names: ${{ steps.chunk-test-files.outputs }}
53+
steps:
54+
- uses: actions/checkout@v4
55+
- uses: actions/setup-node@v4
56+
with:
57+
node-version: 18.x
58+
cache: "yarn"
59+
cache-dependency-path: yarn.lock
60+
- name: Restore cached node_modules
61+
uses: actions/cache@v4
62+
id: node_modules
63+
with:
64+
path: "**/node_modules"
65+
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
66+
- run: yarn install --frozen-lockfile
67+
- id: chunk-test-files
68+
run: yarn --silent test ${{ matrix.params }} --listTests --json --silent | jq '[_nwise(length / 5 | ceil)]' >> $GITHUB_OUTPUT
69+
70+
test:
71+
name: yarn test ${{ needs.build_test_params.outputs.params }}
72+
runs-on: ubuntu-latest
73+
needs: [build_test_params, chunk_tests]
1574
strategy:
1675
matrix:
17-
# Intentionally passing these as strings instead of creating a
18-
# separate parameter per CLI argument, since it's easier to
19-
# control/see which combinations we want to run.
20-
params: [
21-
"-r=stable --env=development",
22-
"-r=stable --env=production",
23-
"-r=experimental --env=development",
24-
"-r=experimental --env=production",
25-
"-r=www-classic --env=development --variant=false",
26-
"-r=www-classic --env=production --variant=false",
27-
"-r=www-classic --env=development --variant=true",
28-
"-r=www-classic --env=production --variant=true",
29-
"-r=www-modern --env=development --variant=false",
30-
"-r=www-modern --env=production --variant=false",
31-
"-r=www-modern --env=development --variant=true",
32-
"-r=www-modern --env=production --variant=true",
33-
"-r=xplat --env=development --variant=false",
34-
"-r=xplat --env=development --variant=true",
35-
"-r=xplat --env=production --variant=false",
36-
"-r=xplat --env=production --variant=true",
37-
# TODO: Test more persistent configurations?
38-
"-r=stable --env=development --persistent",
39-
"-r=experimental --env=development --persistent"
40-
]
76+
params: ${{ fromJSON(needs.build_test_params.outputs.params) }}
77+
test_names: ${{ fromJSON(needs.chunk_tests.outputs.test_names) }}
78+
continue-on-error: true
4179
steps:
4280
- uses: actions/checkout@v4
4381
- uses: actions/setup-node@v4
@@ -52,4 +90,4 @@ jobs:
5290
path: "**/node_modules"
5391
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
5492
- run: yarn install --frozen-lockfile
55-
- run: yarn test ${{ matrix.params }} --ci
93+
- run: echo $CHUNKS | jq '.[${{ matrix.test_names }}] | .[] | @text' | xargs yarn test ${{ matrix.params }} --ci=github

packages/react-dom/src/__tests__/ReactMultiChildText-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const expectChildren = function (container, children) {
7777
* faster to render and update.
7878
*/
7979
describe('ReactMultiChildText', () => {
80-
jest.setTimeout(20000);
80+
jest.setTimeout(30000);
8181

8282
it('should correctly handle all possible children for render and update', async () => {
8383
await expect(async () => {

scripts/jest/jest-cli.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ const argv = yargs
9191
ci: {
9292
describe: 'Run tests in CI',
9393
requiresArg: false,
94-
type: 'boolean',
95-
default: false,
94+
type: 'choices',
95+
choices: ['circleci', 'github'],
9696
},
9797
compactConsole: {
9898
alias: 'c',
@@ -309,10 +309,14 @@ function getCommandArgs() {
309309
}
310310

311311
// CI Environments have limited workers.
312-
if (argv.ci) {
312+
if (argv.ci === 'circleci') {
313313
args.push('--maxWorkers=2');
314314
}
315315

316+
if (argv.ci === 'github') {
317+
args.push('--maxConcurrency=10 --workerThreads=true');
318+
}
319+
316320
// Push the remaining args onto the command.
317321
// This will send args like `--watch` to Jest.
318322
args.push(...argv._);
@@ -364,16 +368,18 @@ function main() {
364368
const envars = getEnvars();
365369
const env = Object.entries(envars).map(([k, v]) => `${k}=${v}`);
366370

367-
// Print the full command we're actually running.
368-
const command = `$ ${env.join(' ')} node ${args.join(' ')}`;
369-
console.log(chalk.dim(command));
371+
if (argv.ci !== 'github') {
372+
// Print the full command we're actually running.
373+
const command = `$ ${env.join(' ')} node ${args.join(' ')}`;
374+
console.log(chalk.dim(command));
370375

371-
// Print the release channel and project we're running for quick confirmation.
372-
console.log(
373-
chalk.blue(
374-
`\nRunning tests for ${argv.project} (${argv.releaseChannel})...`
375-
)
376-
);
376+
// Print the release channel and project we're running for quick confirmation.
377+
console.log(
378+
chalk.blue(
379+
`\nRunning tests for ${argv.project} (${argv.releaseChannel})...`
380+
)
381+
);
382+
}
377383

378384
// Print a message that the debugger is starting just
379385
// for some extra feedback when running the debugger.

0 commit comments

Comments
 (0)