Rename demo script to run-examples and align bundle usage

This commit is contained in:
andrussal 2025-12-09 07:47:17 +01:00
parent 3536c22db0
commit f5352382dd
4 changed files with 130 additions and 34 deletions

View File

@ -48,34 +48,10 @@ jobs:
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Build nomos binaries
- name: Build nomos binaries bundle
run: |
SRC_DIR="${GITHUB_WORKSPACE}/.tmp/nomos-node-src"
mkdir -p "$SRC_DIR"
if [ ! -d "$SRC_DIR/.git" ]; then
git clone https://github.com/logos-co/nomos-node.git "$SRC_DIR"
fi
cd "$SRC_DIR"
git fetch --depth 1 origin "${NOMOS_NODE_REV}"
git checkout "${NOMOS_NODE_REV}"
git reset --hard
git clean -fdx
# Align CI with the host build path: refresh dependency lock to latest compatible
# crates (we still pin flate2 below). This mirrors the local script that drops
# Cargo.lock before building.
cargo +nightly-2025-09-14 update
# Work around flate2 1.1.6 ambiguity issues by pinning to a fixed release.
cargo +nightly-2025-09-14 update -p flate2 --precise 1.1.5
cargo +nightly-2025-09-14 build --all-features --bins
- name: Package binaries
run: |
mkdir -p artifacts
cp "${CARGO_TARGET_DIR}/debug/nomos-node" artifacts/
cp "${CARGO_TARGET_DIR}/debug/nomos-executor" artifacts/
cp "${CARGO_TARGET_DIR}/debug/nomos-cli" artifacts/
mkdir -p artifacts/circuits
rsync -a "$NOMOS_CIRCUITS"/ artifacts/circuits/
tar -czf nomos-binaries.tar.gz -C artifacts .
chmod +x scripts/build-bundle.sh
scripts/build-bundle.sh --platform linux --output nomos-binaries.tar.gz
- name: Save nomos binaries cache
uses: actions/cache@v4
with:

View File

@ -178,13 +178,13 @@ jobs:
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Run local demo (scripted)
- name: Run host demo (scripted)
env:
NOMOS_TESTS_KEEP_LOGS: "true"
RUST_LOG: "info"
NOMOS_LOG_DIR: "${{ runner.temp }}/local-logs"
run: |
scripts/run-demo.sh local 60
scripts/run-examples.sh -t 60 -v 1 -e 1 host
- name: Collect local demo logs (on failure)
if: failure()
run: |
@ -306,7 +306,7 @@ jobs:
NOMOS_BINARIES_TAR: "${{ github.workspace }}/.tmp/nomos-binaries.tar.gz"
run: |
mkdir -p "$TMPDIR"
scripts/run-demo.sh compose 60
scripts/run-examples.sh -t 60 -v 1 -e 1 compose
- name: Collect compose logs
if: failure()

120
scripts/build-bundle.sh Executable file
View File

