mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 06:10:44 +08:00
Fix radicle-httpd tests for release instead of build from source
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -16,6 +16,5 @@ jobs:
|
||||
run: |
|
||||
mkdir -p tests/artifacts;
|
||||
./scripts/install-binaries;
|
||||
./scripts/install-binaries --show-path >> $GITHUB_PATH;
|
||||
- run: |
|
||||
npm run test:http-client:unit
|
||||
|
||||
@@ -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,6 @@ jobs:
|
||||
run: |
|
||||
mkdir -p tests/artifacts;
|
||||
./scripts/install-binaries;
|
||||
./scripts/install-binaries --show-path >> $GITHUB_PATH;
|
||||
|
||||
- name: Run Playwright tests
|
||||
run: |
|
||||
|
||||
+26
-30
@@ -3,28 +3,45 @@ 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/$2"; then
|
||||
echo ✅ "Folder $BINARY_PATH/$1/$2 exists already skipping download."
|
||||
else
|
||||
mkdir -p "$BINARY_PATH/$1/$2"
|
||||
case "$OS" in
|
||||
Darwin)
|
||||
echo Downloading "$1" v"$2" from "https://files.radicle.xyz/releases$3/$2/radicle-aarch64-apple-darwin.tar.xz into /tests/tmp/bin/$1/$2"
|
||||
curl --fail -s "https://files.radicle.xyz/releases$3/$2/radicle-aarch64-apple-darwin.tar.xz" | tar -xJ --strip-components=2 -C "$BINARY_PATH/$1/$2" "radicle-$2-aarch64-apple-darwin/bin/" || (echo "Download failed" && exit 1)
|
||||
;;
|
||||
Linux)
|
||||
echo Downloading "$1" v"$2" from "https://files.radicle.xyz/releases$3/$2/radicle-x86_64-unknown-linux-musl.tar.xz into /tests/tmp/bin/$1/$2"
|
||||
curl --fail -s "https://files.radicle.xyz/releases$3/$2/radicle-x86_64-unknown-linux-musl.tar.xz" | tar -xJ --strip-components=2 -C "$BINARY_PATH/$1/$2" "radicle-$2-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."
|
||||
echo
|
||||
echo "USAGE:"
|
||||
echo " install-binaries [-s|h]"
|
||||
echo " install-binaries [-h]"
|
||||
echo
|
||||
echo "OPTIONS:"
|
||||
echo " -s --show-path Print the binary path, and skip installation."
|
||||
echo " -h --help Print this Help."
|
||||
echo
|
||||
}
|
||||
|
||||
while [ $# -ne 0 ]; do
|
||||
case "$1" in
|
||||
--show-path | -s)
|
||||
echo "$BINARY_PATH"
|
||||
exit
|
||||
;;
|
||||
--help | -h)
|
||||
show_usage
|
||||
exit
|
||||
@@ -32,28 +49,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 "heartwood" "$RELEASE" ""
|
||||
install "httpd" "$HTTPD_RELEASE" "/radicle-httpd"
|
||||
|
||||
echo
|
||||
|
||||
@@ -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,28 @@ import {
|
||||
} from "@tests/support/fixtures.js";
|
||||
import { createPeerManager } from "@tests/support/peerManager.js";
|
||||
|
||||
const heartwoodBinaryPath = Path.join(
|
||||
tmpDir,
|
||||
"bin",
|
||||
"heartwood",
|
||||
heartwoodRelease,
|
||||
);
|
||||
const httpdBinaryPath = Path.join(tmpDir, "bin", "httpd", radicleHttpdRelease);
|
||||
|
||||
process.env.PATH = [
|
||||
heartwoodBinaryPath,
|
||||
httpdBinaryPath,
|
||||
process.env.PATH,
|
||||
].join(Path.delimiter);
|
||||
|
||||
export default async function globalSetup(): Promise<() => void> {
|
||||
try {
|
||||
await assertRadInstalled();
|
||||
await assertBinariesInstalled("rad", heartwoodRelease, heartwoodBinaryPath);
|
||||
await assertBinariesInstalled(
|
||||
"radicle-httpd",
|
||||
radicleHttpdRelease,
|
||||
httpdBinaryPath,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.log("");
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
0.13.0
|
||||
+16
-10
@@ -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<void> {
|
||||
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<void> {
|
||||
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}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user