diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b69ada5..a093980 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -228,6 +228,31 @@ jobs: - name: Prepare workspace tmpdir run: mkdir -p "$TMPDIR" + - name: Restore cached nomos binaries + id: restore-nomos-bins + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.tmp/nomos-binaries.tar.gz + key: ${{ runner.os }}-nomos-binaries-${{ env.NOMOS_NODE_REV }}-${{ env.NOMOS_BUNDLE_VERSION }} + + - name: Download nomos binaries artifact (fallback) + if: steps.restore-nomos-bins.outputs.cache-hit != 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ARTIFACT_NAME: nomos-binaries-${{ runner.os }}-${{ env.NOMOS_NODE_REV }}-${{ env.NOMOS_BUNDLE_VERSION }} + run: | + set -euo pipefail + mkdir -p "${TMPDIR}" + artifact_id=$(gh api -X GET "repos/${GITHUB_REPOSITORY}/actions/artifacts" --paginate -F per_page=100 \ + --jq '.artifacts[] | select(.name=="'"${ARTIFACT_NAME}"'") | .id' | head -n1) + if [ -z "$artifact_id" ]; then + echo "Nomos binaries artifact ${ARTIFACT_NAME} not found. Run build-binaries workflow." >&2 + exit 1 + fi + gh api -X GET "repos/${GITHUB_REPOSITORY}/actions/artifacts/${artifact_id}/zip" > "${TMPDIR}/nomos-binaries.zip" + unzip -o "${TMPDIR}/nomos-binaries.zip" -d "${TMPDIR}" + mv "${TMPDIR}/nomos-binaries.tar.gz" "${GITHUB_WORKSPACE}/.tmp/nomos-binaries.tar.gz" + - name: Set compose target dir run: echo "CARGO_TARGET_DIR=${RUNNER_TEMP}/target-compose" >> "$GITHUB_ENV" @@ -276,6 +301,7 @@ jobs: RUST_LOG: "info" NOMOS_LOG_LEVEL: "info" NOMOS_LOG_DIR: "${{ github.workspace }}/.tmp/compose-logs" + NOMOS_BINARIES_TAR: "${{ github.workspace }}/.tmp/nomos-binaries.tar.gz" run: | mkdir -p "$TMPDIR" scripts/run-demo.sh compose 60 diff --git a/scripts/run-demo.sh b/scripts/run-demo.sh index d18488b..827e247 100755 --- a/scripts/run-demo.sh +++ b/scripts/run-demo.sh @@ -23,6 +23,7 @@ RUN_SECS="${2:-60}" VERSION="${VERSION:-v0.3.1}" IMAGE="${NOMOS_TESTNET_IMAGE:-nomos-testnet:local}" NOMOS_NODE_REV="${NOMOS_NODE_REV:-d2dd5a5084e1daef4032562c77d41de5e4d495f8}" +RESTORED_BINARIES=0 case "$MODE" in compose) BIN="compose_runner" ;; @@ -31,6 +32,41 @@ case "$MODE" in *) echo "Unknown mode '$MODE' (use compose|local)" >&2; exit 1 ;; esac +restore_binaries_from_tar() { + local tar_path="${NOMOS_BINARIES_TAR:-${ROOT_DIR}/.tmp/nomos-binaries.tar.gz}" + local extract_dir="${ROOT_DIR}/.tmp/nomos-binaries" + if [ ! -f "$tar_path" ]; then + return 1 + fi + echo "==> Restoring binaries from ${tar_path}" + rm -rf "${extract_dir}" + mkdir -p "${extract_dir}" + tar -xzf "$tar_path" -C "${extract_dir}" + local src="${extract_dir}/artifacts" + local bin_dst="${ROOT_DIR}/testing-framework/assets/stack/bin" + local circuits_src="${src}/circuits" + local circuits_dst="${ROOT_DIR}/testing-framework/assets/stack/kzgrs_test_params" + if [ -f "${src}/nomos-node" ] && [ -f "${src}/nomos-executor" ] && [ -f "${src}/nomos-cli" ]; then + mkdir -p "${bin_dst}" + cp "${src}/nomos-node" "${bin_dst}/" + cp "${src}/nomos-executor" "${bin_dst}/" + cp "${src}/nomos-cli" "${bin_dst}/" + else + echo "Binaries missing in ${tar_path}; fallback to build-from-source path" >&2 + return 1 + fi + if [ -d "${circuits_src}" ] && [ -f "${circuits_src}/kzgrs_test_params" ]; then + rm -rf "${circuits_dst}" + mkdir -p "${circuits_dst}" + rsync -a --delete "${circuits_src}/" "${circuits_dst}/" + else + echo "Circuits missing in ${tar_path}; fallback to download/build path" >&2 + return 1 + fi + RESTORED_BINARIES=1 + export RESTORED_BINARIES +} + ensure_host_binaries() { # Build nomos-node/nomos-executor for the host if not already present. HOST_SRC="${ROOT_DIR}/.tmp/nomos-node-host-src" @@ -75,9 +111,15 @@ ensure_host_binaries() { export NOMOS_NODE_BIN NOMOS_EXECUTOR_BIN } +restore_binaries_from_tar || true + echo "==> Preparing circuits (version ${VERSION})" SETUP_OUT="/tmp/nomos-setup-output.$$" -"${ROOT_DIR}/scripts/setup-circuits-stack.sh" "${VERSION}"