Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/actions/free-disk-space/action.yml
Original file line number Diff line number Diff line change
@@ -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 /
19 changes: 12 additions & 7 deletions .github/actions/rust/action.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
99 changes: 28 additions & 71 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -205,38 +215,28 @@ jobs:
with:
components: clippy
- name: Run cargo clippy
env:
SQLX_OFFLINE: true
run: |
cargo clippy --all-features --workspace --tests -- -D warnings

binary-build:
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
# `cargo check`, `clippy`, and `--lib` tests never link the executables,
# 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:
Expand Down Expand Up @@ -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
Expand All @@ -444,43 +434,31 @@ 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.
postgres: *postgres_service
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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -577,7 +535,6 @@ jobs:
DATABASE_URL: *postgres_url
CARGO_BUILD_JOBS: 2
NEXTEST_PROFILE: ci
CARGO_TERM_COLOR: always
run: |
just coverage-lcov

Expand Down
7 changes: 7 additions & 0 deletions contract/artifacts/src/workspace_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Comment on lines +232 to +234

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep an ABI-generating contract build in CI

The cargo-near v0.19.2 README describes cargo near build as building the contract along with its ABI, and the near-sdk README calls --no-abi a way to skip schema/ABI errors. This non-reproducible branch is used by spawn_artifact_build for script/prebuild-test-contracts.sh, which feeds both just test-sandbox and script/gas-report.sh, so the required CI paths no longer exercise ABI/JsonSchema generation at all; a contract-facing type can pass tests but fail the release/reproducible build. Keep at least one required cargo-near build without this flag.

Useful? React with 👍 / 👎.

command
}

Expand Down
Loading