|
85 | 85 | - name: 📂 Checkout code |
86 | 86 | uses: actions/checkout@v6 |
87 | 87 |
|
88 | | - - name: Install cargo-insta |
89 | | - uses: baptiste0928/cargo-install@v3 |
90 | | - with: |
91 | | - crate: cargo-insta |
92 | | - version: "=1.46.3" |
93 | | - |
94 | | - - name: Install cargo-nextest |
95 | | - uses: baptiste0928/cargo-install@v3 |
96 | | - with: |
97 | | - crate: cargo-nextest |
98 | | - version: "=0.9.132" |
99 | | - |
100 | | - - name: 💰 Cache |
101 | | - uses: Swatinem/rust-cache@v2 |
102 | | - |
103 | | - - name: Install shells (zsh, fish) - Ubuntu |
104 | | - if: runner.os == 'Linux' |
105 | | - uses: awalsh128/cache-apt-pkgs-action@latest |
106 | | - with: |
107 | | - packages: zsh fish |
108 | | - version: 1.0 |
109 | | - |
110 | | - - name: Install shells (fish) - macOS |
111 | | - if: runner.os == 'macOS' |
112 | | - run: | |
113 | | - brew install fish |
114 | | - # bash and zsh are pre-installed on macOS |
115 | | -
|
116 | | - - name: Install nushell |
117 | | - if: runner.os != 'Windows' |
118 | | - uses: hustcer/setup-nu@v3 |
119 | | - with: |
120 | | - version: '0.112.2' |
121 | | - |
122 | | - - name: Install shells - Windows |
123 | | - if: runner.os == 'Windows' |
124 | | - run: | |
125 | | - # Git Bash is pre-installed on GitHub Actions Windows runners |
126 | | - # Fish, zsh, and nushell are not commonly available on native Windows (require WSL/MSYS2) |
127 | | - # CI will test with bash only on Windows (tests skip unavailable shells) |
128 | | - echo "Using Git Bash for Windows tests" |
129 | | - shell: pwsh |
| 88 | + - uses: ./.github/actions/test-setup |
130 | 89 |
|
131 | 90 | - name: Install wt |
132 | 91 | uses: baptiste0928/cargo-install@v3 |
@@ -237,7 +196,7 @@ jobs: |
237 | 196 | uses: actions/checkout@v6 |
238 | 197 |
|
239 | 198 | - name: Setup Zola |
240 | | - uses: taiki-e/[email protected].22 |
| 199 | + uses: taiki-e/[email protected].27 |
241 | 200 | with: |
242 | 201 | |
243 | 202 |
|
@@ -276,6 +235,120 @@ jobs: |
276 | 235 | - name: 📊 Run benchmarks |
277 | 236 | run: cargo bench |
278 | 237 |
|
| 238 | + # cargo-affected: runs only the tests whose recorded coverage overlaps the |
| 239 | + # diff. Advisory at this stage — `test (linux/macos/windows)` still runs the |
| 240 | + # full suite. The signal is the runtime delta on the exact-match path and |
| 241 | + # whether selection misses any failures the full suite catches. |
| 242 | + # |
| 243 | + # TODO: once cargo-affected is trusted on this repo, gate the full test |
| 244 | + # matrix to run only on pushes to main and on PRs with a `full-tests` label |
| 245 | + # (or similar). PR pushes would default to affected-only. The full suite |
| 246 | + # could fold into the existing `nightly` workflow, which already hosts |
| 247 | + # slower integration-time checks. Periodic full runs remain essential — |
| 248 | + # cargo-affected misses non-Rust inputs (`include_str!`, templates, SQL), |
| 249 | + # build-time inputs not in its fingerprint (build.rs, rust-toolchain.toml, |
| 250 | + # .cargo/config.toml), and proc-macro source edits. |
| 251 | + # |
| 252 | + # Cache strategy: |
| 253 | + # - `collect-affected` (push to main) saves `target/affected/` to |
| 254 | + # actions/cache keyed on the main commit sha. |
| 255 | + # - `affected-tests` (PRs) restores the cache. Primary key is the |
| 256 | + # PR/main merge-base — when collect ran on that exact commit, we get a |
| 257 | + # tight diff (`PR changes only`) and the smallest possible selection. |
| 258 | + # - Restore-keys fall back to the most recent main DB. Its `collect_sha` |
| 259 | + # may be ahead of the merge-base; cargo-affected handles that by running |
| 260 | + # all tests with a notice (no `Diverged` bail), so the fallback always |
| 261 | + # produces a useful run, just with broader selection. |
| 262 | + # - Cache keys include `runner.os` (fingerprint embeds `rustc -vV`) and a |
| 263 | + # manual `db-v{N}` marker. Bump the marker if cargo-affected ships an |
| 264 | + # on-disk schema change; the cache is otherwise version-agnostic. |
| 265 | + collect-affected: |
| 266 | + name: collect affected coverage |
| 267 | + if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch' }} |
| 268 | + runs-on: ubuntu-24.04 |
| 269 | + steps: |
| 270 | + - name: 📂 Checkout code |
| 271 | + uses: actions/checkout@v6 |
| 272 | + with: |
| 273 | + # `cargo affected run` later diffs PR HEAD against the sha that was |
| 274 | + # HEAD when collect ran. That sha must be reachable. |
| 275 | + fetch-depth: 0 |
| 276 | + |
| 277 | + - uses: ./.github/actions/test-setup |
| 278 | + |
| 279 | + - name: Install cargo-affected |
| 280 | + uses: baptiste0928/cargo-install@v3 |
| 281 | + with: |
| 282 | + crate: cargo-affected |
| 283 | + git: https://github.com/max-sixty/cargo-affected |
| 284 | + # No rev/branch/tag → action resolves to latest default-branch sha. |
| 285 | + |
| 286 | + - name: Install llvm-tools |
| 287 | + run: rustup component add llvm-tools |
| 288 | + |
| 289 | + - name: 📊 Collect coverage data |
| 290 | + env: |
| 291 | + NEXTEST_NO_INPUT_HANDLER: 1 |
| 292 | + run: cargo affected collect --features shell-integration-tests |
| 293 | + |
| 294 | + - name: 💾 Save coverage DB |
| 295 | + uses: actions/cache/save@v5 |
| 296 | + with: |
| 297 | + path: target/affected |
| 298 | + key: cargo-affected-db-v1-${{ runner.os }}-${{ github.sha }} |
| 299 | + |
| 300 | + affected-tests: |
| 301 | + name: affected tests (linux, advisory) |
| 302 | + if: github.event_name == 'pull_request' |
| 303 | + runs-on: ubuntu-24.04 |
| 304 | + # Advisory while we calibrate selection accuracy against the full suite. |
| 305 | + # The full matrix (`test (linux/macos/windows)`) is still required for |
| 306 | + # merge. |
| 307 | + continue-on-error: true |
| 308 | + steps: |
| 309 | + - name: 📂 Checkout code |
| 310 | + uses: actions/checkout@v6 |
| 311 | + with: |
| 312 | + # Need the cached `collect_sha` reachable from HEAD for the diff; |
| 313 | + # see collect-affected above. |
| 314 | + fetch-depth: 0 |
| 315 | + |
| 316 | + - name: Compute merge-base for cache key |
| 317 | + id: mb |
| 318 | + env: |
| 319 | + PR_HEAD: ${{ github.event.pull_request.head.sha }} |
| 320 | + run: | |
| 321 | + git fetch --no-tags --depth=200 origin main |
| 322 | + sha=$(git merge-base origin/main "$PR_HEAD") |
| 323 | + echo "sha=$sha" >> "$GITHUB_OUTPUT" |
| 324 | + echo "merge-base with origin/main: $sha" |
| 325 | +
|
| 326 | + - name: 💾 Restore coverage DB |
| 327 | + uses: actions/cache/restore@v5 |
| 328 | + with: |
| 329 | + path: target/affected |
| 330 | + # Exact match: collect ran on the PR's merge-base → tight diff. |
| 331 | + key: cargo-affected-db-v1-${{ runner.os }}-${{ steps.mb.outputs.sha }} |
| 332 | + # Fallback: most recent main DB. cargo-affected runs all tests when |
| 333 | + # collect_sha isn't an ancestor of HEAD; with no DB at all it does |
| 334 | + # the same. Either way the run produces a useful signal. |
| 335 | + restore-keys: | |
| 336 | + cargo-affected-db-v1-${{ runner.os }}- |
| 337 | +
|
| 338 | + - uses: ./.github/actions/test-setup |
| 339 | + |
| 340 | + - name: Install cargo-affected |
| 341 | + uses: baptiste0928/cargo-install@v3 |
| 342 | + with: |
| 343 | + crate: cargo-affected |
| 344 | + git: https://github.com/max-sixty/cargo-affected |
| 345 | + # No rev/branch/tag → action resolves to latest default-branch sha. |
| 346 | + |
| 347 | + - name: 🎯 Run affected tests |
| 348 | + env: |
| 349 | + NEXTEST_NO_INPUT_HANDLER: 1 |
| 350 | + run: cargo affected run --features shell-integration-tests --verbose |
| 351 | + |
279 | 352 | code-coverage: |
280 | 353 | runs-on: ubuntu-24.04 |
281 | 354 | steps: |
|
0 commit comments