Skip to content

Commit 53aa88e

Browse files
authored
chore: enable test parallelism (#32766)
1 parent b7deabc commit 53aa88e

File tree

8 files changed

+82
-19
lines changed

8 files changed

+82
-19
lines changed

.circleci/config.yml

+29-18
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ aliases:
6363
- /blog.+/
6464

6565
test_template: &test_template
66+
parallelism: 4
6667
parameters:
6768
npm_rebuild:
6869
type: boolean
@@ -75,11 +76,16 @@ aliases:
7576
condition: << parameters.npm_rebuild >>
7677
steps:
7778
- run: npm rebuild
78-
- run: yarn list react
79-
- run: yarn why lmdb-store
8079
- run:
81-
command: node --max-old-space-size=2048 ./node_modules/.bin/jest -w 1 --ci
80+
name: Step debug info
81+
command: |
82+
yarn list react
83+
yarn why lmdb-store
84+
- run:
85+
name: Run tests
86+
command: yarn jest --ci --runInBand $(yarn jest --listTests | sed 's/\/root\/project//g' | circleci tests split --split-by=timings)
8287
environment:
88+
NODE_OPTIONS: --max-old-space-size=2048
8389
GENERATE_JEST_REPORT: true
8490
JEST_JUNIT_OUTPUT_DIR: ./test-results/jest-node/
8591
JEST_JUNIT_OUTPUT_NAME: results.xml
@@ -193,7 +199,8 @@ jobs:
193199
- persist_to_workspace:
194200
root: ./
195201
paths:
196-
- "*"
202+
- "packages/"
203+
- "node_modules/"
197204

198205
lint:
199206
executor: node
@@ -506,6 +513,7 @@ jobs:
506513
working_directory: ~/project/scripts/i18n
507514

508515
windows_unit_tests:
516+
parallelism: 4
509517
executor:
510518
name: win/default
511519
shell: powershell.exe
@@ -519,28 +527,30 @@ jobs:
519527
# keys:
520528
# - yarn-packages-v2-{{ checksum "yarn.lock" }}
521529
# - yarn-packages-v2-
530+
531+
- <<: *attach_to_bootstrap
522532
- run:
523-
name: Install node 12.13
533+
name: Install node 12.13 and yarn
524534
command: |
525535
nvm install 12.13.0
526536
nvm alias default 12.13.0
527537
nvm use 12.13.0
528538
choco install yarn
529539
- run:
530-
name: Set yarn timeout
531-
command: yarn config set network-timeout 300000
532-
- run:
533-
name: Install node modules
534-
command: yarn --frozen-lockfile
535-
# Caching is slow, so disabling
536-
# - save_cache:
537-
# paths:
538-
# - C:\Users\circleci\AppData\Local\Yarn\Cache
539-
# key: yarn-packages-v2-{{ checksum "yarn.lock" }}
540-
- run: yarn npm-run-all -s check-versions "lerna-prepare --concurrency=4 --stream"
540+
name: Rebuild packages for windows
541+
command: |
542+
Remove-Item -Recurse -Force -Path "node_modules/sharp/"
543+
yarn
541544
- run:
542-
name: "Run Tests"
543-
command: yarn jest -w 1 --ci
545+
name: Run tests
546+
command: yarn jest --ci --runInBand ((yarn jest --listTests) | Foreach-Object {$_ -replace '.*\\packages', 'packages'} | Foreach-Object {$_ -replace '\\', '/'} | circleci tests split --split-by=timings)
547+
environment:
548+
NODE_OPTIONS: --max-old-space-size=2048
549+
GENERATE_JEST_REPORT: true
550+
JEST_JUNIT_OUTPUT_DIR: ./test-results/jest-node/
551+
JEST_JUNIT_OUTPUT_NAME: results.xml
552+
- store_test_results:
553+
path: ./test-results/jest-node/
544554

545555
bootstrap-with-experimental-react:
546556
executor: node
@@ -627,6 +637,7 @@ workflows:
627637
<<: *ignore_docs
628638
requires:
629639
- lint
640+
- bootstrap
630641
- unit_tests_node12:
631642
<<: *ignore_docs
632643
requires:

e2e-tests/production-runtime/cypress/integration/resource-loading-resilience.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const waitForAPIOptions = {
2-
timeout: 10000,
2+
timeout: 5000,
33
}
44

55
function runTests(testNameSuffix) {

packages/gatsby/src/utils/worker/__tests__/config.ts

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ import * as path from "path"
44

55
let worker: GatsbyTestWorkerPool | undefined
66

7+
jest.mock(`gatsby-telemetry`, () => {
8+
return {
9+
decorateEvent: jest.fn(),
10+
trackCli: jest.fn(),
11+
}
12+
})
13+
714
beforeEach(() => {
815
store.dispatch({ type: `DELETE_CACHE` })
916
})

packages/gatsby/src/utils/worker/__tests__/datastore.ts

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ import { store } from "../../../redux"
77
import { actions } from "../../../redux/actions"
88
import { getDataStore } from "../../../datastore"
99

10+
jest.mock(`gatsby-telemetry`, () => {
11+
return {
12+
decorateEvent: jest.fn(),
13+
trackError: jest.fn(),
14+
trackCli: jest.fn(),
15+
}
16+
})
17+
18+
jest.mock(`gatsby-cli/lib/reporter`, () => {
19+
return {}
20+
})
21+
1022
let worker: GatsbyTestWorkerPool | undefined
1123

1224
beforeEach(() => {

packages/gatsby/src/utils/worker/__tests__/jobs.ts

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ import { waitUntilAllJobsComplete } from "../../jobs/manager"
66
import type { MessagesFromChild, MessagesFromParent } from "../messaging"
77
import { getReduxJobs, getJobsMeta } from "./test-helpers/child-for-tests"
88

9+
jest.mock(`gatsby-telemetry`, () => {
10+
return {
11+
decorateEvent: jest.fn(),
12+
trackCli: jest.fn(),
13+
}
14+
})
15+
16+
// jest.mock(`gatsby-cli/lib/reporter`, () => jest.fn())
17+
918
let worker: GatsbyTestWorkerPool | undefined
1019

1120
describe(`worker (jobs)`, () => {

packages/gatsby/src/utils/worker/__tests__/queries.ts

+8
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ jest.mock(`chokidar`, () => {
4444
return chokidar
4545
})
4646

47+
jest.mock(`gatsby-telemetry`, () => {
48+
return {
49+
decorateEvent: jest.fn(),
50+
trackError: jest.fn(),
51+
trackCli: jest.fn(),
52+
}
53+
})
54+
4755
const dummyKeys = `a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z`.split(
4856
`,`
4957
)

packages/gatsby/src/utils/worker/__tests__/schema.ts

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ jest.mock(`chokidar`, () => {
3737
return chokidar
3838
})
3939

40+
jest.mock(`gatsby-telemetry`, () => {
41+
return {
42+
decorateEvent: jest.fn(),
43+
trackError: jest.fn(),
44+
trackCli: jest.fn(),
45+
}
46+
})
47+
4048
describeWhenLMDB(`worker (schema)`, () => {
4149
let stateFromWorker: CombinedState<IGatsbyState>
4250

packages/gatsby/src/utils/worker/__tests__/share-state.ts

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ import {
77
} from "../../../redux"
88
import { GatsbyStateKeys } from "../../../redux/types"
99

10+
jest.mock(`gatsby-telemetry`, () => {
11+
return {
12+
decorateEvent: jest.fn(),
13+
trackError: jest.fn(),
14+
trackCli: jest.fn(),
15+
}
16+
})
17+
1018
let worker: GatsbyTestWorkerPool | undefined
1119

1220
const dummyPagePayload = {

0 commit comments

Comments
 (0)