From 4d25eec15f772327250f837886c19d9637eb3ff7 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 19 Jun 2026 16:10:14 +0200 Subject: [PATCH] Build optimization --- .github/workflows/ci.yml | 67 +++++++++++++++++++++++++++++++++++----- Makefile | 25 +++++++++------ e2e/fixtures.ts | 4 +-- package.json | 4 +-- playwright.config.ts | 15 +++++---- 5 files changed, 87 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f5f1a6c..bc57e9c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/Makefile b/Makefile index 95cd6ef4..0039b82d 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/e2e/fixtures.ts b/e2e/fixtures.ts index a0b4b651..8b9db7f3 100644 --- a/e2e/fixtures.ts +++ b/e2e/fixtures.ts @@ -65,9 +65,7 @@ export const test = base.extend({ 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, ".."), diff --git a/package.json b/package.json index 9bc722a3..ae90afc0 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/playwright.config.ts b/playwright.config.ts index 99939b47..4d296874 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -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"] }, + }, }, ], });