diff --git a/.github/workflows/rust-ci.yaml b/.github/workflows/rust-ci.yaml index 6ee544939..31b9a9657 100644 --- a/.github/workflows/rust-ci.yaml +++ b/.github/workflows/rust-ci.yaml @@ -12,41 +12,69 @@ on: branches: - main +env: + CARGO_INCREMENTAL: 0 + CARGO_PROFILE_DEV_DEBUG: 0 + CARGO_PROFILE_TEST_DEBUG: 0 + CARGO_TERM_COLOR: always + jobs: - rust_ci: - name: Build & Test + lint: + name: Format & Clippy runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: components: rustfmt, clippy + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - name: Rust fmt + run: cargo fmt --all -- --check + - name: Rust clippy + run: cargo clippy --workspace --all-targets -- -D warnings + + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - name: Install cargo-nextest + uses: taiki-e/install-action@nextest + # Regenerate Cairo reference data when Cairo/SDK files changed or on push to main (rebase) + - name: Check for Cairo/SDK changes + id: cairo-check + if: github.event_name == 'pull_request' + uses: dorny/paths-filter@v3 + with: + filters: | + changed: + - 'packages/**' + - 'sdk/**' + - 'Scarb.toml' + - 'Scarb.lock' - uses: actions/setup-node@v4 + if: github.event_name == 'push' || steps.cairo-check.outputs.changed == 'true' with: node-version: '20' cache: 'npm' cache-dependency-path: sdk/package-lock.json - - name: Install Scarb + if: github.event_name == 'push' || steps.cairo-check.outputs.changed == 'true' uses: software-mansion/setup-scarb@v1 with: scarb-version: "2.15.0" - - name: Install snforge + if: github.event_name == 'push' || steps.cairo-check.outputs.changed == 'true' uses: foundry-rs/setup-snfoundry@v3 - - - name: Rust fmt - run: cargo fmt --all -- --check - - - name: Rust clippy - run: cargo clippy --workspace --all-targets -- -D warnings - - - name: Rust build - run: cargo build --workspace --all-targets - - name: Generate Cairo reference data + if: github.event_name == 'push' || steps.cairo-check.outputs.changed == 'true' run: | cd sdk npm run generate:cairo-refs @@ -55,7 +83,7 @@ jobs: - name: Install starknet-devnet via asdf uses: asdf-vm/actions/install@v3 with: - tool_versions: starknet-devnet 0.7.1 + tool_versions: starknet-devnet 0.7.2 - name: Rust test - run: cargo test --workspace --all-targets + run: cargo nextest run --workspace --all-targets