diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml index 4bdae960df..9e46b6908a 100644 --- a/.github/workflows/check-build.yml +++ b/.github/workflows/check-build.yml @@ -10,12 +10,6 @@ jobs: - uses: actions/setup-node@v4 with: node-version: "20.9.0" - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - with: - workspaces: radicle-httpd -> target - - name: Build - run: cargo build --all --release --manifest-path=./radicle-httpd/Cargo.toml - name: Install dependencies run: npm ci - name: Install Playwright Browsers diff --git a/.github/workflows/check-e2e.yml b/.github/workflows/check-e2e.yml index 7b22a26725..aaae45aa72 100644 --- a/.github/workflows/check-e2e.yml +++ b/.github/workflows/check-e2e.yml @@ -11,16 +11,6 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - with: - workspaces: radicle-httpd -> target - - name: Build - run: cargo build --all --release --manifest-path=./radicle-httpd/Cargo.toml - - uses: actions/setup-node@v4 - with: - node-version: "20.9.0" - - name: Install dependencies run: npm ci @@ -38,7 +28,8 @@ jobs: - name: Install Radicle binaries run: | mkdir -p tests/artifacts; - ./scripts/install-binaries; + ./scripts/install-binaries --show-rad-path >> $GITHUB_PATH; + ./scripts/install-binaries --show-httpd-path >> $GITHUB_PATH; - name: Run Playwright tests run: npm run test:e2e -- --project ${{ matrix.browser }} diff --git a/.github/workflows/check-http-client-unit-test.yml b/.github/workflows/check-http-client-unit-test.yml index 065c3ac279..c6308de181 100644 --- a/.github/workflows/check-http-client-unit-test.yml +++ b/.github/workflows/check-http-client-unit-test.yml @@ -16,6 +16,7 @@ jobs: run: | mkdir -p tests/artifacts; ./scripts/install-binaries; - ./scripts/install-binaries --show-path >> $GITHUB_PATH; + ./scripts/install-binaries --show-rad-path >> $GITHUB_PATH; + ./scripts/install-binaries --show-httpd-path >> $GITHUB_PATH; - run: | npm run test:http-client:unit diff --git a/.github/workflows/check-visual.yml b/.github/workflows/check-visual.yml index 2691dbbbf1..03604cb959 100644 --- a/.github/workflows/check-visual.yml +++ b/.github/workflows/check-visual.yml @@ -26,12 +26,6 @@ jobs: - uses: actions/setup-node@v4 with: node-version: "20.9.0" - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - with: - workspaces: radicle-httpd -> target - - name: Build - run: cargo build --all --release --manifest-path=./radicle-httpd/Cargo.toml - name: Install dependencies run: npm ci @@ -62,7 +56,8 @@ jobs: run: | mkdir -p tests/artifacts; ./scripts/install-binaries; - ./scripts/install-binaries --show-path >> $GITHUB_PATH; + ./scripts/install-binaries --show-rad-path >> $GITHUB_PATH; + ./scripts/install-binaries --show-httpd-path >> $GITHUB_PATH; - name: Run Playwright tests run: | diff --git a/scripts/install-binaries b/scripts/install-binaries index b0369a5d29..8bb04014d6 100755 --- a/scripts/install-binaries +++ b/scripts/install-binaries @@ -3,9 +3,31 @@ set -e REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD") RELEASE=$(cat "$REPO_ROOT/tests/support/heartwood-release") -BINARY_PATH=$REPO_ROOT/tests/tmp/bin/$RELEASE +HTTPD_RELEASE=$(cat "$REPO_ROOT/tests/support/radicle-httpd-release") +BINARY_PATH=$REPO_ROOT/tests/tmp/bin OS=$(uname) +install() { + if test -d "$BINARY_PATH/$1"; then + echo ✅ "Folder $BINARY_PATH/$1 exists already skipping download and build." + else + mkdir -p "$BINARY_PATH/$1" + case "$OS" in + Darwin) + echo Downloading "$1" from "https://files.radicle.xyz/releases$2/$1/radicle-aarch64-apple-darwin.tar.xz into /tests/tmp/bin/$1" + curl --fail -s "https://files.radicle.xyz/releases$2/$1/radicle-aarch64-apple-darwin.tar.xz" | tar -xJ --strip-components=2 -C "$BINARY_PATH/$1" "radicle-$1-aarch64-apple-darwin/bin/" || (echo "Download failed" && exit 1) + ;; + Linux) + echo Downloading "$1" from "https://files.radicle.xyz/releases$2/$1/radicle-x86_64-unknown-linux-musl.tar.xz into /tests/tmp/bin/$1" + curl --fail -s "https://files.radicle.xyz/releases$2/$1/radicle-x86_64-unknown-linux-musl.tar.xz" | tar -xJ --strip-components=2 -C "$BINARY_PATH/$1" "radicle-$1-x86_64-unknown-linux-musl/bin/" || (echo "Download failed" && exit 1) + ;; + *) + echo "There are no precompiled binaries for your OS: $OS, compile $1 manually and make sure it's in PATH." && exit 1 + ;; + esac + fi +} + show_usage() { echo echo "Installs binaries required for running e2e test suite." @@ -21,8 +43,12 @@ show_usage() { while [ $# -ne 0 ]; do case "$1" in - --show-path | -s) - echo "$BINARY_PATH" + --show-rad-path) + echo "$BINARY_PATH/$RELEASE" + exit + ;; + --show-httpd-path) + echo "$BINARY_PATH/$HTTPD_RELEASE" exit ;; --help | -h) @@ -32,28 +58,7 @@ while [ $# -ne 0 ]; do esac done -if test -d "$BINARY_PATH"; then - echo ✅ "Folder $BINARY_PATH exists already skipping download and build." -else - mkdir -p "$BINARY_PATH" - case "$OS" in - Darwin) - echo Downloading "$RELEASE" from "https://files.radicle.xyz/releases/$RELEASE/radicle-aarch64-apple-darwin.tar.xz into /tests/tmp/bin/$RELEASE" - curl --fail -s "https://files.radicle.xyz/releases/$RELEASE/radicle-aarch64-apple-darwin.tar.xz" | tar -xJ --strip-components=2 -C "$BINARY_PATH" "radicle-$RELEASE-aarch64-apple-darwin/bin/" || (echo "Download failed" && exit 1) - ;; - Linux) - echo Downloading "$RELEASE" from "https://files.radicle.xyz/releases/$RELEASE/radicle-x86_64-unknown-linux-musl.tar.xz into /tests/tmp/bin/$RELEASE" - curl --fail -s "https://files.radicle.xyz/releases/$RELEASE/radicle-x86_64-unknown-linux-musl.tar.xz" | tar -xJ --strip-components=2 -C "$BINARY_PATH" "radicle-$RELEASE-x86_64-unknown-linux-musl/bin/" || (echo "Download failed" && exit 1) - ;; - *) - echo "There are no precompiled binaries for your OS: $OS, compile $RELEASE manually and make sure it's in PATH." && exit 1 - ;; - esac - - echo Building radicle-httpd - CARGO_TERM_PROGRESS_WIDTH=80 CARGO_TERM_PROGRESS_WHEN=always cargo build --release --all --quiet --manifest-path=$REPO_ROOT/radicle-httpd/Cargo.toml - echo Copying radicle-httpd into /tests/tmp/bin/$RELEASE - cp $REPO_ROOT/radicle-httpd/target/release/radicle-httpd $BINARY_PATH -fi +install "$RELEASE" "/" +install "$HTTPD_RELEASE" "/radicle-httpd" echo diff --git a/tests/support/globalSetup.ts b/tests/support/globalSetup.ts index a807d1f40d..00d28e6382 100644 --- a/tests/support/globalSetup.ts +++ b/tests/support/globalSetup.ts @@ -1,7 +1,9 @@ import * as Fs from "node:fs"; import * as Path from "node:path"; import { - assertRadInstalled, + assertBinariesInstalled, + heartwoodRelease, + radicleHttpdRelease, removeWorkspace, tmpDir, } from "@tests/support/support.js"; @@ -15,9 +17,22 @@ import { } from "@tests/support/fixtures.js"; import { createPeerManager } from "@tests/support/peerManager.js"; +const heartwoodBinaryPath = Path.join(tmpDir, "bin", heartwoodRelease); +const httpdBinaryPath = Path.join(tmpDir, "bin", radicleHttpdRelease); + export default async function globalSetup(): Promise<() => void> { try { - await assertRadInstalled(); + await assertBinariesInstalled("rad", heartwoodRelease, heartwoodBinaryPath); + await assertBinariesInstalled( + "radicle-httpd", + radicleHttpdRelease, + httpdBinaryPath, + ); + process.env.PATH = [ + heartwoodBinaryPath, + httpdBinaryPath, + process.env.PATH, + ].join(Path.delimiter); } catch (error) { console.error(error); console.log(""); diff --git a/tests/support/radicle-httpd-release b/tests/support/radicle-httpd-release new file mode 100644 index 0000000000..51de3305bb --- /dev/null +++ b/tests/support/radicle-httpd-release @@ -0,0 +1 @@ +0.13.0 \ No newline at end of file diff --git a/tests/support/support.ts b/tests/support/support.ts index e9b7257532..de1ba1fa81 100644 --- a/tests/support/support.ts +++ b/tests/support/support.ts @@ -30,21 +30,27 @@ export const heartwoodRelease = await Fs.readFile( "utf8", ); -const binaryPath = Path.join(tmpDir, "bin", heartwoodRelease); -process.env.PATH = [binaryPath, process.env.PATH].join(Path.delimiter); +export const radicleHttpdRelease = await Fs.readFile( + `${supportDir}/radicle-httpd-release`, + "utf8", +); -// Assert that the `rad` CLI is installed and has the correct version. -export async function assertRadInstalled(): Promise { - const { stdout: which } = await execa("which", ["rad"]); - if (Path.dirname(which) !== binaryPath) { +// Assert that binaries are installed and are the correct version. +export async function assertBinariesInstalled( + binary: string, + expectedVersion: string, + expectedPath: string, +): Promise { + const { stdout: which } = await execa("which", [binary]); + if (Path.dirname(which) !== expectedPath) { throw new Error( - `rad path doesn't match used rad binary: ${binaryPath} !== ${which}`, + `${binary} path doesn't match used ${binary} binary: ${expectedPath} !== ${which}`, ); } - const { stdout: version } = await execa("rad", ["--version"]); - if (!version.includes(heartwoodRelease)) { + const { stdout: version } = await execa(binary, ["--version"]); + if (!version.includes(expectedVersion)) { throw new Error( - `rad version ${version} does not satisfy ${heartwoodRelease}`, + `${binary} version ${version} does not satisfy ${expectedVersion}`, ); } }