From f5352382dd9dbc7d7e831bebcf09be391efb2fcd Mon Sep 17 00:00:00 2001 From: andrussal Date: Tue, 9 Dec 2025 07:47:17 +0100 Subject: [PATCH] Rename demo script to run-examples and align bundle usage --- .github/workflows/build-binaries.yml | 30 +----- .github/workflows/lint.yml | 6 +- scripts/build-bundle.sh | 120 +++++++++++++++++++++++ scripts/{run-demo.sh => run-examples.sh} | 8 +- 4 files changed, 130 insertions(+), 34 deletions(-) create mode 100755 scripts/build-bundle.sh rename scripts/{run-demo.sh => run-examples.sh} (97%) diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index 3424c10..aae0cc4 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -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: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0e80e71..22f6e21 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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() diff --git a/scripts/build-bundle.sh b/scripts/build-bundle.sh new file mode 100755 index 0000000..69c34c6 --- /dev/null +++ b/scripts/build-bundle.sh @@ -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--.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--.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}" 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}" diff --git a/scripts/run-demo.sh b/scripts/run-examples.sh similarity index 97% rename from scripts/run-demo.sh rename to scripts/run-examples.sh index 71ebb62..b497c94 100755 --- a/scripts/run-demo.sh +++ b/scripts/run-examples.sh @@ -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: