diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 652f9f2670..76c3fadfea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -824,30 +824,25 @@ jobs: name: dry-mixer-performance path: dry-mixer-perf.txt - # After the nightly cold run passes, a newer stable Rust release gets a pull request that changes - # only rust-toolchain.toml (a file the workflow token may change; it may not change workflow - # files). Pull requests the token opens start no checks, so the branch also gets a dispatched run - # of this workflow, which runs the whole gate on it. A failed step warns: tomorrow's run tries again. - toolchain-bump: - name: toolchain bump + # After the nightly cold run passes, a warning (annotation and job summary) says when a newer stable + # Rust release than rust-toolchain.toml's exists. It needs no permission and changes nothing: a bump + # is a pull request that changes the file's `channel` by hand. + toolchain-check: + name: toolchain check needs: gate if: github.event_name == 'schedule' && needs.gate.result == 'success' runs-on: ubuntu-24.04 timeout-minutes: 10 continue-on-error: true - permissions: - contents: write - pull-requests: write - actions: write steps: - name: Harden runner uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 with: egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - name: Open the bump pull request - env: - GH_TOKEN: ${{ github.token }} + with: + persist-credentials: false + - name: Compare the pinned release with stable run: | set -euo pipefail version=$(python3 scripts/ci-toolchain-bump.py) @@ -855,15 +850,6 @@ jobs: echo "rust-toolchain.toml is current" exit 0 fi - branch="toolchain-$version" - if [ -n "$(gh pr list --head "$branch" --state all --json number --jq '.[].number')" ]; then - echo "$branch already has a pull request" - exit 0 - fi - python3 scripts/ci-toolchain-bump.py --write "$version" - git -c user.name=github-actions -c user.email=41898282+github-actions[bot]@users.noreply.github.com \ - commit -q -m "Build with Rust $version" rust-toolchain.toml - git push origin "HEAD:refs/heads/$branch" - gh pr create --head "$branch" --base main --title "Build with Rust $version" \ - --body "Moves rust-toolchain.toml to Rust $version, the newest stable release. A pull request opened with the workflow token starts no checks; the run dispatched on this branch is its check. The first main run after the merge builds cold once." - gh workflow run ci.yml --ref "$branch" + msg="Rust $version is the newest stable release; rust-toolchain.toml pins an older one. Change its channel in a pull request to move." + echo "::warning title=Newer Rust release::$msg" + echo "$msg" >> "$GITHUB_STEP_SUMMARY" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 0e0c1ccbf1..9d96b2f6dd 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,6 +1,6 @@ # The Rust release CI and contributors build with. One release means a new Rust release does not -# start a cold build in every cache key (they hold `rustc -vV`). The nightly CI run opens a pull -# request that changes only `channel` when a newer stable exists (scripts/ci-toolchain-bump.py). +# start a cold build in every cache key (they hold `rustc -vV`). The nightly CI run warns when +# a newer stable exists (scripts/ci-toolchain-bump.py); a bump is a pull request that changes `channel`. # `rust-version` in Cargo.toml is the oldest release the sources support. [toolchain] channel = "1.100.0" diff --git a/scripts/ci-toolchain-bump.py b/scripts/ci-toolchain-bump.py index 41bbca05ce..412a7d7dc6 100644 --- a/scripts/ci-toolchain-bump.py +++ b/scripts/ci-toolchain-bump.py @@ -1,11 +1,7 @@ #!/usr/bin/env python3 -"""Moves rust-toolchain.toml to the newest stable Rust release. +"""Prints the newest stable Rust release when it is newer than rust-toolchain.toml's channel. - python3 scripts/ci-toolchain-bump.py prints the newest stable release when it is newer than the file's - python3 scripts/ci-toolchain-bump.py --write V sets the file's channel to V - -CI's nightly run (ci.yml `toolchain-bump`) runs both and opens a pull request that changes only -rust-toolchain.toml. Prints nothing when the file is current. +CI's nightly run (ci.yml `toolchain-check`) warns with it. Prints nothing when the file is current. """ import re @@ -16,7 +12,6 @@ from pathlib import Path FILE = Path(__file__).resolve().parent.parent / 'rust-toolchain.toml' MANIFEST = 'https://static.rust-lang.org/dist/channel-rust-stable.toml' -CHANNEL = re.compile(r'^(channel\s*=\s*")([^"]*)(")', re.M) RELEASE = re.compile(r'^\d+\.\d+\.\d+$') @@ -45,16 +40,7 @@ def newer(file_text, manifest_text): return stable -def with_channel(file_text, version): - if not RELEASE.match(version): - raise ValueError(f'not a release: {version!r}') - return CHANNEL.sub(lambda m: m.group(1) + version + m.group(3), file_text, count=1) - - def main(argv): - if argv[:1] == ['--write']: - FILE.write_text(with_channel(FILE.read_text(), argv[1])) - return with urllib.request.urlopen(MANIFEST, timeout=30) as response: stable = newer(FILE.read_text(), response.read().decode()) if stable: diff --git a/scripts/test-ci-toolchain-bump.py b/scripts/test-ci-toolchain-bump.py index 3c467c5f57..23193f9cdf 100644 --- a/scripts/test-ci-toolchain-bump.py +++ b/scripts/test-ci-toolchain-bump.py @@ -21,9 +21,6 @@ class TestBump(unittest.TestCase): def test_a_pin_that_is_not_a_release_moves_to_stable(self): self.assertEqual(bump.newer(FILE.replace('1.100.0', 'stable'), manifest('1.100.0')), '1.100.0') - def test_writing_changes_only_the_channel(self): - self.assertEqual(bump.with_channel(FILE, '1.101.0'), FILE.replace('1.100.0', '1.101.0')) - if __name__ == '__main__': unittest.main()