From 9798dcc4c3bc48c03f5ba87a30df911f77630b24 Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Thu, 5 Nov 2026 06:43:58 +0000 Subject: [PATCH 1/6] ci: skip the E2E scenarios when clippy is not green Since the build no longer waits for clippy, a lint-red run still spent a full E2E matrix on a change the required clippy check blocks anyway. The E2E job now needs clippy and its gate step opens only when clippy succeeded, on top of the existing build-and-test verdict and heavy checks. A manual dispatch skips clippy and still opens the gate. The skipped E2E check reports green without having run a scenario, so the gate prints a notice saying why instead of passing silently. The contract tests feed the clippy result into the gate script, pin the new needs entry, and cover the notice and the no-heavy-change case. Signed-off-by: Jussi Elo --- .github/workflows/ci.yml | 27 +++++++--- xtask/src/workflow_contract.rs | 97 ++++++++++++++++++++++++++++++---- 2 files changed, 107 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f47b9e228c..c227395411 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -344,8 +344,9 @@ jobs: # waiting for it delayed the whole run behind a check that rarely fails. The # two run in parallel instead. That is acceptable because `clippy` stays a required # check, so a lint failure still blocks the merge; what a clippy-red run loses - # is only the early skip of this job and of E2E, which now spend their runner - # time before the failure is known. + # is only the early skip of this job, which spends its runner time before the + # failure is known. The E2E job does wait for `clippy` and skips its scenarios + # when lint is red (see its gate step), so that cost stops here. needs: [changes, prek] # A manual E2E dispatch skips this heavy job for a fast loop; the E2E jobs # tolerate a skipped build-and-test in their own `if:` guards. @@ -1825,7 +1826,7 @@ jobs: matrix: os: [ubuntu-24.04, ubuntu-26.04] runs-on: ${{ matrix.os }} - needs: [changes, build-and-test] + needs: [changes, clippy, build-and-test] # This is a REQUIRED check, so — like every sibling required job — the job # itself must always run (except on a manual dispatch that didn't select the # mock platform), and the actual work is gated at the STEP level. Gating @@ -1841,19 +1842,33 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 # Whether the real work runs this time. On push/PR/merge_group: only when - # build-and-test ran to a verdict and the change is heavy. On - # workflow_dispatch: build-and-test is skipped, so tolerate that and rely - # on the job-level platform gate above. + # `clippy` passed, build-and-test ran to a verdict, and the change is + # heavy. On workflow_dispatch: clippy and build-and-test are skipped, so + # tolerate that and rely on the job-level platform gate above. # # "Ran to a verdict", not "succeeded": build-and-test is a matrix over # both images and its result is the aggregate, so a failure on one image # would otherwise skip this job's work on the other too — and the required # 24.04 leg would report green without having run a scenario. + # + # `clippy` is different: it must have succeeded. It is a required check + # of its own, so a red one blocks the merge whatever E2E says, and running + # the scenarios first would only spend runner time on a change that + # cannot merge. `clippy` runs on every event but a dispatch (handled + # first), so anything but `success` here is red or cancelled. The skip + # makes this required check report green without having run a scenario, + # the same shape as the build-and-test case above, which is harmless only + # while `clippy` is itself required; the notice says so on the run page + # rather than leaving a silent pass. - name: Decide whether to run id: gate run: | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then echo "run=true" >> "$GITHUB_OUTPUT" + elif [ "${{ needs.changes.outputs.heavy }}" = "true" ] \ + && [ "${{ needs.clippy.result }}" != "success" ]; then + echo "::notice title=E2E scenarios not run::clippy did not pass (result: ${{ needs.clippy.result }}), so no scenario ran and this check reports success without one. The required clippy check blocks the merge." + echo "run=false" >> "$GITHUB_OUTPUT" elif { [ "${{ needs.build-and-test.result }}" = "success" ] \ || [ "${{ needs.build-and-test.result }}" = "failure" ]; } \ && [ "${{ needs.changes.outputs.heavy }}" = "true" ]; then diff --git a/xtask/src/workflow_contract.rs b/xtask/src/workflow_contract.rs index 0dfc0146a5..ace85ab0db 100644 --- a/xtask/src/workflow_contract.rs +++ b/xtask/src/workflow_contract.rs @@ -1214,13 +1214,19 @@ jobs: /// Run `ci.yml`'s E2E "Decide whether to run" step under bash, as a `run:` /// step does, with each `${{ … }}` expression replaced by the value given - /// for it, and return what it wrote to `run=` in `$GITHUB_OUTPUT`. + /// for it, and return what it wrote to `run=` in `$GITHUB_OUTPUT` together + /// with what it printed to stdout (where a `::notice::` annotation goes). /// /// An expression the table does not name fails the test rather than /// expanding to nothing, so the gate cannot start reading a new context /// that this test silently feeds as empty. #[cfg(unix)] - fn run_e2e_gate(event: &str, build_and_test: &str, heavy: &str) -> String { + fn run_e2e_gate( + event: &str, + clippy: &str, + build_and_test: &str, + heavy: &str, + ) -> (String, String) { let ci = read_workflow("ci.yml"); let step = job_steps(job_block(&ci, "e2e")) .expect("ci.yml's `e2e` job has a `steps:` list") @@ -1234,6 +1240,7 @@ jobs: .expect("the gate step's script is not empty"); let values = [ ("github.event_name", event), + ("needs.clippy.result", clippy), ("needs.build-and-test.result", build_and_test), ("needs.changes.outputs.heavy", heavy), ]; @@ -1278,7 +1285,10 @@ jobs: 1, "the E2E gate writes `run=` exactly once; wrote {written:?}" ); - runs[0].to_owned() + ( + runs[0].to_owned(), + String::from_utf8_lossy(&out.stdout).into_owned(), + ) } /// The E2E scenarios run whenever `build-and-test` reached a verdict, not @@ -1292,7 +1302,9 @@ jobs: #[cfg(unix)] #[test] fn e2e_gate_runs_scenarios_whenever_build_and_test_reached_a_verdict() { - // (event, build-and-test result, heavy, expected run=) + // (event, build-and-test result, heavy, expected run=); clippy passed + // in every case, which `e2e_gate_skips_scenarios_unless_clippy_passed` + // varies. let cases = [ ("pull_request", "success", "true", "true"), ("pull_request", "failure", "true", "true"), @@ -1305,13 +1317,69 @@ jobs: ]; for (event, result, heavy, expected) in cases { assert_eq!( - run_e2e_gate(event, result, heavy), + run_e2e_gate(event, "success", result, heavy).0, expected, "ci.yml E2E gate with event={event}, build-and-test={result}, heavy={heavy:?}" ); } } + /// A lint-red run spends no E2E runner time: the scenarios run only when + /// `clippy` succeeded, whatever `build-and-test` did, and the skip says why. + /// + /// `clippy` is a required check of its own, so a red one blocks the merge + /// regardless of E2E. The skipped E2E check then reports green without + /// having run a scenario, which is the same shape as a skipped build; the + /// `::notice::` the gate prints is what keeps that from being silent. The + /// notice's claim that no scenario ran is the `run=false` asserted next to + /// it, and `ci_e2e_steps_after_the_gate_follow_its_decision` is what makes + /// every later step honour that decision. + #[cfg(unix)] + #[test] + fn e2e_gate_skips_scenarios_unless_clippy_passed() { + for event in ["push", "pull_request", "merge_group"] { + for build in ["success", "failure"] { + for clippy in ["failure", "cancelled", "skipped"] { + let (run, stdout) = run_e2e_gate(event, clippy, build, "true"); + assert_eq!( + run, "false", + "{event}: clippy={clippy} must keep the scenarios from running \ + (build-and-test={build})" + ); + assert!( + stdout.contains("::notice") + && stdout.contains(&format!("result: {clippy}")), + "{event}: skipping on clippy={clippy} must print a notice naming it, \ + got {stdout:?}" + ); + } + let (run, stdout) = run_e2e_gate(event, "success", build, "true"); + assert_eq!( + run, "true", + "{event}: clippy passed, build-and-test={build}" + ); + assert!( + !stdout.contains("::notice"), + "{event}: a passing clippy must not print the skip notice, got {stdout:?}" + ); + } + // A change with no heavy work has no E2E work to skip, so the clippy + // notice would be noise: it is for the run that would have run. + for clippy in ["success", "failure"] { + let (run, stdout) = run_e2e_gate(event, clippy, "success", "false"); + assert_eq!(run, "false", "{event}: clippy={clippy}, no heavy change"); + assert!( + !stdout.contains("::notice"), + "{event}: no heavy change, clippy={clippy}: no notice expected, got {stdout:?}" + ); + } + } + // `clippy` skips itself on a dispatch, which opens the gate regardless. + let (run, stdout) = run_e2e_gate("workflow_dispatch", "skipped", "skipped", ""); + assert_eq!(run, "true", "a dispatch ignores clippy"); + assert!(!stdout.contains("::notice"), "dispatch: got {stdout:?}"); + } + /// The runner image a hosted Linux job's caches must be keyed by, as it /// appears in a key: the literal image, or `matrix.os` for a split job. /// `None` for a job that is not a hosted Linux job. @@ -5344,10 +5412,12 @@ fi /// The other half of the ordering above: with `clippy` no longer ahead of /// `build-and-test`, a clippy-red run reaches the E2E job, so what keeps a - /// failed or skipped build from being read as a pass is the E2E job's own - /// gate. The job must need `build-and-test`, and every step after the gate step - /// must follow the gate's decision. What the gate decides is checked by - /// `ci_e2e_gate_opens_only_once_build_and_test_ran_to_a_verdict`. + /// lint-red, failed or skipped run from being read as a pass is the E2E job's + /// own gate. The job must need `clippy` and `build-and-test`, the two results + /// the gate reads, and every step after the gate step must follow the gate's + /// decision. What the gate decides is checked by + /// `ci_e2e_gate_opens_only_once_build_and_test_ran_to_a_verdict` and + /// `e2e_gate_skips_scenarios_unless_clippy_passed`. #[test] fn ci_e2e_steps_after_the_gate_follow_its_decision() { let ci = read_workflow("ci.yml"); @@ -5355,8 +5425,10 @@ fi let needs = yaml_value_at(&e2e, 4, "needs").expect("e2e declares `needs:`"); assert_eq!( flattened_list_items(&needs), - ["changes", "build-and-test"], - "the e2e job must need `build-and-test`, which it consumes" + ["changes", "clippy", "build-and-test"], + "the e2e job must need `clippy` and `build-and-test`, which its gate reads; \ + without `clippy` in `needs:` the gate's clippy result is empty and a lint-red \ + run would be skipped, or run, by accident" ); let steps = job_steps(&e2e).expect("e2e has steps"); let gate_at = steps @@ -5395,8 +5467,11 @@ fi .expect("e2e has a gate step named `Decide whether to run`"); let script = preflight_body_code(&gate.1); let run = |event: &str, build: &str, heavy: &str| -> String { + // `clippy` passed throughout; `e2e_gate_skips_scenarios_unless_clippy_passed` + // varies it. let script = script .replace("${{ github.event_name }}", event) + .replace("${{ needs.clippy.result }}", "success") .replace("${{ needs.build-and-test.result }}", build) .replace("${{ needs.changes.outputs.heavy }}", heavy); assert!( From 5ea5f283580e6e32d5ba86d4dccd9a4c0fd88156 Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Thu, 5 Nov 2026 15:08:20 +0000 Subject: [PATCH 2/6] ci: note why the E2E gate requires clippy to succeed, not skip The release-binaries job accepts a clippy result of success or skipped, while the E2E gate accepts only success. The difference is deliberate: clippy is skipped only on a workflow dispatch, which the gate's first branch already handles, so a skipped clippy anywhere else cannot reach the clippy branch as a pass. Say so next to the condition so the two are not aligned later. Comment only; the gate script's behaviour is unchanged. Signed-off-by: Jussi Elo --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c227395411..a5129c783d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1867,6 +1867,7 @@ jobs: echo "run=true" >> "$GITHUB_OUTPUT" elif [ "${{ needs.changes.outputs.heavy }}" = "true" ] \ && [ "${{ needs.clippy.result }}" != "success" ]; then + # Deliberately stricter than pr-linux-binaries' `success || skipped`: clippy is skipped only on a dispatch, which the first branch already handled. echo "::notice title=E2E scenarios not run::clippy did not pass (result: ${{ needs.clippy.result }}), so no scenario ran and this check reports success without one. The required clippy check blocks the merge." echo "run=false" >> "$GITHUB_OUTPUT" elif { [ "${{ needs.build-and-test.result }}" = "success" ] \ From 111bf78985193fcc0ccfb300290bd361da5617bf Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Thu, 5 Nov 2026 15:10:33 +0000 Subject: [PATCH 3/6] test(xtask): name the E2E gate outcome and share its assertions run_e2e_gate returned an unnamed (String, String) and the clippy skip test repeated the notice assertions in each loop. Return a small E2eGateOutcome struct and move the run= and ::notice:: assertions into one assert_e2e_gate helper that every row of e2e_gate_skips_scenarios_unless_clippy_passed calls. The rows, expected values and test names are unchanged. Re-checked that the test still fails when the gate's clippy comparison, its heavy guard or its notice annotation is broken. Signed-off-by: Jussi Elo --- xtask/src/workflow_contract.rs | 86 ++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 36 deletions(-) diff --git a/xtask/src/workflow_contract.rs b/xtask/src/workflow_contract.rs index ace85ab0db..75133dbef3 100644 --- a/xtask/src/workflow_contract.rs +++ b/xtask/src/workflow_contract.rs @@ -1212,6 +1212,15 @@ jobs: } } + /// What the E2E gate step produced: the `run=` value it wrote to + /// `$GITHUB_OUTPUT` and everything it printed to stdout (where a + /// `::notice::` annotation goes). + #[cfg(unix)] + struct E2eGateOutcome { + run: String, + stdout: String, + } + /// Run `ci.yml`'s E2E "Decide whether to run" step under bash, as a `run:` /// step does, with each `${{ … }}` expression replaced by the value given /// for it, and return what it wrote to `run=` in `$GITHUB_OUTPUT` together @@ -1226,7 +1235,7 @@ jobs: clippy: &str, build_and_test: &str, heavy: &str, - ) -> (String, String) { + ) -> E2eGateOutcome { let ci = read_workflow("ci.yml"); let step = job_steps(job_block(&ci, "e2e")) .expect("ci.yml's `e2e` job has a `steps:` list") @@ -1285,10 +1294,41 @@ jobs: 1, "the E2E gate writes `run=` exactly once; wrote {written:?}" ); - ( - runs[0].to_owned(), - String::from_utf8_lossy(&out.stdout).into_owned(), - ) + E2eGateOutcome { + run: runs[0].to_owned(), + stdout: String::from_utf8_lossy(&out.stdout).into_owned(), + } + } + + /// Assert the gate's two observable effects together: the `run=` it wrote + /// and whether it printed a `::notice::`. `notice_for` is `Some(result)` + /// when the notice must be printed and must name that clippy result, and + /// `None` when no notice may be printed at all. + #[cfg(unix)] + fn assert_e2e_gate( + event: &str, + clippy: &str, + build_and_test: &str, + heavy: &str, + expected_run: &str, + notice_for: Option<&str>, + ) { + let E2eGateOutcome { run, stdout } = run_e2e_gate(event, clippy, build_and_test, heavy); + let context = format!( + "ci.yml E2E gate with event={event}, clippy={clippy}, \ + build-and-test={build_and_test}, heavy={heavy:?}" + ); + assert_eq!(run, expected_run, "{context}: wrong `run=`"); + match notice_for { + Some(result) => assert!( + stdout.contains("::notice") && stdout.contains(&format!("result: {result}")), + "{context}: must print a notice naming clippy's result, got {stdout:?}" + ), + None => assert!( + !stdout.contains("::notice"), + "{context}: must not print the clippy skip notice, got {stdout:?}" + ), + } } /// The E2E scenarios run whenever `build-and-test` reached a verdict, not @@ -1317,7 +1357,7 @@ jobs: ]; for (event, result, heavy, expected) in cases { assert_eq!( - run_e2e_gate(event, "success", result, heavy).0, + run_e2e_gate(event, "success", result, heavy).run, expected, "ci.yml E2E gate with event={event}, build-and-test={result}, heavy={heavy:?}" ); @@ -1340,44 +1380,18 @@ jobs: for event in ["push", "pull_request", "merge_group"] { for build in ["success", "failure"] { for clippy in ["failure", "cancelled", "skipped"] { - let (run, stdout) = run_e2e_gate(event, clippy, build, "true"); - assert_eq!( - run, "false", - "{event}: clippy={clippy} must keep the scenarios from running \ - (build-and-test={build})" - ); - assert!( - stdout.contains("::notice") - && stdout.contains(&format!("result: {clippy}")), - "{event}: skipping on clippy={clippy} must print a notice naming it, \ - got {stdout:?}" - ); + assert_e2e_gate(event, clippy, build, "true", "false", Some(clippy)); } - let (run, stdout) = run_e2e_gate(event, "success", build, "true"); - assert_eq!( - run, "true", - "{event}: clippy passed, build-and-test={build}" - ); - assert!( - !stdout.contains("::notice"), - "{event}: a passing clippy must not print the skip notice, got {stdout:?}" - ); + assert_e2e_gate(event, "success", build, "true", "true", None); } // A change with no heavy work has no E2E work to skip, so the clippy // notice would be noise: it is for the run that would have run. for clippy in ["success", "failure"] { - let (run, stdout) = run_e2e_gate(event, clippy, "success", "false"); - assert_eq!(run, "false", "{event}: clippy={clippy}, no heavy change"); - assert!( - !stdout.contains("::notice"), - "{event}: no heavy change, clippy={clippy}: no notice expected, got {stdout:?}" - ); + assert_e2e_gate(event, clippy, "success", "false", "false", None); } } // `clippy` skips itself on a dispatch, which opens the gate regardless. - let (run, stdout) = run_e2e_gate("workflow_dispatch", "skipped", "skipped", ""); - assert_eq!(run, "true", "a dispatch ignores clippy"); - assert!(!stdout.contains("::notice"), "dispatch: got {stdout:?}"); + assert_e2e_gate("workflow_dispatch", "skipped", "skipped", "", "true", None); } /// The runner image a hosted Linux job's caches must be keyed by, as it From b6b7829dd21ed93a968c8fb6d4077d7392e0c24f Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Fri, 6 Nov 2026 09:53:42 +0000 Subject: [PATCH 4/6] ci: do not claim the clippy skip blocks the merge in the E2E notice The E2E gate prints its notice for every clippy result other than success, which includes cancelled, where nothing is red and nothing blocks the merge. Reword it to say what is true for each outcome (no scenario ran, this check reports success without one) and to point at the fix: fix or re-run clippy, then re-run the job. The contract test now asserts that wording together with run=false, for failure, cancelled and skipped, and fails if the notice goes back to asserting a merge block. Signed-off-by: Jussi Elo --- .github/workflows/ci.yml | 8 +++++--- xtask/src/workflow_contract.rs | 23 ++++++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5129c783d..a06910293b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1858,8 +1858,10 @@ jobs: # first), so anything but `success` here is red or cancelled. The skip # makes this required check report green without having run a scenario, # the same shape as the build-and-test case above, which is harmless only - # while `clippy` is itself required; the notice says so on the run page - # rather than leaving a silent pass. + # while `clippy` is itself required. The notice says on the run page that no + # scenario ran and what to re-run, rather than leaving a silent pass. It does + # not say the merge is blocked: a `cancelled` clippy is not red, so only a + # `failure` blocks anything, and the notice has to be true for both. - name: Decide whether to run id: gate run: | @@ -1868,7 +1870,7 @@ jobs: elif [ "${{ needs.changes.outputs.heavy }}" = "true" ] \ && [ "${{ needs.clippy.result }}" != "success" ]; then # Deliberately stricter than pr-linux-binaries' `success || skipped`: clippy is skipped only on a dispatch, which the first branch already handled. - echo "::notice title=E2E scenarios not run::clippy did not pass (result: ${{ needs.clippy.result }}), so no scenario ran and this check reports success without one. The required clippy check blocks the merge." + echo "::notice title=E2E scenarios not run::clippy did not succeed (result: ${{ needs.clippy.result }}), so no scenario ran and this check reports success without one. Fix or re-run clippy, then re-run this job to run the scenarios." echo "run=false" >> "$GITHUB_OUTPUT" elif { [ "${{ needs.build-and-test.result }}" = "success" ] \ || [ "${{ needs.build-and-test.result }}" = "failure" ]; } \ diff --git a/xtask/src/workflow_contract.rs b/xtask/src/workflow_contract.rs index 75133dbef3..f63589d77f 100644 --- a/xtask/src/workflow_contract.rs +++ b/xtask/src/workflow_contract.rs @@ -1320,10 +1320,21 @@ jobs: ); assert_eq!(run, expected_run, "{context}: wrong `run=`"); match notice_for { - Some(result) => assert!( - stdout.contains("::notice") && stdout.contains(&format!("result: {result}")), - "{context}: must print a notice naming clippy's result, got {stdout:?}" - ), + Some(result) => { + assert!( + stdout.contains("::notice") && stdout.contains(&format!("result: {result}")), + "{context}: must print a notice naming clippy's result, got {stdout:?}" + ); + // The notice is printed for every non-success result, including + // `cancelled`, where nothing is red and nothing is blocked. So it + // may tell the reader what to re-run but must not claim the merge + // is blocked; `run=false` above is what makes "no scenario ran" true. + assert!( + stdout.contains("re-run clippy") && !stdout.contains("blocks the merge"), + "{context}: the notice must say to re-run clippy and must not assert a \ + merge block that a `cancelled` clippy does not cause, got {stdout:?}" + ); + } None => assert!( !stdout.contains("::notice"), "{context}: must not print the clippy skip notice, got {stdout:?}" @@ -1373,7 +1384,9 @@ jobs: /// `::notice::` the gate prints is what keeps that from being silent. The /// notice's claim that no scenario ran is the `run=false` asserted next to /// it, and `ci_e2e_steps_after_the_gate_follow_its_decision` is what makes - /// every later step honour that decision. + /// every later step honour that decision. A `cancelled` clippy reaches the + /// same branch with nothing red, so the notice must hold for it too: it says + /// to re-run, and does not say the merge is blocked. #[cfg(unix)] #[test] fn e2e_gate_skips_scenarios_unless_clippy_passed() { From 20858e31d25ae08e11cdcb628f8368a5aab4c9f9 Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Fri, 6 Nov 2026 10:01:19 +0000 Subject: [PATCH 5/6] test(xtask): drive the E2E gate order test through run_e2e_gate The test for which build-and-test results open the E2E gate carried its own copy of the expression substitution that run_e2e_gate already does, so every context the gate reads had to be fed in two places and the copy could drift. Call assert_e2e_gate instead, which keeps one substitution that fails on a context it does not feed, and also checks that no clippy notice is printed when clippy passed. The cases are unchanged. Signed-off-by: Jussi Elo --- xtask/src/workflow_contract.rs | 75 ++++++++-------------------------- 1 file changed, 17 insertions(+), 58 deletions(-) diff --git a/xtask/src/workflow_contract.rs b/xtask/src/workflow_contract.rs index f63589d77f..e2b4a5cce5 100644 --- a/xtask/src/workflow_contract.rs +++ b/xtask/src/workflow_contract.rs @@ -5475,8 +5475,9 @@ fi } } - /// Run the e2e gate's own script, the way GitHub runs a step with no `shell:` - /// (`bash -e`), over every event and every `build-and-test` result. The gate + /// Run the e2e gate's own script through `run_e2e_gate`, the way GitHub runs + /// a step with no `shell:` (`bash -e`), over every event and every + /// `build-and-test` result. The gate /// opens once `build-and-test` ran to a verdict, `success` or `failure`: it is /// a matrix over both images and its result is the aggregate, so a failure on /// one image must not skip the other's E2E. A `skipped` or `cancelled` build @@ -5486,69 +5487,27 @@ fi #[cfg(unix)] #[test] fn ci_e2e_gate_opens_only_once_build_and_test_ran_to_a_verdict() { - let ci = read_workflow("ci.yml"); - let steps = job_steps(&ci_job(&ci, "e2e")).expect("e2e has steps"); - let gate = steps - .iter() - .find(|(name, _)| name == "Decide whether to run") - .expect("e2e has a gate step named `Decide whether to run`"); - let script = preflight_body_code(&gate.1); - let run = |event: &str, build: &str, heavy: &str| -> String { - // `clippy` passed throughout; `e2e_gate_skips_scenarios_unless_clippy_passed` - // varies it. - let script = script - .replace("${{ github.event_name }}", event) - .replace("${{ needs.clippy.result }}", "success") - .replace("${{ needs.build-and-test.result }}", build) - .replace("${{ needs.changes.outputs.heavy }}", heavy); - assert!( - !script.contains("${{"), - "the gate reads an expression this test does not substitute: {script}" - ); - let dir = tempfile::tempdir().expect("temp dir"); - let output = dir.path().join("github_output"); - std::fs::write(&output, "").expect("creating GITHUB_OUTPUT"); - let out = std::process::Command::new("bash") - .args(["-e", "-c", &script]) - .env("GITHUB_OUTPUT", &output) - .output() - .expect("running the e2e gate script"); - assert_eq!( - exit_code(out.status, "the e2e gate script"), - 0, - "the gate script must exit 0 for {event}/{build}/{heavy}" - ); - std::fs::read_to_string(&output) - .expect("reading GITHUB_OUTPUT") - .trim() - .to_owned() - }; - + // The gate is driven through `run_e2e_gate`, which owns the `${{ }}` + // substitution, so a context the gate starts reading is added there once. + // `clippy` passed throughout, so the clippy notice must never print; + // `e2e_gate_skips_scenarios_unless_clippy_passed` varies it. for event in ["push", "pull_request", "merge_group"] { for ran in ["success", "failure"] { - assert_eq!( - run(event, ran, "true"), - "run=true", - "{event}: a {ran} build-and-test ran to a verdict" - ); - assert_eq!( - run(event, ran, "false"), - "run=false", - "{event}: a {ran} build with no heavy change has no E2E work" - ); + // A build that ran to a verdict opens the E2E work. + assert_e2e_gate(event, "success", ran, "true", "true", None); + // ... but with no heavy change there is no E2E work. + assert_e2e_gate(event, "success", ran, "false", "false", None); } + // A build that never ran to a verdict must not open the E2E work. for bad in ["skipped", "cancelled"] { - assert_eq!( - run(event, bad, "true"), - "run=false", - "{event}: a {bad} build-and-test never ran to a verdict and must not open the E2E work" - ); + assert_e2e_gate(event, "success", bad, "true", "false", None); } } - // build-and-test is skipped on a dispatch, so the dispatch opens the gate - // without it; the job-level platform gate decides whether the job runs. + // build-and-test and clippy are both skipped on a dispatch, so the + // dispatch opens the gate without them; the job-level platform gate + // decides whether the job runs. for build in ["success", "skipped", "failure"] { - assert_eq!(run("workflow_dispatch", build, ""), "run=true", "{build}"); + assert_e2e_gate("workflow_dispatch", "skipped", build, "", "true", None); } } From 8300dc9cb4e5312276abc8121b4b82a161851280 Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Fri, 6 Nov 2026 12:42:34 +0000 Subject: [PATCH 6/6] ci: wrap the E2E gate comment and tell the notice to re-run the workflow The comment explaining why the E2E gate is stricter than pr-linux-binaries sat on one very long line inside the run block; wrap it like the comments around it. The comment lines stay in the script, so the shell it runs is unchanged. The skip notice said to re-run this job. A re-run of a single job reuses the results the earlier attempt recorded for the jobs it needs, so it would still read the old clippy result and skip the scenarios again. The notice now says to fix clippy if it is red and re-run the workflow, which runs clippy and then this job. The contract test requires that wording and rejects both "re-run this job" and "blocks the merge", together with run=false, for a failed, cancelled and skipped clippy. Signed-off-by: Jussi Elo --- .github/workflows/ci.yml | 6 ++++-- xtask/src/workflow_contract.rs | 15 +++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a06910293b..8cd4d271bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1869,8 +1869,10 @@ jobs: echo "run=true" >> "$GITHUB_OUTPUT" elif [ "${{ needs.changes.outputs.heavy }}" = "true" ] \ && [ "${{ needs.clippy.result }}" != "success" ]; then - # Deliberately stricter than pr-linux-binaries' `success || skipped`: clippy is skipped only on a dispatch, which the first branch already handled. - echo "::notice title=E2E scenarios not run::clippy did not succeed (result: ${{ needs.clippy.result }}), so no scenario ran and this check reports success without one. Fix or re-run clippy, then re-run this job to run the scenarios." + # Deliberately stricter than pr-linux-binaries' `success || skipped`: + # clippy is skipped only on a dispatch, which the first branch + # already handled. + echo "::notice title=E2E scenarios not run::clippy did not succeed (result: ${{ needs.clippy.result }}), so no scenario ran and this check reports success without one. Fix clippy if it is red, then re-run the workflow so that clippy and this job run again." echo "run=false" >> "$GITHUB_OUTPUT" elif { [ "${{ needs.build-and-test.result }}" = "success" ] \ || [ "${{ needs.build-and-test.result }}" = "failure" ]; } \ diff --git a/xtask/src/workflow_contract.rs b/xtask/src/workflow_contract.rs index e2b4a5cce5..cabc994866 100644 --- a/xtask/src/workflow_contract.rs +++ b/xtask/src/workflow_contract.rs @@ -1329,10 +1329,16 @@ jobs: // `cancelled`, where nothing is red and nothing is blocked. So it // may tell the reader what to re-run but must not claim the merge // is blocked; `run=false` above is what makes "no scenario ran" true. + // Re-running only this job would reuse the clippy result recorded + // by the earlier attempt, so the advice is to re-run the workflow, + // which runs clippy again and then this job. assert!( - stdout.contains("re-run clippy") && !stdout.contains("blocks the merge"), - "{context}: the notice must say to re-run clippy and must not assert a \ - merge block that a `cancelled` clippy does not cause, got {stdout:?}" + stdout.contains("re-run the workflow") + && !stdout.contains("re-run this job") + && !stdout.contains("blocks the merge"), + "{context}: the notice must say to re-run the workflow, must not say to \ + re-run only this job (it would reuse the old clippy result) and must not \ + assert a merge block that a `cancelled` clippy does not cause, got {stdout:?}" ); } None => assert!( @@ -1386,7 +1392,8 @@ jobs: /// it, and `ci_e2e_steps_after_the_gate_follow_its_decision` is what makes /// every later step honour that decision. A `cancelled` clippy reaches the /// same branch with nothing red, so the notice must hold for it too: it says - /// to re-run, and does not say the merge is blocked. + /// to re-run the workflow (not just this job, which would reuse the old + /// clippy result), and does not say the merge is blocked. #[cfg(unix)] #[test] fn e2e_gate_skips_scenarios_unless_clippy_passed() {