From 2452513b658372723b8c1da30fdc5fda4c284341 Mon Sep 17 00:00:00 2001 From: bherbruck Date: Sun, 18 Oct 2026 23:39:00 +0000 Subject: [PATCH] CI: faster test shards - Pull requests that can change a robustness golden check every seed but the 17 slowest, in the same nextest run as the other tests instead of a second step after it (16-30 minutes on its own). The slow seeds (about four fifths of the goldens' time) still run in the merge queue, on main and nightly. A failed golden still prints how to re-record it, and junit.xml now holds the whole run. - The slowest tests start first (nextest priority), so a shard no longer ends with one of them running alone. - tspline::tests::hostile_tsplines_never_panic joins the heavy tests pull requests skip (up to 12 minutes on a GitHub runner; the same kind of check as hostile_params_never_panic). - The ci profile builds dependencies without line tables: the test archive pull requests' shards download goes from 3.4 GB to 2.2 GB. Co-Authored-By: Claude Opus 5.5 --- .config/nextest.toml | 33 ++++++++++++- .github/workflows/ci.yml | 49 ++++++++++--------- CONTRIBUTING.md | 6 +-- Cargo.toml | 3 ++ crates/engine/src/tests/robustness_goldens.rs | 4 +- docs/book/src/dev/testing.md | 14 +++--- docs/robustness.md | 6 ++- 7 files changed, 76 insertions(+), 39 deletions(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index 92451dd5c..a45691c8a 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -1,8 +1,9 @@ # cargo-nextest settings for CI (`cargo xtask test` does not use nextest). -# PR runs build the tests once and run them in 4 shards (.github/workflows/ci.yml). +# CI builds the tests once and runs them in shards: 2 for a pull request, 4 for main and the nightly +# (.github/workflows/ci.yml). [profile.ci] -# Heavy tests (one to four minutes each on a CI runner) that pull requests skip. They run on +# Heavy tests (one to twelve minutes each on a CI runner) that pull requests skip. They run on # every push to main and nightly (`--ignore-default-filter`), and in `cargo xtask test`. The # boolean_props property tests run only nightly (ci.yml excludes them from pushes to main). # Keep this list in sync with docs/book/src/dev/testing.md and CONTRIBUTING.md. @@ -17,6 +18,7 @@ not ( | test(=cmd::plastic::tests::enclosure_snap_fit_follows_resized_front_wall) )) | (package(solidcraft-kernel) & test(=tests::boolean_identity_on_tangent_primitives)) + | (package(solidcraft-kernel) & test(=tspline::tests::hostile_tsplines_never_panic)) | (package(solidcraft-kernel) & binary(boolean_props)) | (package(solidcraft-engine) & binary(atomic_commands)) | (package(solidcraft-ui-egui) & binary(scenarios) & test(=acceptance_sensor_enclosure)) @@ -39,3 +41,30 @@ path = "junit.xml" filter = "binary(action_matrix) & test(=action_matrix_sample)" threads-required = "num-cpus" + +# The slowest tests start first, so a shard does not end with one of them running alone on a +# core while the others sit idle (seed_81 alone takes about 20 minutes under CI load). Medians +# from the CI test timings (the junit artifacts), slowest first; a test over ~100 s belongs here. +[[profile.ci.overrides]] +filter = """ +(package(solidcraft-engine) & ( + test(/^tests::robustness_goldens::seed_(81|45|20|24|95|02|57|40|18|48|32|46|85|61)$/) + | test(/^tests::robustness::/) + | test(=tests::hostile_params_never_panic) + | test(=cmd::clearance::tests::distances_are_exact_on_edges_and_curved_faces) + | test(=cmd::clipboard::tests::a_pasted_coil_joins_the_pasted_body) + | test(=tests::pleat_join::the_pleats_join_at_every_wall_from_2_4_to_2_6_mm) + | test(=tests::flush_join_loft::a_flange_flush_with_the_end_of_a_bent_tapered_tube_joins) + | test(=cmd::sheet::tests::perforated_sheet_takes_a_thousand_round_holes) + | test(=boolean_regression_tests::joined_loft_frames_plan_their_display_at_every_quality) +)) +| (package(solidcraft-engine) & (binary(atomic_commands) | binary(step_export_regressions))) +| (package(solidcraft-kernel) & ( + test(=curveblend::tests::rolling_ball_turns_about_a_rounded_corner_of_its_radius) + | test(=tests::fillet_tabbed_plate_outer_loop_and_partial_selection_after_hole) + | test(=tspline::tests::hostile_tsplines_never_panic) + | test(=fill::tests::regular_rims_of_three_to_eight_sides_fill_with_one_face_and_close_the_cup) + | test(/^issue_788_tests::equal_bores_crossing_/) +)) +""" +priority = 100 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8bb2e0b0..8bc782e27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ # those. Changes to the lockfile, root manifest, toolchain/cargo/nextest config, .github/, # vendor/, tests/, scripts/ or any file no package owns select the whole workspace, as do # pushes to main, the nightly run and Run workflow. -# Tests are built once and run in 4 shards. A few heavy tests (see .config/nextest.toml) are +# Tests are built once and run in shards. A few heavy tests (see .config/nextest.toml) are # skipped on pull requests and run on pushes to main and nightly. The Windows jobs (D3D12 shaders # and app startup) run on pull requests only when what they test changes (the GPU crate, the app, # the viewport's GPU glue, the graphics dependencies, their scripts or this file); main and @@ -363,45 +363,46 @@ jobs: - name: Run tests env: EVENT_NAME: ${{ github.event_name }} + GOLDENS: ${{ needs.changes.outputs.goldens }} LOCAL: ${{ needs.changes.outputs.local }} FULL: ${{ needs.changes.outputs.full }} PACKAGES: ${{ needs.changes.outputs.packages }} SHARD: ${{ matrix.shard }} SHARDS: ${{ github.event_name == 'pull_request' && 2 || 4 }} + # The robustness golden seeds a pull request skips: each takes one to twenty minutes under + # CI load, together about four fifths of the goldens' time. Pushes to main, the merge + # queue and the nightly run every seed. + SLOW_SEEDS: 81|45|20|24|95|02|57|40|18|48|32|46|85|61|77|34|14 run: | # Pull requests skip the heavy tests (default-filter in .config/nextest.toml). - all=() - # The boolean property tests draw new random inputs every run; they run only in the - # nightly property-tests job, so a known kernel bug cannot turn main red at random. + filter=() if [ "$EVENT_NAME" != pull_request ]; then - all=(--ignore-default-filter -E 'not (package(solidcraft-kernel) & binary(boolean_props))') + # The boolean property tests draw new random inputs every run; they run only in the + # nightly property-tests job, so a known kernel bug cannot turn main red at random. + filter=(--ignore-default-filter -E 'not (package(solidcraft-kernel) & binary(boolean_props))') + elif [ "$GOLDENS" = true ]; then + # A pull request that can change a robustness golden (tests/robustness/goldens.json) + # also checks every seed but the slow ones, in the same run so they share its cores. + filter=(--ignore-default-filter -E "default() | (package(solidcraft-engine) & test(/^tests::robustness_goldens::/) & not test(/^tests::robustness_goldens::seed_($SLOW_SEEDS)\$/))") fi + junit=${CARGO_TARGET_DIR:-target}/nextest/ci/junit.xml + # The warm build directory keeps the last run's junit.xml: never upload that one. + rm -f "$junit" if [ "$LOCAL" = true ]; then scope=(--workspace) if [ "$FULL" != true ]; then scope=(); for p in $PACKAGES; do scope+=(-p "$p"); done; fi - # The warm build directory keeps the last run's junit.xml: never upload that one. - rm -f "$CARGO_TARGET_DIR/nextest/ci/junit.xml" - cargo nextest run "${scope[@]}" --cargo-profile ci --locked \ - --profile ci --partition "slice:$SHARD/$SHARDS" --no-tests=pass "${all[@]}" + run=(cargo nextest run "${scope[@]}" --cargo-profile ci --locked) else # Extract into ./target: tests that run a built binary (env!("CARGO_BIN_EXE_*")) have # the build job's path, which is the same checkout path here. - cargo nextest run --archive-file tests.tar.zst --workspace-remap . --extract-to . --extract-overwrite \ - --profile ci --partition "slice:$SHARD/$SHARDS" --no-tests=pass "${all[@]}" + run=(cargo nextest run --archive-file tests.tar.zst --workspace-remap . --extract-to . --extract-overwrite) fi - - name: Robustness goldens (pull requests that change geometry) - # Every seed of tests/robustness/goldens.json (each seed is a test), split over the shards; - # pushes to main and the nightly run them in the step above. - if: github.event_name == 'pull_request' && needs.changes.outputs.goldens == 'true' - env: - SHARD: ${{ matrix.shard }} - SHARDS: ${{ github.event_name == 'pull_request' && 2 || 4 }} - run: | - if ! cargo nextest run --archive-file tests.tar.zst --workspace-remap . --extract-to . --extract-overwrite \ - --profile ci --ignore-default-filter --partition "slice:$SHARD/$SHARDS" --no-tests=pass \ - -E 'package(solidcraft-engine) & test(/^tests::robustness_goldens::/)'; then - echo "::error::A robustness golden changed. If the new result is intended, re-record it in this pull request and say why:" - echo "::error::ROBUSTNESS_GOLDENS_BLESS=\"why it changed\" cargo test --profile ci -p solidcraft-engine --lib robustness_goldens:: (see docs/robustness.md)" + if ! "${run[@]}" --profile ci --partition "slice:$SHARD/$SHARDS" --no-tests=pass "${filter[@]}"; then + # A failed golden gets the hint to re-record it (junit.xml lists the failures). + if [ -f "$junit" ] && tr '\n' ' ' < "$junit" | grep -q ']*>[[:space:]]*.seeds` records override only the listed seeds on that