Skip to content

Commit b997c83

Browse files
authored
feat: parallelize jest tests with sharding (#1550)
1 parent eb3e4af commit b997c83

File tree

3 files changed

+90
-38
lines changed

3 files changed

+90
-38
lines changed

.github/workflows/build-rad-ui.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- 'src/**' # Only run when files in this directory change
8+
- 'styles/**'
9+
- 'package.json'
10+
- 'package-lock.json'
11+
- 'scripts/**'
12+
- 'rollup.config.cjs'
13+
- 'rollup-css.config.cjs'
14+
- 'rollup-tokens.config.cjs'
15+
- 'tsconfig.json'
16+
- 'postcss.config.js'
17+
- 'tsconfig.json'
18+
pull_request:
19+
branches: [ main, security-fixes ]
20+
paths:
21+
- 'src/**' # Only run when files in this directory change
22+
- 'styles/**'
23+
- 'package.json'
24+
- 'package-lock.json'
25+
- 'scripts/**'
26+
- 'rollup.config.cjs'
27+
- 'rollup-css.config.cjs'
28+
- 'rollup-tokens.config.cjs'
29+
- 'tsconfig.json'
30+
- 'postcss.config.js'
31+
- 'tsconfig.json'
32+
33+
permissions:
34+
contents: read
35+
pull-requests: read
36+
37+
concurrency:
38+
group: ${{ github.workflow }}-${{ github.ref }}
39+
cancel-in-progress: true
40+
41+
jobs:
42+
test:
43+
name: Jest ${{ matrix.shard }}/${{ matrix.total }}
44+
runs-on: ubuntu-latest
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
shard: [1, 2]
49+
total: [2]
50+
steps:
51+
- uses: actions/checkout@v4
52+
53+
- name: Setup Node.js
54+
uses: actions/setup-node@v4
55+
with:
56+
node-version: '20'
57+
cache: 'npm'
58+
59+
- name: Install dependencies
60+
run: npm ci
61+
62+
- name: Run tests
63+
env:
64+
JEST_SHARD: ${{ matrix.shard }}/${{ matrix.total }}
65+
run: npm run test:shard
66+
build:
67+
name: Build
68+
runs-on: ubuntu-latest
69+
needs: test
70+
steps:
71+
- uses: actions/checkout@v4
72+
73+
- name: Setup Node.js
74+
uses: actions/setup-node@v4
75+
with:
76+
node-version: '20'
77+
cache: 'npm'
78+
79+
- name: Install dependencies
80+
run: npm ci
81+
82+
- name: Build package
83+
run: npm run build:rollup

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
"description": "",
55
"main": "dist",
66
"type": "module",
7-
"exports": {},
7+
"exports": {
8+
"./themes/default.css": "./dist/themes/default.css",
9+
"./themes/tailwind-presets/default.js": "./dist/themes/tailwind-presets/default.js"
10+
},
811
"scripts": {
912
"test": "jest",
1013
"test:e2e": "playwright test",
1114
"coverage": "jest --coverage",
15+
"test:shard": "jest --shard=$JEST_SHARD",
1216
"test:watch": "jest --watch",
1317
"clean": "rimraf dist",
1418
"chromatic": "chromatic --exit-zero-on-changes",
@@ -26,7 +30,7 @@
2630
"build:css": "npm run generate-tokens && npm run bundle-tokens && npm run build-css",
2731
"build:components": "npm run compile-components && npm run process-components",
2832
"build:rollup": "NODE_OPTIONS='--max-old-space-size=8192' npm run build:rollup:process",
29-
"build:rollup:process": "npm run prebuild && (npm run build:css & npm run build:components & wait) && npm run build:generate-exports",
33+
"build:rollup:process": "npm run clean && (npm run build:css & npm run build:components & wait) && npm run build:generate-exports",
3034
"compile-components:esbuild": "node build-components.cjs",
3135
"check:types": "tsc --noEmit",
3236
"build-components:esbuild": "npm run compile-components:esbuild && npm run process-components",
@@ -129,4 +133,4 @@
129133
"react": "^18.2.0",
130134
"react-dom": "^18.2.0"
131135
}
132-
}
136+
}

0 commit comments

Comments
 (0)