diff --git a/.github/actions/free-disk-space/action.yml b/.github/actions/free-disk-space/action.yml new file mode 100644 index 000000000..238b72f9a --- /dev/null +++ b/.github/actions/free-disk-space/action.yml @@ -0,0 +1,31 @@ +name: Free disk space +description: Reclaim runner disk space by removing preinstalled toolchains we never use. +inputs: + aggressive: + description: >- + Also purge large apt packages, boost, and the agent tools cache. Slower; + use only for disk-heavy jobs (e.g. coverage) that otherwise run out. + required: false + default: "false" +runs: + using: composite + steps: + - name: Free disk space + shell: bash + env: + AGGRESSIVE: ${{ inputs.aggressive }} + run: | + set -euo pipefail + echo "Disk before:"; df -h / + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL + sudo docker image prune --all --force || true + if [ "$AGGRESSIVE" = "true" ]; then + sudo rm -rf /usr/local/share/boost "${AGENT_TOOLSDIRECTORY:-}" + sudo apt-get remove -y '^aspnetcore-.*' '^dotnet-.*' '^llvm-.*' 'php.*' \ + '^mongodb-.*' '^mysql-.*' azure-cli google-chrome-stable firefox \ + powershell mono-devel || true + sudo apt-get autoremove -y || true + sudo docker system prune --all --volumes --force || true + fi + sudo apt-get clean + echo "Disk after:"; df -h / diff --git a/.github/actions/rust/action.yml b/.github/actions/rust/action.yml index cd07ca012..e8aa0b588 100644 --- a/.github/actions/rust/action.yml +++ b/.github/actions/rust/action.yml @@ -1,5 +1,5 @@ name: Setup Rust -description: Install Rust version and setup caching +description: Install the Rust toolchain and wire up compilation + dependency caching. inputs: targets: description: Rust targets to install @@ -20,11 +20,16 @@ runs: - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 with: + # Save on same-repo pushes and PRs (fork PRs can't, for security), so a + # PR's later runs restore what its earlier runs compiled. Per-job keys + # (the rust-cache default) keep each cache matched to its artifact kind: + # clippy caches dep `.rmeta`, a build caches dep `.rlib`, and sharing one + # key across them would make the build restore check-artifacts and + # recompile. save-if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} - # Cache target directory but with smart cleanup - cache-on-failure: false - # Keep caches reusable inside a job class. Do not include raw target or - # component input strings here: rust-cache rejects keys containing - # commas, and comma-separated target lists are common in this repo. - shared-key: "rust-${{ runner.os }}-${{ github.job }}" + # Save even on failure/timeout. The node suite historically timed out + # before this post-step ran, so it never seeded a cache: cold build -> + # timeout -> still cold. CI runs CARGO_INCREMENTAL=0, so there is no + # incremental state to corrupt. + cache-on-failure: true workspaces: ". -> target" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 19de9ec29..57587ed78 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,6 +41,16 @@ permissions: contents: read # Required to checkout repository contents pull-requests: read # Required for path filtering on PR events +# Defaults shared by every Rust job. Job-/step-level env still overrides these. +# `_DEBUG: line-tables-only` keeps backtraces line-accurate while shrinking the +# target dir (and therefore the cache) vs full debuginfo. +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: "0" + SQLX_OFFLINE: "true" + CARGO_PROFILE_DEV_DEBUG: line-tables-only + CARGO_PROFILE_TEST_DEBUG: line-tables-only + jobs: changes: name: Change Detection @@ -205,8 +215,6 @@ jobs: with: components: clippy - name: Run cargo clippy - env: - SQLX_OFFLINE: true run: | cargo clippy --all-features --workspace --tests -- -D warnings @@ -214,20 +222,14 @@ jobs: name: Binary Build runs-on: ubuntu-latest steps: - - name: Free up disk space - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf /usr/local/lib/android - sudo rm -rf /opt/ghc - sudo rm -rf /opt/hostedtoolcache/CodeQL - sudo docker image prune --all --force - sudo apt-get clean - - name: Checkout repository uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with: persist-credentials: false + - name: Free disk space + uses: ./.github/actions/free-disk-space + - uses: ./.github/actions/rust - name: Build all workspace binaries @@ -235,8 +237,6 @@ jobs: # so a binary that only fails at link time (e.g. an undefined native # symbol pulled in from a contract crate) slips through. Linking the bins # is the one thing that catches it. - env: - SQLX_OFFLINE: true run: cargo build --workspace --bins soroban: @@ -417,24 +417,14 @@ jobs: --health-timeout 5s --health-retries 5 steps: - - name: Free up disk space - run: | - echo "Disk space before cleanup:" - df -h - sudo rm -rf /usr/share/dotnet - sudo rm -rf /usr/local/lib/android - sudo rm -rf /opt/ghc - sudo rm -rf /opt/hostedtoolcache/CodeQL - sudo docker image prune --all --force - sudo apt-get clean - echo "Disk space after cleanup:" - df -h - - name: Checkout repository uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with: persist-credentials: false + - name: Free disk space + uses: ./.github/actions/free-disk-space + - uses: ./.github/actions/rust - name: Install test tools @@ -444,18 +434,16 @@ jobs: - name: Run fast tests env: - SQLX_OFFLINE: true DATABASE_URL: &postgres_url postgres://relayeruser:password@localhost:5432/relayer NEXTEST_PROFILE: ci - CARGO_TERM_COLOR: always - CARGO_INCREMENTAL: 0 - CARGO_PROFILE_DEV_DEBUG: line-tables-only - CARGO_PROFILE_TEST_DEBUG: line-tables-only run: just test-fast near-integration-tests: name: NEAR Integration Tests - timeout-minutes: 40 + # Ceiling only (billing is actual runtime): ~35 min cold, less once the + # prebuild's ABI pass is skipped and rust-cache is dev-seeded. The headroom + # over 40 avoids a cold-run variance kill wasting a whole run. + timeout-minutes: 45 runs-on: ubuntu-latest services: # The relayer's node-backed `#[sqlx::test]` fixtures need Postgres. @@ -463,24 +451,14 @@ jobs: needs: changes if: ${{ needs.changes.outputs.run_near_integration == 'true' }} steps: - - name: Free up disk space - run: | - echo "Disk space before cleanup:" - df -h - sudo rm -rf /usr/share/dotnet - sudo rm -rf /usr/local/lib/android - sudo rm -rf /opt/ghc - sudo rm -rf /opt/hostedtoolcache/CodeQL - sudo docker image prune --all --force - sudo apt-get clean - echo "Disk space after cleanup:" - df -h - - name: Checkout repository uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with: persist-credentials: false + - name: Free disk space + uses: ./.github/actions/free-disk-space + - uses: ./.github/actions/rust - name: Install test tools @@ -493,12 +471,7 @@ jobs: - name: Run node-backed tests on a pooled neard sandbox env: - SQLX_OFFLINE: true DATABASE_URL: *postgres_url - CARGO_TERM_COLOR: always - CARGO_INCREMENTAL: 0 - CARGO_PROFILE_DEV_DEBUG: line-tables-only - CARGO_PROFILE_TEST_DEBUG: line-tables-only run: just test-sandbox - name: Cleanup Docker resources @@ -522,8 +495,6 @@ jobs: - uses: ./.github/actions/rust - name: Check artifact drift - env: - CARGO_TERM_COLOR: always run: ./script/check-artifact-drift.sh coverage: @@ -540,29 +511,16 @@ jobs: # database per test, so they need a reachable postgres at runtime. postgres: *postgres_service steps: - - name: Free up disk space - run: | - echo "Disk space before cleanup:" - df -h - sudo rm -rf /usr/share/dotnet - sudo rm -rf /usr/local/lib/android - sudo rm -rf /opt/ghc - sudo rm -rf /opt/hostedtoolcache/CodeQL - sudo rm -rf /usr/local/share/boost - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - sudo apt-get remove -y '^aspnetcore-.*' '^dotnet-.*' '^llvm-.*' 'php.*' '^mongodb-.*' '^mysql-.*' azure-cli google-chrome-stable firefox powershell mono-devel || true - sudo apt-get autoremove -y - sudo apt-get clean - sudo docker image prune --all --force - sudo docker system prune --all --volumes --force - echo "Disk space after cleanup:" - df -h - - name: Checkout repository uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with: persist-credentials: false + - name: Free disk space + uses: ./.github/actions/free-disk-space + with: + aggressive: "true" + - uses: ./.github/actions/rust with: components: llvm-tools-preview @@ -577,7 +535,6 @@ jobs: DATABASE_URL: *postgres_url CARGO_BUILD_JOBS: 2 NEXTEST_PROFILE: ci - CARGO_TERM_COLOR: always run: | just coverage-lcov diff --git a/contract/artifacts/src/workspace_loader.rs b/contract/artifacts/src/workspace_loader.rs index 288b56f09..53aa1b5b1 100644 --- a/contract/artifacts/src/workspace_loader.rs +++ b/contract/artifacts/src/workspace_loader.rs @@ -225,6 +225,13 @@ fn build_command( .args(["near", "build", build_mode, "--manifest-path"]) .arg(manifest_path) .current_dir(workspace_dir); + // Test artifacts (non-reproducible, `target/near`) are only deployed and + // called by the suite, which never reads the embedded ABI. Skipping ABI + // generation drops cargo-near's separate ABI build pass — ~35% of the + // prebuild's compile time. Release blobs (reproducible, `res/near`) keep it. + if !reproducible { + command.arg("--no-abi"); + } command }