Skip to content

Commit 4d25eec

Browse files
committed
Build optimization
1 parent b3f79be commit 4d25eec

5 files changed

Lines changed: 87 additions & 28 deletions

File tree

.github/workflows/ci.yml

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,24 @@ jobs:
117117
with:
118118
node-version-file: ".nvmrc"
119119

120+
- uses: Swatinem/rust-cache@v2
121+
with:
122+
key: e2e-debug
123+
120124
- name: Install dependencies
121125
run: npm ci
122126

123-
- name: Build
124-
run: make build
127+
# Debug server (serves the client bundle from disk) — far faster to compile
128+
# than the release build. The embedded-bundle path is covered by the
129+
# separate test-e2e-release job below.
130+
- name: Build (debug server + client bundle)
131+
run: make build-e2e
125132

126-
- name: Install Playwright browsers
127-
run: npx playwright install --with-deps
133+
- name: Install Playwright browser (chromium)
134+
run: npx playwright install --with-deps chromium
128135

129136
- name: Run e2e tests
130-
run: npx playwright test
137+
run: npx playwright test --project=chromium
131138

132139
- name: Upload test results
133140
if: ${{ !cancelled() }}
@@ -137,14 +144,58 @@ jobs:
137144
path: test-results/
138145
retention-days: 7
139146

147+
# Validates the shipped release binary's rust-embed embedded bundle. Kept
148+
# separate from test-e2e so the fast gate isn't blocked on a release compile;
149+
# runs in parallel and gates release/docker.
150+
test-e2e-release:
151+
runs-on: ubuntu-latest
152+
steps:
153+
- name: Setup repo
154+
uses: actions/checkout@v4
155+
with:
156+
fetch-depth: 0
157+
fetch-tags: true
158+
159+
- name: Setup Node.js
160+
uses: actions/setup-node@v4
161+
with:
162+
node-version-file: ".nvmrc"
163+
164+
- uses: Swatinem/rust-cache@v2
165+
with:
166+
key: e2e-release
167+
168+
- name: Install dependencies
169+
run: npm ci
170+
171+
- name: Build (release server with embedded bundle)
172+
run: make build-rs
173+
174+
- name: Install Playwright browser (chromium)
175+
run: npx playwright install --with-deps chromium
176+
177+
- name: Run embedded-bundle e2e tests
178+
run: npx playwright test --project=release
179+
180+
- name: Upload test results
181+
if: ${{ !cancelled() }}
182+
uses: actions/upload-artifact@v4
183+
with:
184+
name: playwright-report-release
185+
path: test-results/
186+
retention-days: 7
187+
188+
# Compilation doesn't depend on the test suites, so the build runs in parallel
189+
# with them instead of after — the test gate is enforced on the *publishing*
190+
# jobs (release/docker) below, which keeps "nothing ships if tests fail".
140191
build:
141-
needs: [config, test-frontend, test-e2e]
192+
needs: [config]
142193
if: needs.config.outputs.publish == 'true'
143194
uses: ./.github/workflows/_build.yml
144195
secrets: inherit
145196

146197
release:
147-
needs: [config, build]
198+
needs: [config, build, test-frontend, test-e2e, test-e2e-release]
148199
if: needs.config.outputs.publish == 'true'
149200
runs-on: ubuntu-latest
150201
permissions:
@@ -220,7 +271,7 @@ jobs:
220271
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
221272

222273
docker:
223-
needs: [config, build]
274+
needs: [config, build, test-frontend, test-e2e, test-e2e-release]
224275
if: needs.config.outputs.publish == 'true'
225276
runs-on: ubuntu-latest
226277
permissions:

Makefile

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
.PHONY: build build-for-docker build-linux-ci docker build-server-releases build-server-releases-macos build-cli-releases-rust build-cli-releases-freebsd build-cli-releases-rust-macos clean check fmt test test-e2e test-e2e-release bench generate website install uninstall bundle build-rs build-rs-cli run-rs
1+
.PHONY: build build-e2e build-for-docker build-linux-ci docker build-server-releases build-server-releases-macos build-cli-releases-rust build-cli-releases-freebsd build-cli-releases-rust-macos clean check fmt test test-e2e test-e2e-release bench generate website install uninstall bundle build-rs build-rs-cli run-rs
22

