Merge branch 'main' into feat/issue-255-result-schema-migration-guard #4
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 #255: Result schema migration guardrail. | ||
| # schema_migration_tests.rs contains a compile-time exhaustive SLAResult | ||
| # destructure and runtime assertions that RESULT_SCHEMA_VERSION and | ||
| # RESULT_SCHEMA_FIELD_COUNT match the actual struct layout and the values | ||
| # returned by get_result_schema(). Any PR that modifies SLAResult without | ||
| # updating both constants will fail here. | ||
| # See: docs/result-schema-migration-guard.md | ||
| - name: Result schema migration guard | ||
| working-directory: apexchainx_calculator | ||
| run: cargo test --lib schema_migration_tests | ||
| # 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:: | ||
| parity-check: | ||
| name: Parity Check (canonical baseline) | ||
| runs-on: ubuntu-latest | ||
| # This job is a release gate: it verifies that the current compute_result | ||
| # implementation produces identical outputs to the locked-in historical | ||
| # golden vectors in test_snapshots/tests/parity_baseline.json. | ||
| # A failure here means a calculation regression has been introduced and | ||
| # must be reviewed before merging or cutting a release. | ||
| 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: parity-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
| restore-keys: | | ||
| parity-${{ runner.os }}-cargo- | ||
| - name: Run parity checker against canonical baseline | ||
| working-directory: apexchainx_calculator | ||
| run: cargo test --lib parity_tests:: | ||
| - name: Upload parity baseline as artifact (for release traceability) | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: parity-baseline | ||
| path: apexchainx_calculator/test_snapshots/tests/parity_baseline.json | ||
| retention-days: 90 | ||
| 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: Install just | ||
| run: cargo install just | ||
| - name: Generate and save hash | ||
| run: just hash-save | ||
| - name: Verify hash against committed file | ||
| run: just hash-verify | ||
| continue-on-error: true | ||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: pr-provenance-hash | ||
| path: artifacts/apexchainx_calculator.wasm.sha256 | ||
| retention-days: 30 | ||