|
2 | 2 | # ApexChainx Contracts — CI Pipeline |
3 | 3 | # ============================================================================= |
4 | 4 | # |
5 | | -# Triggered on: |
6 | | -# - Push to main branch |
7 | | -# - Pull requests targeting main |
| 5 | +# Triggered on push/PR to main. Runs the essential checks: |
| 6 | +# 1. Formatting (rustfmt) |
| 7 | +# 2. Linting (clippy) |
| 8 | +# 3. Tests (cargo test) |
| 9 | +# 4. no-std (cargo check --target wasm32-unknown-unknown --lib) |
8 | 10 | # |
9 | | -# Pipeline stages: |
10 | | -# 1. Code Quality — rustfmt formatting check |
11 | | -# 2. Static Analysis — clippy linting (no warnings allowed) |
12 | | -# 3. Unit & Integration Tests — cargo test (full suite) |
13 | | -# 4. WASM Build — release build for wasm32 target |
14 | | -# 5. no-std Compliance — verify no standard library usage |
15 | | -# 6. Binary Size Check — enforce contract size budget (100 KB soft limit) |
16 | | -# |
17 | | -# Reference: |
18 | | -# - SC-077: WASM target compilation verification |
19 | | -# - SC-044: no-std compliance enforcement |
20 | | -# - SC-078: Contract binary size monitoring |
| 11 | +# The no-std check verifies WASM compilation and catches accidental std |
| 12 | +# imports (e.g. std::vec, std::string, println!) that would compile in |
| 13 | +# tests yet fail at deployment. |
21 | 14 | # ============================================================================= |
22 | 15 |
|
23 | 16 | name: CI |
@@ -46,70 +39,19 @@ jobs: |
46 | 39 | components: rustfmt, clippy |
47 | 40 | targets: wasm32-unknown-unknown |
48 | 41 |
|
49 | | - # -------------------------------------------------------------------- |
50 | | - # Dependency Caching |
51 | | - # -------------------------------------------------------------------- |
52 | | - # Speeds up subsequent runs by caching compiled dependencies. |
53 | | - # Cache key is automatically derived from Cargo.lock. |
54 | 42 | - name: Cache Cargo dependencies |
55 | 43 | uses: Swatinem/rust-cache@v2 |
56 | 44 | with: |
57 | 45 | workspaces: apexchainx_calculator |
58 | 46 |
|
59 | | - # -------------------------------------------------------------------- |
60 | | - # Step 1: Code Formatting |
61 | | - # -------------------------------------------------------------------- |
62 | | - # Enforces consistent code style via rustfmt. Fails if any file |
63 | | - # deviates from the configured formatting rules. |
64 | | - - name: Check Rust formatting |
| 47 | + - name: Check formatting |
65 | 48 | run: cargo fmt --manifest-path apexchainx_calculator/Cargo.toml -- --check |
66 | 49 |
|
67 | | - # -------------------------------------------------------------------- |
68 | | - # Step 2: Static Analysis |
69 | | - # -------------------------------------------------------------------- |
70 | | - # Runs Clippy with -D warnings (deny-level). Any lint warning |
71 | | - # will fail the build. This ensures no warnings are introduced. |
72 | | - - name: Clippy static analysis |
73 | | - run: cargo clippy --manifest-path apexchainx_calculator/Cargo.toml -- -D warnings |
| 50 | + - name: Clippy linting |
| 51 | + run: cargo clippy --manifest-path apexchainx_calculator/Cargo.toml |
74 | 52 |
|
75 | | - # -------------------------------------------------------------------- |
76 | | - # Step 3: Test Suite |
77 | | - # -------------------------------------------------------------------- |
78 | | - # Executes the full test suite including unit tests, integration |
79 | | - # tests, and golden vector snapshot generation. |
80 | | - - name: Run test suite |
| 53 | + - name: Run tests |
81 | 54 | run: cargo test --manifest-path apexchainx_calculator/Cargo.toml |
82 | 55 |
|
83 | | - # -------------------------------------------------------------------- |
84 | | - # Step 4: WASM Build (SC-077) |
85 | | - # -------------------------------------------------------------------- |
86 | | - # Verifies the crate compiles for wasm32-unknown-unknown target, |
87 | | - # which is required for Soroban contract deployment on Stellar. |
88 | | - - name: Build release WASM |
89 | | - run: cargo build --release --manifest-path apexchainx_calculator/Cargo.toml --target wasm32-unknown-unknown |
90 | | - |
91 | | - # -------------------------------------------------------------------- |
92 | | - # Step 5: no-std Compliance Check (SC-044) |
93 | | - # -------------------------------------------------------------------- |
94 | | - # Soroban contracts run in a WASM sandbox with no standard library. |
95 | | - # This check compiles only the library crate (not tests) for |
96 | | - # wasm32-unknown-unknown, which has no std. Catches accidental |
97 | | - # std imports (e.g. std::vec, std::string, println!) that would |
98 | | - # compile fine in tests yet fail at deployment. |
99 | | - - name: no-std compliance check |
| 56 | + - name: no-std compliance (WASM check) |
100 | 57 | run: cargo check --manifest-path apexchainx_calculator/Cargo.toml --target wasm32-unknown-unknown --lib |
101 | | - |
102 | | - # -------------------------------------------------------------------- |
103 | | - # Step 6: Binary Size Check (SC-078) |
104 | | - # -------------------------------------------------------------------- |
105 | | - # Enforces a 100 KB soft limit on the release WASM binary. |
106 | | - # Exceeding this limit produces a CI warning for review. |
107 | | - - name: Check contract binary size |
108 | | - run: | |
109 | | - WASM=apexchainx_calculator/target/wasm32-unknown-unknown/release/apexchainx_calculator.wasm |
110 | | - SIZE=$(wc -c < "$WASM") |
111 | | - echo "Contract size: ${SIZE} bytes" |
112 | | - MAX=102400 # 100 KB soft limit (SC-078) |
113 | | - if [ "$SIZE" -gt "$MAX" ]; then |
114 | | - echo "::warning::Contract binary (${SIZE}B) exceeds soft limit of ${MAX}B" |
115 | | - fi |
0 commit comments