CI #344
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| # Daily cron job used to clear and rebuild cache (https://github.com/Swatinem/rust-cache/issues/181). | |
| schedule: | |
| - cron: "0 0 * * *" | |
| # Limits workflow concurrency to only the latest commit in the PR. | |
| concurrency: | |
| group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" | |
| cancel-in-progress: true | |
| jobs: | |
| detect-changes: | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| code: ${{ steps.filter.outputs.code }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: dorny/paths-filter@v4 | |
| id: filter | |
| with: | |
| filters: | | |
| code: | |
| - 'crates/**' | |
| - '!**/*.md' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| - '.github/workflows/**' | |
| test-all-features: | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.code == 'true' | |
| runs-on: ubuntu-24.04 | |
| env: | |
| CARGO_TERM_COLOR: always | |
| MLIR_SYS_190_PREFIX: "/usr/lib/llvm-19" | |
| LLVM_SYS_191_PREFIX: "/usr/lib/llvm-19" | |
| TABLEGEN_190_PREFIX: "/usr/lib/llvm-19" | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: ./.github/actions/free-disk-space | |
| - uses: rui314/setup-mold@v1 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'schedule' }} | |
| - uses: arduino/setup-protoc@v3 | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: taiki-e/install-action@nextest | |
| - uses: gerlero/add-apt-repository@v1 | |
| with: | |
| uri: http://apt.llvm.org/noble/ | |
| suite: llvm-toolchain-noble-19 | |
| key: https://apt.llvm.org/llvm-snapshot.gpg.key | |
| - uses: gerlero/apt-install@v1 | |
| with: | |
| packages: build-essential llvm-19 llvm-19-dev llvm-19-runtime clang-19 clang-tools-19 lld-19 libpolly-19-dev libmlir-19-dev mlir-19-tools | |
| - name: Clear cache | |
| if: github.event_name =='schedule' | |
| run: | | |
| cargo clean | |
| rm -rf ~/.cargo/registry | |
| rm -rf ~/.cargo/git | |
| - name: Compile pathfinder binary in release mode to check if integration testing cli is unavailable | |
| run: cargo build --release -p pathfinder --bin pathfinder -F p2p | |
| - name: Compile unit tests with all features enabled | |
| run: cargo nextest run --cargo-profile ci-dev --all-targets --all-features --workspace --locked --no-run --timings | |
| - name: Run unit tests with all features enabled excluding consensus integration tests | |
| run: timeout 10m cargo nextest run --cargo-profile ci-dev --no-fail-fast --all-targets --all-features --workspace --locked -E 'not test(/^test::consensus_[34]_nodes/)' --retries 2 | |
| - name: Store timings with all features enabled | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: timings-all-features | |
| path: target/cargo-timings/ | |
| if-no-files-found: warn | |
| test-consensus: | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.code == 'true' | |
| runs-on: ubuntu-24.04 | |
| env: | |
| CARGO_TERM_COLOR: always | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: ./.github/actions/free-disk-space | |
| - uses: rui314/setup-mold@v1 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'schedule' }} | |
| - uses: arduino/setup-protoc@v3 | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: taiki-e/install-action@nextest | |
| - name: Clear cache | |
| if: github.event_name == 'schedule' | |
| run: | | |
| cargo clean | |
| rm -rf ~/.cargo/registry | |
| rm -rf ~/.cargo/git | |
| - name: Compile feeder gateway binary for consensus integration tests | |
| run: cargo build -p feeder-gateway -F small_aggregate_filters --bin feeder-gateway | |
| - name: Compile pathfinder binary for consensus integration tests | |
| run: cargo build -p pathfinder -F p2p -F consensus-integration-tests --bin pathfinder | |
| - name: Run consensus integration tests | |
| env: | |
| APP_TEMP_DIR: ${{ runner.temp }} | |
| run: PATHFINDER_TEST_ENABLE_MARKER_FILES=1 timeout 30m cargo nextest run --test consensus -p pathfinder --features p2p,consensus-integration-tests --locked --retries 2 -j 1 | |
| - name: Store test artifacts for consensus integration tests | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: consensus-integration-tests | |
| include-hidden-files: true | |
| path: ${{ runner.temp }}/consensus-integration-tests/ | |
| if-no-files-found: warn | |
| test-default-features: | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.code == 'true' | |
| runs-on: ubuntu-24.04 | |
| env: | |
| CARGO_TERM_COLOR: always | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: ./.github/actions/free-disk-space | |
| - uses: rui314/setup-mold@v1 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'schedule' }} | |
| - uses: arduino/setup-protoc@v3 | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: taiki-e/install-action@nextest | |
| - name: Clear cache | |
| if: github.event_name =='schedule' | |
| run: | | |
| cargo clean | |
| rm -rf ~/.cargo/registry | |
| rm -rf ~/.cargo/git | |
| - name: Compile unit tests with default features | |
| run: cargo nextest run --cargo-profile ci-dev --all-targets --workspace --locked --no-run --timings | |
| - name: Run unit tests with default features | |
| run: timeout 10m cargo nextest run --cargo-profile ci-dev --no-fail-fast --all-targets --workspace --locked | |
| - name: Store timings with default features | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: timings-default-features | |
| path: target/cargo-timings/ | |
| if-no-files-found: warn | |
| clippy: | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.code == 'true' | |
| runs-on: ubuntu-24.04 | |
| env: | |
| MLIR_SYS_190_PREFIX: "/usr/lib/llvm-19" | |
| LLVM_SYS_191_PREFIX: "/usr/lib/llvm-19" | |
| TABLEGEN_190_PREFIX: "/usr/lib/llvm-19" | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
| - uses: arduino/setup-protoc@v3 | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: gerlero/add-apt-repository@v1 | |
| with: | |
| uri: http://apt.llvm.org/noble/ | |
| suite: llvm-toolchain-noble-19 | |
| key: https://apt.llvm.org/llvm-snapshot.gpg.key | |
| - uses: gerlero/apt-install@v1 | |
| with: | |
| packages: llvm-19 llvm-19-dev llvm-19-runtime clang-19 clang-tools-19 lld-19 libpolly-19-dev libmlir-19-dev mlir-19-tools | |
| - name: Clear cache | |
| if: github.event_name =='schedule' | |
| run: | | |
| cargo clean | |
| rm -rf ~/.cargo/registry | |
| rm -rf ~/.cargo/git | |
| - run: | | |
| cargo clippy --workspace --all-targets --all-features --locked -- -D warnings -D rust_2018_idioms | |
| cargo clippy --workspace --all-targets --locked -- -D warnings -D rust_2018_idioms | |
| cargo clippy --workspace --all-targets --all-features --locked --manifest-path crates/load-test/Cargo.toml -- -D warnings -D rust_2018_idioms | |
| rustfmt: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: dtolnay/rust-toolchain@nightly | |
| with: | |
| components: rustfmt | |
| - run: | | |
| cargo +nightly fmt --all -- --check | |
| cargo +nightly fmt --all --manifest-path crates/load-test/Cargo.toml -- --check | |
| doc: | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.code == 'true' | |
| runs-on: ubuntu-24.04 | |
| env: | |
| RUSTDOCFLAGS: "-D warnings" | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
| - uses: arduino/setup-protoc@v3 | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Clear cache | |
| if: github.event_name =='schedule' | |
| run: cargo clean | |
| - run: cargo doc --no-deps --document-private-items | |
| dep-sort: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: baptiste0928/cargo-install@v3 | |
| with: | |
| crate: cargo-sort | |
| version: "~2.0.2" | |
| - run: | | |
| cargo sort --check --workspace | |
| typos: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: crate-ci/typos@v1.26.0 | |
| with: | |
| files: . | |
| load_test: | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.code == 'true' | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: cargo check | |
| run: | | |
| cd crates/load-test | |
| cargo check | |
| # The Docker build excludes rust-toolchain.toml from its context, so the only thing | |
| # setting the build's Rust version is the base image tag in the Dockerfile. Guard | |
| # against the two drifting apart, which silently builds against the wrong toolchain. | |
| docker-rust-version: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Check Dockerfile Rust version matches rust-toolchain.toml | |
| run: | | |
| pin=$(grep -oP 'channel\s*=\s*"\K[^"]+' rust-toolchain.toml) | |
| img=$(grep -oP 'cargo-chef:.*-rust-\K[0-9]+\.[0-9]+\.[0-9]+' Dockerfile | head -1) | |
| if [ "$pin" != "$img" ]; then | |
| echo "::error::Dockerfile base image Rust ($img) does not match rust-toolchain.toml channel ($pin). Bump the cargo-chef image tag in the Dockerfile to rust-$pin." | |
| exit 1 | |
| fi | |
| echo "Rust version matches: $pin" | |
| required: | |
| needs: | |
| - test-all-features | |
| - test-consensus | |
| - test-default-features | |
| - clippy | |
| - rustfmt | |
| - doc | |
| - dep-sort | |
| - typos | |
| - load_test | |
| - docker-rust-version | |
| if: ${{ !cancelled() }} | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: On failure | |
| if: always() && contains(needs.*.result, 'failure') | |
| run: exit 1 |