From c4c033d912464c6045484b56fe23e4644e924a26 Mon Sep 17 00:00:00 2001 From: andrussal Date: Tue, 2 Dec 2025 14:08:54 +0100 Subject: [PATCH] Adjust CI lint workflow caching and binaries reuse --- .github/workflows/lint.yml | 77 +++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 26 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 134b9a3..1985ffa 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -44,6 +44,10 @@ jobs: restore-keys: ${{ runner.os }}-cargo- - name: Build nomos binaries run: | + if [ "${ACT:-}" = "true" ] && [ -f "${GITHUB_WORKSPACE}/nomos-binaries.tar.gz" ]; then + # Reuse previously built tar without rebuilding. + exit 0 + fi SRC_DIR="${GITHUB_WORKSPACE}/.tmp/nomos-node-src" mkdir -p "$SRC_DIR" if [ ! -d "$SRC_DIR/.git" ]; then @@ -63,10 +67,16 @@ jobs: cp "${CARGO_TARGET_DIR}/debug/nomos-cli" artifacts/ tar -czf nomos-binaries.tar.gz -C artifacts . - uses: actions/upload-artifact@v4 - if: env.ACT != 'true' with: name: nomos-binaries-linux-amd64 path: nomos-binaries.tar.gz + continue-on-error: ${{ env.ACT == 'true' }} + - name: Persist binaries for act + if: env.ACT == 'true' + run: | + if [ ! -f "${GITHUB_WORKSPACE}/nomos-binaries.tar.gz" ]; then + cp nomos-binaries.tar.gz "${GITHUB_WORKSPACE}/nomos-binaries.tar.gz" + fi fmt: runs-on: ubuntu-latest @@ -222,30 +232,24 @@ jobs: key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo- - name: Build nomos binaries (act fallback) - if: env.ACT == 'true' && ! (startsWith(github.event_name, 'workflow_dispatch') && hashFiles('nomos-binaries.tar.gz') != '') + if: env.ACT == 'true' && hashFiles(format('{0}/nomos-binaries/nomos-binaries.tar.gz', runner.temp)) == '' run: | - if [ -f "${GITHUB_WORKSPACE}/nomos-binaries.tar.gz" ]; then - mkdir -p "${RUNNER_TEMP}/nomos-binaries" - cp "${GITHUB_WORKSPACE}/nomos-binaries.tar.gz" "${RUNNER_TEMP}/" - tar -xzf "${RUNNER_TEMP}/nomos-binaries.tar.gz" -C "${RUNNER_TEMP}/nomos-binaries" - else - SRC_DIR="${RUNNER_TEMP}/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 2f60a0372c228968c3526c341ebc7e58bbd178dd - git checkout 2f60a0372c228968c3526c341ebc7e58bbd178dd - git reset --hard - git clean -fdx - cargo +nightly-2025-09-14 build --all-features -p nomos-node -p nomos-executor -p nomos-cli - mkdir -p "${RUNNER_TEMP}/nomos-binaries" - cp "${CARGO_TARGET_DIR:-${RUNNER_TEMP}/target-local}/debug/nomos-node" "${RUNNER_TEMP}/nomos-binaries/" - cp "${CARGO_TARGET_DIR:-${RUNNER_TEMP}/target-local}/debug/nomos-executor" "${RUNNER_TEMP}/nomos-binaries/" - cp "${CARGO_TARGET_DIR:-${RUNNER_TEMP}/target-local}/debug/nomos-cli" "${RUNNER_TEMP}/nomos-binaries/" - tar -czf "${RUNNER_TEMP}/nomos-binaries.tar.gz" -C "${RUNNER_TEMP}/nomos-binaries" . + SRC_DIR="${RUNNER_TEMP}/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 2f60a0372c228968c3526c341ebc7e58bbd178dd + git checkout 2f60a0372c228968c3526c341ebc7e58bbd178dd + git reset --hard + git clean -fdx + cargo +nightly-2025-09-14 build --all-features -p nomos-node -p nomos-executor -p nomos-cli + mkdir -p "${RUNNER_TEMP}/nomos-binaries" + cp "${CARGO_TARGET_DIR:-${RUNNER_TEMP}/target-local}/debug/nomos-node" "${RUNNER_TEMP}/nomos-binaries/" + cp "${CARGO_TARGET_DIR:-${RUNNER_TEMP}/target-local}/debug/nomos-executor" "${RUNNER_TEMP}/nomos-binaries/" + cp "${CARGO_TARGET_DIR:-${RUNNER_TEMP}/target-local}/debug/nomos-cli" "${RUNNER_TEMP}/nomos-binaries/" + tar -czf "${RUNNER_TEMP}/nomos-binaries.tar.gz" -C "${RUNNER_TEMP}/nomos-binaries" . - name: Download prebuilt nomos binaries if: env.ACT != 'true' uses: actions/download-artifact@v4 @@ -256,11 +260,22 @@ jobs: if: env.ACT == 'true' run: | mkdir -p "${RUNNER_TEMP}/nomos-binaries" - tar -xzf "${RUNNER_TEMP}/nomos-binaries.tar.gz" -C "${RUNNER_TEMP}/nomos-binaries" + if [ -f "${RUNNER_TEMP}/nomos-binaries.tar.gz" ]; then + cp "${RUNNER_TEMP}/nomos-binaries.tar.gz" "${RUNNER_TEMP}/nomos-binaries/nomos-binaries.tar.gz" + tar -xzf "${RUNNER_TEMP}/nomos-binaries.tar.gz" -C "${RUNNER_TEMP}/nomos-binaries" + elif [ -f "${GITHUB_WORKSPACE}/nomos-binaries.tar.gz" ]; then + cp "${GITHUB_WORKSPACE}/nomos-binaries.tar.gz" "${RUNNER_TEMP}/nomos-binaries/" + tar -xzf "${GITHUB_WORKSPACE}/nomos-binaries.tar.gz" -C "${RUNNER_TEMP}/nomos-binaries" + else + echo "nomos-binaries.tar.gz not found" >&2 + exit 1 + fi - name: Install nomos binaries run: | BIN_DIR="${RUNNER_TEMP}/nomos-binaries" - tar -xzf "${BIN_DIR}/nomos-binaries.tar.gz" -C "${BIN_DIR}" + if [ -f "${BIN_DIR}/nomos-binaries.tar.gz" ]; then + tar -xzf "${BIN_DIR}/nomos-binaries.tar.gz" -C "${BIN_DIR}" + fi sudo cp "${BIN_DIR}/nomos-node" /usr/local/bin/ sudo cp "${BIN_DIR}/nomos-executor" /usr/local/bin/ sudo cp "${BIN_DIR}/nomos-cli" /usr/local/bin/ @@ -273,6 +288,8 @@ jobs: mkdir -p testing-framework/assets/stack/kzgrs_test_params rsync -a --delete "$NOMOS_CIRCUITS"/ testing-framework/assets/stack/kzgrs_test_params/ || true - name: Run local runner smoke (ignored test) + env: + LOCAL_DEMO_RUN_SECS: ${{ env.ACT == 'true' && '20' || env.LOCAL_DEMO_RUN_SECS }} run: | cargo +nightly-2025-09-14 test -p runner-examples --test local_runner_bin_smoke -- --ignored --nocapture @@ -301,7 +318,15 @@ jobs: if: env.ACT == 'true' run: | mkdir -p "${RUNNER_TEMP}/nomos-binaries" - tar -xzf "${RUNNER_TEMP}/nomos-binaries.tar.gz" -C "${RUNNER_TEMP}/nomos-binaries" + if [ -f "${RUNNER_TEMP}/nomos-binaries.tar.gz" ]; then + tar -xzf "${RUNNER_TEMP}/nomos-binaries.tar.gz" -C "${RUNNER_TEMP}/nomos-binaries" + elif [ -f "${GITHUB_WORKSPACE}/nomos-binaries.tar.gz" ]; then + cp "${GITHUB_WORKSPACE}/nomos-binaries.tar.gz" "${RUNNER_TEMP}/nomos-binaries/" + tar -xzf "${GITHUB_WORKSPACE}/nomos-binaries.tar.gz" -C "${RUNNER_TEMP}/nomos-binaries" + else + echo "nomos-binaries.tar.gz not found" >&2 + exit 1 + fi - name: Stage nomos binaries into build context run: | BIN_DIR="${RUNNER_TEMP}/nomos-binaries"