test new ci #2
Workflow file for this run
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-Tests-Optimized | |
| # This is a test optimization workflow that runs tests more efficiently | |
| # It does NOT build Docker images or upload any artifacts | |
| # Safe to test on PRs without affecting production | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| types: [opened, reopened, synchronize, edited] | |
| env: | |
| RUSTFLAGS: "-D warnings -C link-arg=-fuse-ld=lld" | |
| RUST_BACKTRACE: 1 | |
| CARGO_TERM_COLOR: always | |
| CARGO_INCREMENTAL: 0 | |
| NEXTEST_RETRIES: 2 | |
| # Unique concurrency group to not interfere with existing workflows | |
| concurrency: | |
| group: ci-tests-only-${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'pull_request' && 'PR' || github.sha }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| # Quick checks that should pass before running expensive tests | |
| quick-checks: | |
| name: Quick Checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' }} | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| - name: Check Cargo.lock | |
| run: | | |
| cargo update -w --locked | |
| git diff --exit-code Cargo.lock | |
| - name: Install cargo-machete | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-machete | |
| - name: Check unused dependencies | |
| run: cargo machete | |
| - name: Install taplo | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: taplo-cli | |
| - name: Check TOML formatting | |
| run: taplo fmt --check | |
| # Detect which files changed to optimize what we test | |
| detect-changes: | |
| name: Detect Changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| rust-changed: ${{ steps.filter.outputs.rust }} | |
| blockifier-changed: ${{ steps.filter.outputs.blockifier }} | |
| papyrus-changed: ${{ steps.filter.outputs.papyrus }} | |
| committer-changed: ${{ steps.filter.outputs.committer }} | |
| sequencer-changed: ${{ steps.filter.outputs.sequencer }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| rust: | |
| - '**/*.rs' | |
| - '**/Cargo.toml' | |
| - 'Cargo.lock' | |
| - 'rust-toolchain.toml' | |
| blockifier: | |
| - 'crates/blockifier/**' | |
| - 'crates/blockifier_test_utils/**' | |
| - 'crates/native_blockifier/**' | |
| papyrus: | |
| - 'crates/papyrus**/**' | |
| committer: | |
| - 'crates/starknet_committer/**' | |
| - 'crates/starknet_patricia/**' | |
| sequencer: | |
| - 'crates/apollo**/**' | |
| # Generate test matrix dynamically based on workspace crates | |
| generate-test-matrix: | |
| name: Generate Test Matrix | |
| runs-on: ubuntu-latest | |
| needs: [quick-checks, detect-changes] | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Generate crate matrix | |
| id: set-matrix | |
| run: | | |
| # Get all workspace members | |
| CRATES=$(cargo metadata --no-deps --format-version 1 | jq -r '.workspace_members[] | split(" ") | .[0]') | |
| # Convert to JSON array | |
| MATRIX=$(echo "$CRATES" | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
| echo "matrix=$MATRIX" >> $GITHUB_OUTPUT | |
| echo "Generated matrix with $(echo "$CRATES" | wc -l) crates" | |
| # Run clippy and tests for each crate in parallel | |
| test: | |
| name: Test ${{ matrix.crate }} | |
| runs-on: ubuntu-latest | |
| needs: [generate-test-matrix, detect-changes] | |
| if: needs.detect-changes.outputs.rust-changed == 'true' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| crate: ${{ fromJson(needs.generate-test-matrix.outputs.matrix) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' }} | |
| - name: Install nextest | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-nextest | |
| # Install Python for crates that need it (OS compilation) | |
| - name: Setup Python (if needed) | |
| if: contains(matrix.crate, 'starknet_os') || contains(matrix.crate, 'blockifier') | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: 'pypy3.9' | |
| cache: 'pip' | |
| - name: Install Python dependencies (if needed) | |
| if: contains(matrix.crate, 'starknet_os') || contains(matrix.crate, 'blockifier') | |
| run: | | |
| pip install -r scripts/requirements.txt | |
| ln -s $(which pypy3.9) /usr/local/bin/pypy3.9 || true | |
| - name: Run clippy | |
| run: | | |
| cargo clippy -p ${{ matrix.crate }} --all-targets --all-features -- -D warnings | |
| - name: Run tests | |
| run: | | |
| cargo nextest run -p ${{ matrix.crate }} --retries ${{ env.NEXTEST_RETRIES }} | |
| env: | |
| RUST_LOG: warn | |
| SEED: 0 | |
| # Workspace compilation, docs, and tests (share compilation cache) | |
| workspace-checks: | |
| name: Workspace Checks | |
| runs-on: ubuntu-latest | |
| needs: quick-checks | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' }} | |
| # First, run clippy on the entire workspace to get all compilation done | |
| - name: Run workspace clippy | |
| run: cargo clippy --workspace --all-targets --all-features -- -D warnings | |
| # Now docs can reuse the compilation artifacts | |
| - name: Build documentation | |
| run: cargo doc --workspace --no-deps --document-private-items | |
| env: | |
| RUSTDOCFLAGS: "-D warnings" | |
| # And workspace tests also reuse the cache | |
| - name: Run workspace tests | |
| run: cargo test -p workspace_tests | |
| # Test specific feature combinations for key crates | |
| test-features: | |
| name: Test Features | |
| runs-on: ubuntu-latest | |
| needs: [quick-checks, detect-changes] | |
| if: needs.detect-changes.outputs.blockifier-changed == 'true' | |
| strategy: | |
| matrix: | |
| include: | |
| - crate: blockifier | |
| features: "" | |
| - crate: blockifier | |
| features: "--features transaction_serde" | |
| - crate: blockifier | |
| features: "--features cairo_native" | |
| - crate: blockifier | |
| features: "--features tracing" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' }} | |
| - name: Install nextest | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-nextest | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: 'pypy3.9' | |
| cache: 'pip' | |
| - name: Install Python dependencies | |
| run: | | |
| pip install -r scripts/requirements.txt | |
| ln -s $(which pypy3.9) /usr/local/bin/pypy3.9 || true | |
| - name: Test with features | |
| run: | | |
| cargo nextest run -p ${{ matrix.crate }} ${{ matrix.features }} --retries ${{ env.NEXTEST_RETRIES }} | |
| # Integration tests (run separately as they're slower) | |
| integration-tests: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| needs: [quick-checks, detect-changes] | |
| if: needs.detect-changes.outputs.sequencer-changed == 'true' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' }} | |
| - name: Install nextest | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-nextest | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: 'pypy3.9' | |
| cache: 'pip' | |
| - name: Install Python dependencies | |
| run: | | |
| pip install -r scripts/requirements.txt | |
| ln -s $(which pypy3.9) /usr/local/bin/pypy3.9 || true | |
| # Build all binaries together to maximize cache sharing | |
| - name: Build integration test binaries | |
| run: | | |
| cargo build --bins -p apollo_node -p apollo_integration_tests || true | |
| # Run integration tests | |
| - name: Run integration tests | |
| run: | | |
| # Run available integration test binaries | |
| for test in integration_test_positive_flow integration_test_restart_flow integration_test_revert_flow; do | |
| if [ -f "target/debug/$test" ]; then | |
| echo "Running $test..." | |
| "./target/debug/$test" || true | |
| fi | |
| done | |
| # Run integration tests via nextest as well | |
| cargo nextest run -p apollo_integration_tests || true | |
| # Papyrus-specific tests | |
| papyrus-tests: | |
| name: Papyrus Tests | |
| runs-on: ubuntu-latest | |
| needs: [quick-checks, detect-changes] | |
| if: needs.detect-changes.outputs.papyrus-changed == 'true' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' }} | |
| - name: Build Papyrus | |
| run: | | |
| mkdir -p data | |
| cargo build -p papyrus_node | |
| - name: Test Papyrus startup | |
| run: | | |
| timeout 30s target/debug/papyrus_node --chain_id SN_SEPOLIA --base_layer.node_url ${{ secrets.CI_BASE_LAYER_NODE_URL }} || [ $? -eq 124 ] | |
| - name: Run Papyrus integration tests | |
| run: | | |
| cargo test --test latency_histogram --test gateway_integration_test --test feeder_gateway_integration_test -- --include-ignored --skip test_gw_integration_testnet | |
| cargo run -p papyrus_node --bin central_source_integration_test --features="futures-util tokio-stream" || true | |
| # Final status check | |
| ci-success: | |
| name: CI Success | |
| needs: [quick-checks, test, test-features, integration-tests, workspace-checks, papyrus-tests] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check all jobs | |
| run: | | |
| if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then | |
| echo "One or more jobs failed" | |
| exit 1 | |
| else | |
| echo "All jobs succeeded" | |
| fi |