feat: improve just bootstrap to be session-safe and consistent with C… #3
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
| # ============================================================================= | ||
| # ApexChainx Contracts — CI Pipeline | ||
| # ============================================================================= | ||
| name: CI | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| concurrency: | ||
| group: ci-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| client-checks: | ||
| name: Client Checks | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Install Rust | ||
| uses: dtolnay/rust-toolchain@stable | ||
| - name: Install Rust toolchain | ||
| uses: dtolnay/rust-toolchain@1.94.1 | ||
| with: | ||
| targets: wasm32-unknown-unknown | ||
| components: rustfmt, clippy | ||
| # Issue #207: Early no-std lint — scans Rust source for accidental `use | ||
| # std::` or `extern crate std` before the costly WASM compilation step. | ||
| # Runs fast (pure grep) and gives contributors a clear, file-level error. | ||
| - name: no_std compatibility lint (early gate) | ||
| run: ./scripts/check-no-std.sh | ||
| # Issue #12: WASM no-std compliance check. | ||
| # Compiles only the library crate for wasm32-unknown-unknown so that any | ||
| # accidental `std` import surfaces here (before deployment) as a compile | ||
| # error. Invokes the wasm32 compiler from the host runner via `cargo check`, | ||
| # which is cheaper than the `Build WASM` step below (metadata only, no codegen). | ||
| - name: WASM no-std compliance check | ||
| working-directory: apexchainx_calculator | ||
| run: | | ||
| cargo check --target wasm32-unknown-unknown --lib 2>&1 | tee no_std_check.log \ | ||
| || (echo "=== no_std compliance check failed: std imports are not allowed in WASM ===" \ | ||
| && cat no_std_check.log && exit 1) | ||
| - name: Debug environment | ||
| run: | | ||
| echo "=== Rust toolchain ===" | ||
| rustc --version | ||
| cargo --version | ||
| rustup show | ||
| echo "=== Project structure ===" | ||
| ls -la | ||
| ls -la apexchainx_calculator/ | ||
| echo "=== Cargo.toml ===" | ||
| cat apexchainx_calculator/Cargo.toml | ||
| - name: Cargo check | ||
| working-directory: apexchainx_calculator | ||
| run: | | ||
| cargo check 2>&1 | tee check.log || (echo "=== Cargo check failed ===" && cat check.log && exit 1) | ||
| - name: Format check | ||
| working-directory: apexchainx_calculator | ||
| run: | | ||
| cargo fmt -- --check --color=always 2>&1 | tee fmt_output.log | ||
| if [ ${PIPESTATUS[0]} -ne 0 ]; then | ||
| echo "" | ||
| echo "=== Formatting diff ===" | ||
| cargo fmt -- --check 2>&1 || true | ||
| git diff -- '*.rs' || true | ||
| echo "" | ||
| echo "Run 'cargo fmt' locally to fix." | ||
| exit 1 | ||
| fi | ||
| - name: Clippy | ||
| working-directory: apexchainx_calculator | ||
| run: cargo clippy --all-targets -- -D warnings | ||
| - name: Unused dependency gate | ||
| working-directory: apexchainx_calculator | ||
| run: | | ||
| cargo install cargo-machete --locked | ||
| cargo install cargo-udeps --locked | ||
| cargo machete | ||
| cargo udeps --all-targets | ||
| - name: Build native | ||
| working-directory: apexchainx_calculator | ||
| run: cargo build | ||
| - name: Build WASM | ||
| working-directory: apexchainx_calculator | ||
| run: cargo build --target wasm32-unknown-unknown | ||
| e2e-tests: | ||
| name: E2E Tests | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Install Rust | ||
| uses: dtolnay/rust-toolchain@stable | ||
| - name: Run tests | ||
| working-directory: apexchainx_calculator | ||
| run: cargo test --lib | ||
| # Issue #81: Normalize snapshot artifacts before upload so that volatile | ||
| # fields (timestamp, elapsed_ms, generated_at) are stripped and keys are | ||
| # sorted. This prevents noisy PR diffs caused by non-semantic changes. | ||
| - name: Normalize snapshot artifacts | ||
| run: npx --yes tsx tools/normalize-snapshots.ts | ||
| - name: Upload snapshot artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: sla-test-snapshots | ||
| path: apexchainx_calculator/test_snapshots/tests/ | ||
| retention-days: 30 | ||
| fuzz-tests: | ||
| name: Fuzz Tests (proptest) | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 2 | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Install Rust toolchain | ||
| uses: dtolnay/rust-toolchain@1.94.1 | ||
| - name: Cache cargo registry | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| apexchainx_calculator/target | ||
| key: fuzz-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
| restore-keys: | | ||
| fuzz-${{ runner.os }}-cargo- | ||
| - name: Run property-based fuzz tests | ||
| working-directory: apexchainx_calculator | ||
| run: cargo test --lib fuzz_tests:: | ||
| provenance-hashes: | ||
| name: Provenance & Hashes | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Install Rust | ||
| uses: dtolnay/rust-toolchain@1.94.1 | ||
| with: | ||
| targets: wasm32-unknown-unknown | ||
| - name: Build WASM release | ||
| working-directory: apexchainx_calculator | ||
| run: cargo build --target wasm32-unknown-unknown --release | ||
| - name: Generate hash | ||
| run: | | ||
| WASM=target/wasm32-unknown-unknown/release/apexchainx_calculator.wasm | ||
| if [ -f "$WASM" ]; then | ||
| sha256sum "$WASM" | awk '{print $1 " apexchainx_calculator.wasm"}' > provenance.sha256 | ||
| echo "Hash generated successfully" | ||
| cat provenance.sha256 | ||
| else | ||
| echo "WASM file not found at $WASM" | ||
| exit 1 | ||
| fi | ||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: pr-provenance-hash | ||
| path: provenance.sha256 | ||
| retention-days: 30 | ||