diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2d9d5e73a..8ad46b0e4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -47,6 +47,16 @@ remove the `SKIP_SETUP` flag to ensure tests run against the latest build. * Subsequent runs (no code changes): `SKIP_SETUP=true npm run test:e2e -- --project chromium` * Single test by line number: `SKIP_SETUP=true npm run test:e2e -- tests/e2e/repo/commits.spec.ts:90 --project chromium` +**Testing with local radicle-httpd build:** + +If you're developing radicle-httpd and want to test changes locally: + + npm run test:e2e:local + +This will: +1. Compile radicle-httpd from the `radicle-httpd/` directory +2. Run the full test suite against the locally compiled binary + Proposing changes ----------------- When proposing changes via a patch: diff --git a/package.json b/package.json index 7f89a61a4..2d2bf6932 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "format": "npx prettier '**/*.@(ts|js|svelte|json|css|html|yml)' --write", "test:unit": "TZ='UTC' vitest run", "test:e2e": "NODE_CONFIG_ENV='test' TZ='UTC' playwright test", + "test:e2e:local": "scripts/compile-local-httpd && USE_LOCAL_HTTPD=true NODE_CONFIG_ENV='test' TZ='UTC' playwright test", "test:http-client:unit": "NODE_CONFIG_ENV='test' TZ='UTC' vitest run --config http-client/vite.config.ts --reporter verbose", "test:radicle-httpd": "cd radicle-httpd && cargo test --all-features", "deploy": "rimraf build && npm clean-install && npm run build && scripts/inject-plausible && npx wrangler deploy" diff --git a/scripts/compile-local-httpd b/scripts/compile-local-httpd new file mode 100755 index 000000000..865b921e2 --- /dev/null +++ b/scripts/compile-local-httpd @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +set -e + +echo "🔨 Compiling local radicle-httpd..." + +# Ensure radicle-httpd directory exists +if [ ! -d "radicle-httpd" ]; then + echo "❌ radicle-httpd directory not found" + exit 1 +fi + +# Compile radicle-httpd (debug build for faster compilation) +cd radicle-httpd +cargo build +cd .. + +# Verify binary was created +if [ ! -f "radicle-httpd/target/debug/radicle-httpd" ]; then + echo "❌ Compilation failed - binary not found" + exit 1 +fi + +# Create target directory +mkdir -p tests/tmp/bin/httpd/local + +# Copy binary to test location +cp radicle-httpd/target/debug/radicle-httpd tests/tmp/bin/httpd/local/radicle-httpd + +echo "✅ Local radicle-httpd compiled and ready at tests/tmp/bin/httpd/local/radicle-httpd" diff --git a/tests/support/globalSetup.ts b/tests/support/globalSetup.ts index a285492b1..b273fdd5d 100644 --- a/tests/support/globalSetup.ts +++ b/tests/support/globalSetup.ts @@ -6,6 +6,7 @@ import { radicleHttpdRelease, removeWorkspace, tmpDir, + useLocalHttpd, } from "@tests/support/support.js"; import { defaultConfig, @@ -24,12 +25,9 @@ const heartwoodBinaryPath = Path.join( "heartwood", heartwoodRelease, ).trim(); -const httpdBinaryPath = Path.join( - tmpDir, - "bin", - "httpd", - radicleHttpdRelease, -).trim(); +const httpdBinaryPath = useLocalHttpd + ? Path.join(tmpDir, "bin", "httpd", "local").trim() + : Path.join(tmpDir, "bin", "httpd", radicleHttpdRelease).trim(); process.env.PATH = [ heartwoodBinaryPath, @@ -42,14 +40,19 @@ export default async function globalSetup(): Promise<() => void> { await assertBinariesInstalled("rad", heartwoodRelease, heartwoodBinaryPath); await assertBinariesInstalled( "radicle-httpd", - radicleHttpdRelease, + useLocalHttpd ? "pre-release" : radicleHttpdRelease, httpdBinaryPath, ); } catch (error) { console.error(error); console.log(""); - console.log("To download the required test binaries, run:"); - console.log(" 👉 ./scripts/install-binaries"); + if (useLocalHttpd) { + console.log("To compile local radicle-httpd binary, run:"); + console.log(" 👉 ./scripts/compile-local-httpd"); + } else { + console.log("To download the required test binaries, run:"); + console.log(" 👉 ./scripts/install-binaries"); + } console.log(""); process.exit(1); } @@ -62,7 +65,7 @@ export default async function globalSetup(): Promise<() => void> { if (shouldSetup) { console.log("⚡ Starting parallel setup..."); } else { - console.log("⏭️ Skipping setup (SKIP_SETUP is set)"); + console.log("⏭️ Skipping setup (SKIP_SETUP is set)"); } // Run build and fixture setup in parallel @@ -162,6 +165,25 @@ export default async function globalSetup(): Promise<() => void> { console.log("🚀 Setup complete, ready to run tests"); } + // Print binary versions + const { execa: exec } = await import("execa"); + const { stdout: radVersion } = await exec("rad", ["--version"]); + const { stdout: gitRemoteRadVersion } = await exec("git-remote-rad", [ + "--version", + ]); + const { stdout: httpdVersion } = await exec("radicle-httpd", ["--version"]); + // radicle-httpd outputs logging lines, extract just the version line (last line) + const httpdVersionClean = + httpdVersion.trim().split("\n").pop() || httpdVersion; + console.log(""); + console.log("Binary versions:"); + console.log(` rad: ${radVersion.trim()}`); + console.log(` git-remote-rad: ${gitRemoteRadVersion.trim()}`); + console.log( + ` radicle-httpd: ${httpdVersionClean}${useLocalHttpd ? " (local)" : ""}`, + ); + console.log(""); + return async () => { await peerManager.shutdown(); }; diff --git a/tests/support/support.ts b/tests/support/support.ts index cdc81dfb4..16abe286e 100644 --- a/tests/support/support.ts +++ b/tests/support/support.ts @@ -33,6 +33,8 @@ export const radicleHttpdRelease = ( await Fs.readFile(`${supportDir}/radicle-httpd-release`, "utf8") ).trim(); +export const useLocalHttpd = process.env.USE_LOCAL_HTTPD === "true"; + // Assert that binaries are installed and are the correct version. export async function assertBinariesInstalled( binary: string,