Skip to content

Commit 0f18cba

Browse files
authoredMar 4, 2025··
build(ci): parallelize builds across browsers & caching (#1472)
1 parent 71cead4 commit 0f18cba

File tree

4 files changed

+71
-18
lines changed

4 files changed

+71
-18
lines changed
 

‎.github/workflows/build.yml

+42-15
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,29 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 100
17+
18+
- uses: nrwl/nx-set-shas@v3
1519

1620
- uses: actions/setup-node@v4
1721
with:
1822
node-version: "20.x"
23+
cache: "npm"
24+
cache-dependency-path: "**/package-lock.json"
1925

20-
- name: Cache node modules
26+
- name: Cache NX
2127
uses: actions/cache@v4
22-
env:
23-
cache-name: cache-node-modules
2428
with:
25-
# npm cache files are stored in `~/.npm` on Linux/macOS
26-
path: ~/.npm
27-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
29+
path: node_modules/.cache/nx/
30+
key: nx-${{ env.NX_BRANCH }}-${{ env.NX_RUN_GROUP }}-${{ github.sha }}
2831
restore-keys: |
29-
${{ runner.os }}-build-${{ env.cache-name }}-
30-
${{ runner.os }}-build-
31-
${{ runner.os }}-
32+
nx-${{ env.NX_BRANCH }}-${{ env.NX_RUN_GROUP }}-
33+
nx-${{ env.NX_BRANCH }}-
34+
nx-
3235
3336
- name: Install Dependencies
34-
run: npm install
37+
run: npm ci --prefer-offline --no-audit
3538

3639
- name: Bootstrap packages
3740
run: npm run bootstrap
@@ -50,19 +53,43 @@ jobs:
5053
with:
5154
webpackStatsFile: ./playground/dist/webpack-stats.json
5255
artifactName: relative-ci-artifacts-editor
56+
5357
playwright:
54-
name: "Playwright Tests"
58+
name: "Playwright Tests - ${{ matrix.browser }}"
5559
runs-on: ubuntu-latest
5660
container:
5761
image: mcr.microsoft.com/playwright:v1.49.1-noble
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
browser: [chromium, firefox, webkit]
5866
steps:
5967
- uses: actions/checkout@v4
68+
with:
69+
fetch-depth: 100
70+
71+
- uses: nrwl/nx-set-shas@v3
72+
6073
- uses: actions/setup-node@v4
6174
with:
62-
node-version: lts/*
75+
node-version: "20.x"
76+
cache: "npm"
77+
cache-dependency-path: "**/package-lock.json"
78+
79+
- name: Cache NX
80+
uses: actions/cache@v4
81+
with:
82+
path: node_modules/.cache/nx/
83+
key: nx-${{ env.NX_BRANCH }}-${{ env.NX_RUN_GROUP }}-${{ github.sha }}
84+
restore-keys: |
85+
nx-${{ env.NX_BRANCH }}-${{ env.NX_RUN_GROUP }}-
86+
nx-${{ env.NX_BRANCH }}-
87+
nx-
88+
6389
- run: apt-get update && apt-get install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
90+
6491
- name: Install dependencies
65-
run: npm ci
92+
run: npm ci --prefer-offline --no-audit
6693

6794
- name: Build packages
6895
run: npm run build
@@ -71,11 +98,11 @@ jobs:
7198
run: |
7299
npm run start:built > /dev/null &
73100
npx wait-on http://localhost:3000
74-
cd tests && HOME=/root npx playwright test
101+
cd tests && HOME=/root npx playwright test --project ${{ matrix.browser }}
75102
76103
- uses: actions/upload-artifact@v4
77104
if: always()
78105
with:
79-
name: playwright-report
106+
name: playwright-report-${{ matrix.browser }}
80107
path: tests/playwright-report/
81108
retention-days: 30

‎lerna.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
3-
"useNx": false,
43
"useWorkspaces": true,
5-
"version": "0.24.2"
4+
"version": "0.24.2",
5+
"useNx": true
66
}

‎nx.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"tasksRunnerOptions": {
3+
"default": {
4+
"runner": "nx/tasks-runners/default",
5+
"options": {
6+
"cacheableOperations": ["build", "test", "lint"]
7+
}
8+
}
9+
},
10+
"targetDefaults": {
11+
"build": {
12+
"cache": true,
13+
"dependsOn": ["^build"],
14+
"outputs": ["{projectRoot}/dist"]
15+
},
16+
"test": {
17+
"cache": true,
18+
"dependsOn": ["^test"]
19+
},
20+
"lint": {
21+
"cache": true,
22+
"dependsOn": ["^lint"]
23+
}
24+
}
25+
}

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"start": "lerna run --stream --scope @blocknote/example-editor dev",
2424
"gen": "lerna run --stream --scope @blocknote/dev-scripts gen",
2525
"start:built": "npx serve playground/dist -c ../serve.json",
26-
"build": "npm run clean && npm run gen && npm run clean && lerna run --stream build --concurrency 1",
26+
"build:clean": "npm run clean && npm run gen && npm run clean && lerna run --stream build",
27+
"build": "lerna run --stream build",
2728
"build:site": "lerna run --stream docs:build --concurrency 1",
2829
"lint": "lerna run --stream lint",
2930
"bootstrap": "lerna bootstrap --ci -- --force && patch-package",

0 commit comments

Comments
 (0)
Please sign in to comment.