From 629c0ffb75c64c5e91049dbba830fcba9937cd72 Mon Sep 17 00:00:00 2001 From: aiongg Date: Fri, 20 Nov 2026 04:02:11 +0000 Subject: [PATCH] ci: build every CI job with one pinned Rust release Part of #15711 --- .github/workflows/ci.yml | 30 ++++++++++++++++++---------- .github/workflows/perf-nightly.yml | 5 ++++- scripts/test-ci-toolchain-pin.py | 32 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 scripts/test-ci-toolchain-pin.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 196a421ca2..561c75e875 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,6 +57,12 @@ permissions: env: CARGO_TERM_COLOR: always + # The Rust release every job builds with. A release that came out overnight must not start a cold + # build in every cache key (the key holds `rustc -vV`); a change to this value is the one cold + # day, reviewed as any change. The gate calls below carry the same value (their `env` is not this + # one), and scripts/test-ci-toolchain-pin.py checks that they agree. The name stays outside the + # prefixes rust-cache hashes into its keys. + TOOLCHAIN_PIN: "1.100.0" RUST_BACKTRACE: 1 PHOTOCRAFT_FULL_SWEEP: ${{ inputs.full_sweep && '1' || '0' }} # No test or fuzz run may print a page: the engine refuses to spool, and if something ever @@ -167,6 +173,8 @@ jobs: # Tracks @main so suite-wide CI fixes reach every app without a PR in each repository. uses: storytold/craft-common-actions/.github/workflows/gate.yml@main with: + # TOOLCHAIN_PIN (the called workflow does not see this file's `env`). + toolchain: "1.100.0" # egui/winit/rfd. packages: >- libxkbcommon-dev libwayland-dev libx11-dev libxrandr-dev libxi-dev libgl1-mesa-dev @@ -191,7 +199,7 @@ jobs: # fmt, egui-fork, clippy, layers, panel-commands, scorecard, the wasm32 check and the # missing-translations report (`cargo xtask ci lint`, xtask/src/main.rs), and the CI scripts' # own tests. - lint-command: python3 scripts/test-ci-gpu-lavapipe.py && python3 scripts/test-ci-windows-gpu-tests.py && python3 scripts/test-ci-test-times.py && cargo xtask ci lint + lint-command: python3 scripts/test-ci-gpu-lavapipe.py && python3 scripts/test-ci-windows-gpu-tests.py && python3 scripts/test-ci-test-times.py && python3 scripts/test-ci-toolchain-pin.py && cargo xtask ci lint archive-command: cargo xtask ci archive --gpu-shard after-archive-command: cargo xtask ci doctest test-shards: 4 @@ -216,6 +224,8 @@ jobs: uses: storytold/craft-common-actions/.github/workflows/gate.yml@main with: os: '["windows-latest"]' + # TOOLCHAIN_PIN. + toolchain: "1.100.0" lint-cache: false # The all-language UI tests shape real Japanese, Chinese, Korean and Devanagari labels with # kittest's strict `MissingGlyphPolicy::Panic`, and a hosted Windows image has no guaranteed @@ -325,7 +335,7 @@ jobs: - uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0 with: - toolchain: stable + toolchain: ${{ env.TOOLCHAIN_PIN }} # The gate's own key (the shared action computes it), restore only. The toolchain action # exports CARGO_HOME, which the gate's legs do not have; align-environment leaves it out of @@ -370,7 +380,7 @@ jobs: persist-credentials: false - uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0 with: - toolchain: stable + toolchain: ${{ env.TOOLCHAIN_PIN }} - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 with: prefix-key: v1-rust @@ -413,7 +423,7 @@ jobs: - uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0 with: - toolchain: stable + toolchain: ${{ env.TOOLCHAIN_PIN }} targets: wasm32-unknown-unknown - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 with: @@ -532,7 +542,7 @@ jobs: libgtk-3-dev - uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0 with: - toolchain: stable + toolchain: ${{ env.TOOLCHAIN_PIN }} - name: Compare exact outputs and release timings on 24 MP run: | set -o pipefail @@ -565,7 +575,7 @@ jobs: libgtk-3-dev - uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0 with: - toolchain: stable + toolchain: ${{ env.TOOLCHAIN_PIN }} - name: Compare exact outputs and release timings on 36 MP run: | set -o pipefail @@ -597,7 +607,7 @@ jobs: persist-credentials: false - uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0 with: - toolchain: stable + toolchain: ${{ env.TOOLCHAIN_PIN }} # perf-nightly.yml's entry (same key and runner); only that job saves it. - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 with: @@ -630,7 +640,7 @@ jobs: persist-credentials: false - uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0 with: - toolchain: stable + toolchain: ${{ env.TOOLCHAIN_PIN }} - name: Compare exact outputs and release timings on 36 MP run: | set -o pipefail @@ -663,7 +673,7 @@ jobs: path: before - uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0 with: - toolchain: stable + toolchain: ${{ env.TOOLCHAIN_PIN }} - name: Build the same benchmark against both versions run: | cp after/crates/paint/examples/big_dab_bench.rs before/crates/paint/examples/big_dab_bench.rs @@ -714,7 +724,7 @@ jobs: cp crates/engine/examples/bench_dry_mixer.rs "$RUNNER_TEMP/photocraft-baseline/crates/engine/examples/bench_dry_mixer.rs" - uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0 with: - toolchain: stable + toolchain: ${{ env.TOOLCHAIN_PIN }} - name: Install Linux build dependencies uses: storytold/craft-common-actions/actions/install-apt-packages@main with: diff --git a/.github/workflows/perf-nightly.yml b/.github/workflows/perf-nightly.yml index c15d5d9f59..314589c417 100644 --- a/.github/workflows/perf-nightly.yml +++ b/.github/workflows/perf-nightly.yml @@ -35,6 +35,9 @@ concurrency: env: CARGO_TERM_COLOR: always + # ci.yml's TOOLCHAIN_PIN: the quick performance suite there restores this workflow's cache entry, whose key + # holds the Rust release. + TOOLCHAIN_PIN: "1.100.0" jobs: perf: @@ -53,7 +56,7 @@ jobs: - uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0 with: - toolchain: stable + toolchain: ${{ env.TOOLCHAIN_PIN }} - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 with: diff --git a/scripts/test-ci-toolchain-pin.py b/scripts/test-ci-toolchain-pin.py new file mode 100644 index 0000000000..46978c2779 --- /dev/null +++ b/scripts/test-ci-toolchain-pin.py @@ -0,0 +1,32 @@ +"""ci.yml and perf-nightly.yml build every job with one Rust release: TOOLCHAIN_PIN, and the gate calls' `toolchain`.""" +from pathlib import Path +import re +import unittest + +WORKFLOWS = Path(__file__).resolve().parent.parent / '.github' / 'workflows' +CI = WORKFLOWS / 'ci.yml' +PERF = WORKFLOWS / 'perf-nightly.yml' + + +class TestToolchainPin(unittest.TestCase): + def setUp(self): + self.text = CI.read_text() + + def test_the_gate_calls_use_the_pinned_release(self): + pin = re.search(r'^ TOOLCHAIN_PIN: "([^"]+)"$', self.text, re.M) + self.assertIsNotNone(pin, 'ci.yml sets no TOOLCHAIN_PIN') + calls = re.findall(r'^ toolchain: "([^"]+)"$', self.text, re.M) + self.assertEqual(calls, [pin.group(1)] * 2, 'the Linux and Windows gate calls must name the pin') + + def test_perf_nightly_uses_the_same_release(self): + pins = [re.search(r'^ TOOLCHAIN_PIN: "([^"]+)"$', t, re.M) for t in (self.text, PERF.read_text())] + self.assertTrue(all(pins), 'a workflow sets no TOOLCHAIN_PIN') + self.assertEqual(pins[0].group(1), pins[1].group(1)) + + def test_no_job_installs_a_floating_stable(self): + self.assertNotIn('toolchain: stable', self.text) + self.assertNotIn('toolchain: stable', PERF.read_text()) + + +if __name__ == '__main__': + unittest.main()