|
| 1 | +name: Contract MSRV |
| 2 | + |
| 3 | +# Optional second job: verify the workspace compiles and all tests pass on the |
| 4 | +# declared Minimum Supported Rust Version (MSRV) without requiring the Stellar |
| 5 | +# CLI or any network access. Runs on every PR that touches contract code and |
| 6 | +# on pushes to main/develop. |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: [main, develop] |
| 11 | + paths: |
| 12 | + - 'contract/**' |
| 13 | + - '.github/workflows/contract-msrv.yml' |
| 14 | + pull_request: |
| 15 | + branches: [main, develop] |
| 16 | + paths: |
| 17 | + - 'contract/**' |
| 18 | + - '.github/workflows/contract-msrv.yml' |
| 19 | + |
| 20 | +env: |
| 21 | + CARGO_TERM_COLOR: always |
| 22 | + RUST_BACKTRACE: 1 |
| 23 | + # Keep incremental compilation off so the MSRV build is hermetic. |
| 24 | + CARGO_INCREMENTAL: 0 |
| 25 | + |
| 26 | +jobs: |
| 27 | + msrv: |
| 28 | + name: Contract MSRV (Rust ${{ matrix.rust }}) |
| 29 | + runs-on: ubuntu-latest |
| 30 | + timeout-minutes: 30 |
| 31 | + |
| 32 | + strategy: |
| 33 | + fail-fast: false |
| 34 | + matrix: |
| 35 | + # Primary MSRV declared in contract/Cargo.toml [workspace.package]. |
| 36 | + # Add additional entries here when you want to test a range, e.g.: |
| 37 | + # rust: ['1.74', '1.75', 'stable'] |
| 38 | + rust: ['1.74'] |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Checkout |
| 42 | + uses: actions/checkout@v4 |
| 43 | + |
| 44 | + # ── Cargo cache ──────────────────────────────────────────────────────── |
| 45 | + - name: Cache Cargo registry |
| 46 | + uses: actions/cache@v4 |
| 47 | + with: |
| 48 | + path: | |
| 49 | + ~/.cargo/registry/index |
| 50 | + ~/.cargo/registry/cache |
| 51 | + ~/.cargo/git/db |
| 52 | + ~/.cargo/git/checkouts |
| 53 | + key: ${{ runner.os }}-cargo-registry-msrv-${{ matrix.rust }}-${{ hashFiles('contract/Cargo.lock') }} |
| 54 | + restore-keys: | |
| 55 | + ${{ runner.os }}-cargo-registry-msrv-${{ matrix.rust }}- |
| 56 | + ${{ runner.os }}-cargo-registry-msrv- |
| 57 | +
|
| 58 | + - name: Cache Cargo target (MSRV) |
| 59 | + uses: actions/cache@v4 |
| 60 | + with: |
| 61 | + path: contract/target |
| 62 | + key: ${{ runner.os }}-contract-target-msrv-${{ matrix.rust }}-${{ hashFiles('contract/Cargo.lock') }} |
| 63 | + restore-keys: | |
| 64 | + ${{ runner.os }}-contract-target-msrv-${{ matrix.rust }}- |
| 65 | +
|
| 66 | + # ── Toolchain ────────────────────────────────────────────────────────── |
| 67 | + # Install the exact MSRV toolchain. No Stellar CLI is installed here; |
| 68 | + # the test suite uses soroban-sdk testutils (pure Rust, no CLI needed). |
| 69 | + - name: Install Rust ${{ matrix.rust }} |
| 70 | + uses: dtolnay/rust-toolchain@master |
| 71 | + with: |
| 72 | + toolchain: ${{ matrix.rust }} |
| 73 | + |
| 74 | + # Confirm the active toolchain matches what we requested. |
| 75 | + - name: Show toolchain info |
| 76 | + run: | |
| 77 | + rustc --version |
| 78 | + cargo --version |
| 79 | + working-directory: contract |
| 80 | + |
| 81 | + # ── Verify declared MSRV matches installed toolchain ────────────────── |
| 82 | + # `cargo check` with --locked ensures the Cargo.lock is respected and |
| 83 | + # that the rust-version field in Cargo.toml is honoured. |
| 84 | + - name: Verify MSRV field is respected (cargo check) |
| 85 | + run: cargo check --locked --all-targets |
| 86 | + working-directory: contract |
| 87 | + |
| 88 | + # ── Tests (no Stellar CLI, no network) ──────────────────────────────── |
| 89 | + # Run the full test suite. soroban-sdk testutils are pure-Rust and do |
| 90 | + # not require the Stellar CLI or any external service. |
| 91 | + - name: Run contract tests on MSRV |
| 92 | + run: cargo test --locked --all-features 2>&1 | tee /tmp/msrv-test-output.txt |
| 93 | + working-directory: contract |
| 94 | + |
| 95 | + # ── Step summary ────────────────────────────────────────────────────── |
| 96 | + - name: Write step summary |
| 97 | + if: always() |
| 98 | + run: | |
| 99 | + echo "## Contract MSRV – Rust ${{ matrix.rust }}" >> $GITHUB_STEP_SUMMARY |
| 100 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 101 | + echo "| Check | Result |" >> $GITHUB_STEP_SUMMARY |
| 102 | + echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY |
| 103 | + if cargo check --locked --all-targets 2>/dev/null; then |
| 104 | + echo "| \`cargo check\` | ✅ |" >> $GITHUB_STEP_SUMMARY |
| 105 | + else |
| 106 | + echo "| \`cargo check\` | ❌ |" >> $GITHUB_STEP_SUMMARY |
| 107 | + fi |
| 108 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 109 | + echo "### Test output (last 30 lines)" >> $GITHUB_STEP_SUMMARY |
| 110 | + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |
| 111 | + tail -30 /tmp/msrv-test-output.txt 2>/dev/null || echo "(no output captured)" >> $GITHUB_STEP_SUMMARY |
| 112 | + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |
| 113 | + working-directory: contract |
0 commit comments