Build optimization

This commit is contained in:
Zef Hemel
2026-06-19 16:10:14 +02:00
parent b3f79be692
commit 4d25eec15f
5 changed files with 87 additions and 28 deletions
+59 -8
View File
@@ -117,17 +117,24 @@ jobs:
with:
node-version-file: ".nvmrc"
- uses: Swatinem/rust-cache@v2
with:
key: e2e-debug
- name: Install dependencies
run: npm ci
- name: Build
run: make build
# Debug server (serves the client bundle from disk) — far faster to compile
# than the release build. The embedded-bundle path is covered by the
# separate test-e2e-release job below.
- name: Build (debug server + client bundle)
run: make build-e2e
- name: Install Playwright browsers
run: npx playwright install --with-deps
- name: Install Playwright browser (chromium)
run: npx playwright install --with-deps chromium
- name: Run e2e tests
run: npx playwright test
run: npx playwright test --project=chromium
- name: Upload test results
if: ${{ !cancelled() }}
@@ -137,14 +144,58 @@ jobs:
path: test-results/
retention-days: 7
# Validates the shipped release binary's rust-embed embedded bundle. Kept
# separate from test-e2e so the fast gate isn't blocked on a release compile;
# runs in parallel and gates release/docker.
test-e2e-release:
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- uses: Swatinem/rust-cache@v2
with:
key: e2e-release
- name: Install dependencies
run: npm ci
- name: Build (release server with embedded bundle)
run: make build-rs
- name: Install Playwright browser (chromium)
run: npx playwright install --with-deps chromium
- name: Run embedded-bundle e2e tests
run: npx playwright test --project=release
- name: Upload test results
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: playwright-report-release
path: test-results/
retention-days: 7
# Compilation doesn't depend on the test suites, so the build runs in parallel
# with them instead of after — the test gate is enforced on the *publishing*
# jobs (release/docker) below, which keeps "nothing ships if tests fail".
build:
needs: [config, test-frontend, test-e2e]
needs: [config]
if: needs.config.outputs.publish == 'true'
uses: ./.github/workflows/_build.yml
secrets: inherit
release:
needs: [config, build]
needs: [config, build, test-frontend, test-e2e, test-e2e-release]
if: needs.config.outputs.publish == 'true'
runs-on: ubuntu-latest
permissions:
@@ -220,7 +271,7 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
docker:
needs: [config, build]
needs: [config, build, test-frontend, test-e2e, test-e2e-release]
if: needs.config.outputs.publish == 'true'
runs-on: ubuntu-latest
permissions:
+16 -9
View File
@@ -1,4 +1,4 @@
.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
.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
build:
npm run build
@@ -6,6 +6,14 @@ build:
cargo build --release -p silverbullet
cargo build --release -p sb
# Fast build for the e2e suite: a debug server (rust-embed reads the client
# bundle from disk in debug, so no embed step) plus the frontend bundle. Skips
# the release compile, plug-compile, and the `sb` CLI — none are exercised by
# the debug e2e suite. The embedded-bundle path is covered by `test-e2e-release`.
build-e2e:
npm run build
cargo build -p silverbullet
setup:
npm install
npx playwright install
@@ -138,16 +146,15 @@ test:
npx vitest run
cargo test --workspace --all-features
test-e2e: build-rs
npx playwright test
test-e2e: build-e2e
npx playwright test --project=chromium
# Browser E2E tests against the standalone release binary, validating the
# rust-embed embedded client bundle and the browser login flow. Requires a
# release build first: run `make build-rs` to produce
# `target/release/silverbullet`. Kept out of the default `test-e2e` so the
# fast suite isn't blocked on a release build.
test-e2e-release:
npx playwright test e2e/release-embedded.test.ts
# rust-embed embedded client bundle and the browser login flow. Builds the
# release binary first (`target/release/silverbullet`). Kept out of the default
# `test-e2e` so the fast suite isn't blocked on a release build.
test-e2e-release: build-rs
npx playwright test --project=release
bench:
npm run bench
+1 -3
View File
@@ -65,9 +65,7 @@ export const test = base.extend<SBFixtures>({
const port = await getFreePort();
const proc: ChildProcess = spawn(
// The e2e suite runs against the Rust server (the release binary, with
// the client bundle embedded — built by `make build-rs`).
"./target/release/silverbullet",
"./target/debug/silverbullet",
[spaceDir, "-p", String(port), "-L", "127.0.0.1"],
{
cwd: join(import.meta.dirname, ".."),
+2 -2
View File
@@ -63,8 +63,8 @@
"fmt:check": "biome format .",
"bench": "vitest bench",
"index-stats": "tsx plugs/index/index_stats.ts",
"test:e2e": "npx playwright test",
"test:e2e:headed": "npx playwright test --headed"
"test:e2e": "npx playwright test --project=chromium",
"test:e2e:headed": "npx playwright test --project=chromium --headed"
},
"peerDependencies": {
"preact": "^10.25.0"
+9 -6
View File
@@ -19,6 +19,9 @@ export default defineConfig({
projects: [
{
name: "chromium",
// The embedded-bundle test needs the release binary; it runs as its
// own `release` project (see `make test-e2e-release`).
testIgnore: "**/release-embedded.test.ts",
use: {
...devices["Desktop Chrome"],
// CI runners have a small /dev/shm, which crashes the chromium
@@ -27,12 +30,12 @@ export default defineConfig({
},
},
{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},
{
name: "webkit",
use: { ...devices["Desktop Safari"] },
name: "release",
testMatch: "**/release-embedded.test.ts",
use: {
...devices["Desktop Chrome"],
launchOptions: { args: ["--disable-dev-shm-usage"] },
},
},
],
});