|
48 | 48 | - '**' |
49 | 49 | - '!**.md' |
50 | 50 |
|
| 51 | + # Everything else in CI runs on `stable` (see rust-toolchain.toml), so the MSRV |
| 52 | + # promised to downstream users needs its own gate. This job is the only place |
| 53 | + # the MSRV toolchain is used; it reads the version from the workspace |
| 54 | + # Cargo.toml so `rust-version` stays the single source of truth. |
| 55 | + # |
| 56 | + # Scope: build only, no `--all-targets`. The promise is that consumers can |
| 57 | + # *build* the published crates with the MSRV, not that our test suite runs |
| 58 | + # there — dev-dependencies are free to require a newer compiler. |
| 59 | + # |
| 60 | + # Linux-only: MSRV regressions almost always come from a dependency raising its |
| 61 | + # own `rust-version`, which is platform-independent. Running the full OS matrix |
| 62 | + # would triple the cost to catch only platform-gated regressions (e.g. a |
| 63 | + # windows-sys bump), which the stable `test` matrix would surface anyway once |
| 64 | + # the dependency reaches a release we build. |
| 65 | + msrv: |
| 66 | + name: MSRV build |
| 67 | + needs: changes |
| 68 | + if: needs.changes.outputs.src == 'true' |
| 69 | + runs-on: ubuntu-latest |
| 70 | + |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 73 | + |
| 74 | + - name: Read MSRV from Cargo.toml |
| 75 | + id: msrv |
| 76 | + run: | |
| 77 | + set -euo pipefail |
| 78 | + version=$(awk -F'"' '/^rust-version *=/ { print $2; exit }' Cargo.toml) |
| 79 | + if [ -z "$version" ]; then |
| 80 | + echo "::error file=Cargo.toml::could not parse rust-version" |
| 81 | + exit 1 |
| 82 | + fi |
| 83 | + echo "Detected MSRV: $version" |
| 84 | + echo "version=$version" >> "$GITHUB_OUTPUT" |
| 85 | +
|
| 86 | + - name: Remove the runner's bundled Rust toolchain |
| 87 | + run: rustup toolchain remove stable 2>/dev/null || true |
| 88 | + |
| 89 | + - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 |
| 90 | + with: |
| 91 | + toolchain: ${{ steps.msrv.outputs.version }} |
| 92 | + target: wasm32-unknown-unknown |
| 93 | + cache-shared-key: ${{ runner.os }}-msrv |
| 94 | + cache-bin: false |
| 95 | + rustflags: "" |
| 96 | + |
| 97 | + # ref-tests and ic-utils-bindgen-tests are the only `publish = false` |
| 98 | + # members; they depend on pocket-ic from the IC monorepo, whose MSRV runs |
| 99 | + # far ahead of ours. Excluding (rather than listing the published crates) |
| 100 | + # keeps a newly added published crate covered by default. |
| 101 | + - name: Build with MSRV |
| 102 | + run: | |
| 103 | + cargo build --locked --workspace \ |
| 104 | + --exclude ref-tests --exclude ic-utils-bindgen-tests |
| 105 | + cargo build --locked --workspace \ |
| 106 | + --exclude ref-tests --exclude ic-utils-bindgen-tests --all-features |
| 107 | +
|
| 108 | + # Browser consumers build ic-agent for wasm at the MSRV too; mirrors the |
| 109 | + # WASM step in lint.yml. |
| 110 | + - name: Build with MSRV (WASM) |
| 111 | + run: | |
| 112 | + CARGO_TARGET_DIR=target/wasm cargo build --locked --target wasm32-unknown-unknown \ |
| 113 | + -p ic-agent --features wasm-bindgen -p ic-utils |
| 114 | +
|
51 | 115 | # Workspace tests for every crate except ref-tests, on all three OSes. Because |
52 | 116 | # each crate is tested from its own directory, the heavy pocket-ic dependency |
53 | 117 | # (only used by ref-tests) never compiles here, keeping this job's cache small. |
@@ -199,17 +263,27 @@ jobs: |
199 | 263 |
|
200 | 264 | # CARGO_TARGET_DIR=target/wasm keeps wasm artifacts under ./target, so |
201 | 265 | # rust-cache (which caches ./target) still picks them up. |
| 266 | + # |
| 267 | + # --lib restricts this to the lib target's #[wasm_bindgen_test] tests. Newer |
| 268 | + # toolchains also run doctests for wasm targets (1.88 skipped them), and |
| 269 | + # ic-agent's doctests cannot compile there: they use #[tokio::main], and |
| 270 | + # tokio is deliberately a dev-dependency only under |
| 271 | + # cfg(not(target_family = "wasm")). Doctests are covered on the host by the |
| 272 | + # `test` job above; running them inside a headless browser adds nothing. |
202 | 273 | - name: Run Tests (WASM) |
203 | | - run: CARGO_TARGET_DIR=target/wasm wasm-pack test --chrome --headless ic-agent --features wasm-bindgen |
| 274 | + run: CARGO_TARGET_DIR=target/wasm wasm-pack test --chrome --headless ic-agent --features wasm-bindgen --lib |
204 | 275 |
|
205 | 276 | aggregate: |
206 | 277 | name: test:required |
207 | 278 | # Runs only when the test jobs ran; on docs-only changes this skips, and a |
208 | 279 | # skipped required check counts as passing for branch protection. |
209 | 280 | if: always() && needs.changes.outputs.src == 'true' |
210 | 281 | runs-on: ubuntu-latest |
211 | | - needs: [changes, test, ref_tests, wasm] |
| 282 | + needs: [changes, msrv, test, ref_tests, wasm] |
212 | 283 | steps: |
| 284 | + - name: Check MSRV result |
| 285 | + if: ${{ needs.msrv.result != 'success' }} |
| 286 | + run: exit 1 |
213 | 287 | - name: Check test result |
214 | 288 | if: ${{ needs.test.result != 'success' }} |
215 | 289 | run: exit 1 |
|
0 commit comments