33
build:
44
npm run build
55
npm run build:plug-compile
66
cargo build --release -p silverbullet
77
cargo build --release -p sb
88

9+
# Fast build for the e2e suite: a debug server (rust-embed reads the client
10+
# bundle from disk in debug, so no embed step) plus the frontend bundle. Skips
11+
# the release compile, plug-compile, and the `sb` CLI — none are exercised by
12+
# the debug e2e suite. The embedded-bundle path is covered by `test-e2e-release`.
13+
build-e2e:
14+
npm run build
15+
cargo build -p silverbullet
16+
917
setup:
1018
npm install
1119
npx playwright install
@@ -138,16 +146,15 @@ test:
138146
npx vitest run
139147
cargo test --workspace --all-features
140148

141-
test-e2e: build-rs
142-
npx playwright test
149+
test-e2e: build-e2e
150+
npx playwright test --project=chromium
143151

144152
# Browser E2E tests against the standalone release binary, validating the
145-
# rust-embed embedded client bundle and the browser login flow. Requires a
146-
# release build first: run `make build-rs` to produce
147-
# `target/release/silverbullet`. Kept out of the default `test-e2e` so the
148-
# fast suite isn't blocked on a release build.
149-
test-e2e-release:
150-
npx playwright test e2e/release-embedded.test.ts
153+
# rust-embed embedded client bundle and the browser login flow. Builds the
154+
# release binary first (`target/release/silverbullet`). Kept out of the default
155+
# `test-e2e` so the fast suite isn't blocked on a release build.
156+
test-e2e-release: build-rs
157+
npx playwright test --project=release
151158

152159
bench:
153160
npm run bench

e2e/fixtures.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ export const test = base.extend<SBFixtures>({
6565
const port = await getFreePort();
6666

6767
const proc: ChildProcess = spawn(
68-
// The e2e suite runs against the Rust server (the release binary, with
69-
// the client bundle embedded — built by `make build-rs`).
70-
"./target/release/silverbullet",
68+
"./target/debug/silverbullet",
7169
[spaceDir, "-p", String(port), "-L", "127.0.0.1"],
7270
{
7371
cwd: join(import.meta.dirname, ".."),

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
"fmt:check": "biome format .",
6464
"bench": "vitest bench",
6565
"index-stats": "tsx plugs/index/index_stats.ts",
66-
"test:e2e": "npx playwright test",
67-
"test:e2e:headed": "npx playwright test --headed"
66+
"test:e2e": "npx playwright test --project=chromium",
67+
"test:e2e:headed": "npx playwright test --project=chromium --headed"
6868
},
6969
"peerDependencies": {
7070
"preact": "^10.25.0"

playwright.config.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ export default defineConfig({
1919
projects: [
2020
{
2121
name: "chromium",
22+
// The embedded-bundle test needs the release binary; it runs as its
23+
// own `release` project (see `make test-e2e-release`).
24+
testIgnore: "**/release-embedded.test.ts",
2225
use: {
2326
...devices["Desktop Chrome"],
2427
// CI runners have a small /dev/shm, which crashes the chromium
@@ -27,12 +30,12 @@ export default defineConfig({
2730
},
2831
},
2932
{
30-
name: "firefox",
31-
use: { ...devices["Desktop Firefox"] },
32-
},
33-
{
34-
name: "webkit",
35-
use: { ...devices["Desktop Safari"] },
33+
name: "release",
34+
testMatch: "**/release-embedded.test.ts",
35+
use: {
36+
...devices["Desktop Chrome"],
37+
launchOptions: { args: ["--disable-dev-shm-usage"] },
38+
},
3639
},
3740
],
3841
});

0 commit comments

Comments
 (0)