diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba106b67b..6c8aeb3ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,6 +93,15 @@ jobs: rust-test: name: Rust (tests) runs-on: ubuntu-latest + # Five times since 13 November the runner stopped answering during the + # first cargo step and GitHub failed the job after 55 minutes as "lost + # communication": no test log, and every rerun passed. That step built + # the whole workspace with full debug info at four jobs, on a runner with + # 16 GB of memory (disk is not short: 87 GB free). With line tables the + # build peaks near 11 GB (the build step logs it each minute), builds in + # about a third of the time, and panics and backtraces keep file:line. + env: + CARGO_PROFILE_DEV_DEBUG: line-tables-only defaults: run: working-directory: services @@ -123,27 +132,51 @@ jobs: with: workspaces: services cache-on-failure: true + # Each test in its own process, ended and failed under its own name + # after two minutes (services/.config/nextest.toml). + - if: steps.changes.outputs.run == 'true' + uses: taiki-e/install-action@1919c4a95903d2c33e4a221102edca87309fc14b # v2.89.0 + with: + tool: cargo-nextest@0.9.151 + # The build on its own step, with its own time limit. --workspace + # everywhere: one feature set, so one build (`-p worker` alone resolves + # features differently and compiles everything again). + # Disk and memory every minute while it builds, so a runner that runs + # out of either says so in the log. + - name: Build tests + if: steps.changes.outputs.run == 'true' + timeout-minutes: 30 + run: | + usage() { echo "$(date -u +%T) disk free $(df -h --output=avail / | tail -1 | tr -d ' '), memory used $(free -m | awk '/^Mem/{print $3 " of " $2 " MB"}')"; } + usage + (while sleep 60; do usage; done) & + cargo test --workspace --no-run + usage # Every run failure that reached a person, replayed through the # pipeline's decision code with fakes only at the edges # (docs/incidents.md). Its own step, so a regression names itself. - # --workspace on both steps: one feature set, so one build (`-p worker` - # alone resolves features differently and compiles everything again). - name: Incident regressions if: steps.changes.outputs.run == 'true' - run: cargo test --workspace -- 'incidents::' + timeout-minutes: 10 + run: cargo nextest run --workspace --no-fail-fast -E 'test(/incidents::/)' # Stops, asks, blocks and loops replayed through the real decision # functions and graded on the decision, with the stop judge's recorded # answers k = 3 times each (pass^k; passes/replay/README.md). It gates # any prompt, model or effort change to a judgment step. - name: Replay suite if: steps.changes.outputs.run == 'true' - run: cargo test --workspace -- 'replay::' + timeout-minutes: 10 + run: cargo nextest run --workspace --no-fail-fast -E 'test(/replay::/)' # Includes the reviewer evals (worker passes::review_eval): recorded # review histories replayed through the real decision code, no model. # The incident and replay suites already ran above, on the same build. + # nextest runs no doc tests, so cargo test runs those. - name: Workspace tests if: steps.changes.outputs.run == 'true' - run: cargo test --workspace -- --skip 'incidents::' --skip 'replay::' + timeout-minutes: 15 + run: | + cargo nextest run --workspace --no-fail-fast -E 'not (test(/incidents::/) | test(/replay::/))' + cargo test --workspace --doc rust: name: Rust (workspace) diff --git a/docs/incidents.md b/docs/incidents.md index 42d96bcc4..72d34d785 100644 --- a/docs/incidents.md +++ b/docs/incidents.md @@ -3,7 +3,10 @@ Every run failure that reached a person is a case in `services/worker/src/passes/incidents/`, so it can't come back without a failing test. CI runs the suite as its own step, **Incident regressions** in **Rust (tests)** -(`cargo test --workspace -- incidents::`), on every pull request. +(`cargo nextest run --workspace -E 'test(/incidents::/)'`; locally, +`cargo test --workspace -- incidents::` runs the same tests), on every pull +request. A case still running after two minutes fails under its own name +(`services/.config/nextest.toml`). Each case replays the failure on one invented monorepo: diff --git a/services/.config/nextest.toml b/services/.config/nextest.toml new file mode 100644 index 000000000..1cbe118c9 --- /dev/null +++ b/services/.config/nextest.toml @@ -0,0 +1,11 @@ +# cargo-nextest settings for the workspace (CI runs every Rust test step +# through it; see .github/workflows/ci.yml). +# +# Each test runs in its own process, and one still running after two minutes +# is ended and reported as failed under its own name, so a test that hangs +# fails the step in minutes instead of holding the runner for an hour. The +# slowest test in the workspace takes a few seconds. + +[profile.default] +slow-timeout = { period = "30s", terminate-after = 4 } +fail-fast = false diff --git a/services/worker/src/passes/incidents/mod.rs b/services/worker/src/passes/incidents/mod.rs index 0849ab389..893c45b6a 100644 --- a/services/worker/src/passes/incidents/mod.rs +++ b/services/worker/src/passes/incidents/mod.rs @@ -9,7 +9,7 @@ //! never appears. Where a decision lives inside the pipeline itself, the //! case also checks that the pipeline still calls it at that place. //! -//! CI runs the suite as its own job (`cargo test -p worker incidents::`), +//! CI runs the suite as its own step (`docs/incidents.md` has the command), //! and `docs/incidents.md` lists each case with the guarantee it protects. //! A fix for a new failure adds a case here and a line there. diff --git a/services/worker/src/passes/incidents/q_run_ceiling.rs b/services/worker/src/passes/incidents/q_run_ceiling.rs index ddd7c3295..8565f6ee3 100644 --- a/services/worker/src/passes/incidents/q_run_ceiling.rs +++ b/services/worker/src/passes/incidents/q_run_ceiling.rs @@ -113,6 +113,18 @@ enum Ended { async fn adversary(message: &WorkerMessage, pass: &str, layers: Layers) -> (Ended, Totals) { let record = Record::default(); let usd_per_step = 4.0; + // One meter for every step: building an SDK client is the costly part, + // and 100,000 of them took a minute of the CI runner's CPU. No team, so + // `admit` asks nothing outside: only the allowance. + let meter = common::usage::UsageMeter::dynamo( + aws_sdk_dynamodb::Client::from_conf( + aws_sdk_dynamodb::Config::builder() + .behavior_version_latest() + .build(), + ), + "", + "", + ); for _ in 0..100_000u32 { if layers.entry && !admit(&record, message).await { assert_eq!(*record.ended_by_entry.borrow(), 1); @@ -128,13 +140,6 @@ async fn adversary(message: &WorkerMessage, pass: &str, layers: Layers) -> (Ende })); let refused = common::usage::with_run_allowance(allowance, async { // A step's calls: refused once the allowance is spent. - let client = aws_sdk_dynamodb::Client::from_conf( - aws_sdk_dynamodb::Config::builder() - .behavior_version_latest() - .build(), - ); - // No team, so `admit` asks nothing outside: only the allowance. - let meter = common::usage::UsageMeter::dynamo(client, "", ""); for _ in 0..4 { if meter.admit().await.is_err() { return true;