@ -0,0 +1,120 @@
#!/usr/bin/env bash
set -euo pipefail
# Build a nomos-binaries.tar.gz for the specified platform.
#
# Usage: scripts/build-bundle.sh [--platform host|linux] [--output PATH]
# --platform Target platform for binaries (default: host)
# --output Output path for the tarball (default: .tmp/nomos-binaries-<platform>-<version>.tar.gz)
usage() {
cat <<'EOF'
Usage: scripts/build-bundle.sh [--platform host|linux] [--output PATH]
Options:
--platform Target platform for binaries (default: host)
--output Output path for the tarball (default: .tmp/nomos-binaries-<platform>-<version>.tar.gz)
Notes:
- For compose/k8s, use platform=linux. If running on macOS, this script will
run inside a Linux Docker container to produce Linux binaries.
- VERSION and NOMOS_NODE_REV env vars are honored (defaults align with run-examples.sh).
EOF
}
fail() { echo "$1" >&2; exit 1; }
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
usage; exit 0
fi
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
DEFAULT_VERSION="v0.3.1"
DEFAULT_NODE_REV="d2dd5a5084e1daef4032562c77d41de5e4d495f8"
PLATFORM="host"
OUTPUT=""
while [ "$#" -gt 0 ]; do
case "$1" in
--platform)
PLATFORM="${2:-}"; shift 2 ;;
--output)
OUTPUT="${2:-}"; shift 2 ;;
*) fail "Unknown argument: $1" ;;
esac
done
case "$PLATFORM" in
host|linux) ;;
*) fail "--platform must be host or linux" ;;
esac
VERSION="${VERSION:-${DEFAULT_VERSION}}"
NOMOS_NODE_REV="${NOMOS_NODE_REV:-${DEFAULT_NODE_REV}}"
if [ -z "${OUTPUT}" ]; then
OUTPUT="${ROOT_DIR}/.tmp/nomos-binaries-${PLATFORM}-${VERSION}.tar.gz"
fi
if [ "$PLATFORM" = "linux" ] && [ "$(uname -s)" != "Linux" ] && [ -z "${BUNDLE_IN_CONTAINER:-}" ]; then
# Re-run inside a Linux container to produce Linux binaries.
if ! command -v docker >/dev/null 2>&1; then
fail "Docker is required to build a Linux bundle from non-Linux host"
fi
echo "==> Building Linux bundle inside Docker"
mkdir -p "${ROOT_DIR}/.tmp/cargo-linux" "${ROOT_DIR}/.tmp/nomos-node-linux-target"
docker run --rm \
-e VERSION="$VERSION" \
-e NOMOS_NODE_REV="$NOMOS_NODE_REV" \
-e BUNDLE_IN_CONTAINER=1 \
-e CARGO_HOME=/workspace/.tmp/cargo-linux \
-e CARGO_TARGET_DIR=/workspace/.tmp/nomos-node-linux-target \
-v "${ROOT_DIR}/.tmp/cargo-linux":/workspace/.tmp/cargo-linux \
-v "${ROOT_DIR}/.tmp/nomos-node-linux-target":/workspace/.tmp/nomos-node-linux-target \
-v "$ROOT_DIR":/workspace \
-w /workspace \
rust:1.80-bullseye \
bash -c "apt-get update && apt-get install -y clang llvm-dev libclang-dev pkg-config cmake libssl-dev rsync libgmp10 libgmp-dev libgomp1 nasm && ./scripts/build-bundle.sh --platform linux --output /workspace/.tmp/nomos-binaries-linux-${VERSION}.tar.gz"
exit 0
fi
echo "==> Preparing circuits (version ${VERSION})"
HOST_BUNDLE_PATH="${ROOT_DIR}/testing-framework/assets/stack/kzgrs_test_params"
mkdir -p "${ROOT_DIR}/.tmp"
"${ROOT_DIR}/scripts/setup-circuits-stack.sh" "${VERSION}" </dev/null
HOST_SRC="${ROOT_DIR}/.tmp/nomos-node-host-src"
HOST_TARGET="${ROOT_DIR}/.tmp/nomos-node-host-target"
HOST_NODE_BIN="${HOST_TARGET}/debug/nomos-node"
HOST_EXEC_BIN="${HOST_TARGET}/debug/nomos-executor"
HOST_CLI_BIN="${HOST_TARGET}/debug/nomos-cli"
echo "==> Building host binaries (platform=${PLATFORM})"
mkdir -p "${HOST_SRC}"
if [ ! -d "${HOST_SRC}/.git" ]; then
git clone https://github.com/logos-co/nomos-node.git "${HOST_SRC}"
fi
(
cd "${HOST_SRC}"
git fetch --depth 1 origin "${NOMOS_NODE_REV}"
git checkout "${NOMOS_NODE_REV}"
git reset --hard
git clean -fdx
RUSTFLAGS='--cfg feature="pol-dev-mode"' NOMOS_CIRCUITS="${HOST_BUNDLE_PATH}" \
cargo build --features testing \
-p nomos-node -p nomos-executor -p nomos-cli \
--target-dir "${HOST_TARGET}"
)
echo "==> Packaging bundle"
bundle_dir="${ROOT_DIR}/.tmp/nomos-bundle"
rm -rf "${bundle_dir}"
mkdir -p "${bundle_dir}/artifacts/circuits"
cp -a "${HOST_BUNDLE_PATH}/." "${bundle_dir}/artifacts/circuits/"
mkdir -p "${bundle_dir}/artifacts"
cp "${HOST_NODE_BIN}" "${bundle_dir}/artifacts/"
cp "${HOST_EXEC_BIN}" "${bundle_dir}/artifacts/"
cp "${HOST_CLI_BIN}" "${bundle_dir}/artifacts/"
mkdir -p "$(dirname "${OUTPUT}")"
tar --no-mac-metadata --no-xattrs -czf "${OUTPUT}" -C "${bundle_dir}" artifacts
echo "Bundle created at ${OUTPUT}"

View File

@ -4,9 +4,9 @@ set -euo pipefail
# All-in-one helper: prepare circuits (Linux + host), rebuild the image, and run
# the chosen runner binary.
#
# Usage: scripts/run-demo.sh [options] [compose|local|k8s]
# Usage: scripts/run-examples.sh [options] [compose|host|k8s]
# compose -> runs examples/src/bin/compose_runner.rs (default)
# local -> runs examples/src/bin/local_runner.rs
# host -> runs examples/src/bin/local_runner.rs
# k8s -> runs examples/src/bin/k8s_runner.rs
# run-seconds must be provided via -t/--run-seconds
#
@ -19,11 +19,11 @@ set -euo pipefail
usage() {
cat <<'EOF'
Usage: scripts/run-demo.sh [options] [compose|local|k8s]
Usage: scripts/run-examples.sh [options] [compose|host|k8s]
Modes:
compose Run examples/src/bin/compose_runner.rs (default)
local Run examples/src/bin/local_runner.rs
host Run examples/src/bin/local_runner.rs
k8s Run examples/src/bin/k8s_runner.rs
Options: