From 6cae85eb7af0b533f4a3cc84995d6ca552459b8a Mon Sep 17 00:00:00 2001 From: Thomas Yau Date: Thu, 23 Jul 2026 12:00:00 +0800 Subject: [PATCH] ci: only open a Rust toolchain PR when the version changed The nightly updater ran `nix flake update rust-overlay` unconditionally. That bumps the rust-overlay input to its newest revision every night regardless of whether the latest stable Rust actually moved, which always dirties flake.lock. As a result create-pull-request opened a fresh PR each night even when the pinned toolchain was already current. Read the currently pinned version out of rust-toolchain.toml in the check step and compare it against the latest stable, exposing a `changed` output. Gate the Earthfile and toml edits, the Nix install, the flake update, and the PR creation on that flag, so a night with no version bump touches nothing and opens no PR. Signed-off-by: Thomas Yau --- .../workflows/nightly-rust-update-check.yaml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nightly-rust-update-check.yaml b/.github/workflows/nightly-rust-update-check.yaml index 38b0021e..9a13f8b7 100644 --- a/.github/workflows/nightly-rust-update-check.yaml +++ b/.github/workflows/nightly-rust-update-check.yaml @@ -24,25 +24,37 @@ jobs: run: | rustup install stable stable=$(rustup run stable rustc -V | sed -E -e 's/^rustc ([0-9\.]+) \(.*\)$/\1/g') - echo "Latest stable rust is ${stable}" + current=$(sed -E -n 's/^channel = "([0-9\.]+)"$/\1/p' rust-toolchain.toml) + echo "Latest stable rust is ${stable}, currently pinned to ${current}" echo rust="$stable" >> "$GITHUB_OUTPUT" + if [ "$stable" != "$current" ]; then + echo changed=true >> "$GITHUB_OUTPUT" + else + echo changed=false >> "$GITHUB_OUTPUT" + fi - name: Update Rust version in Earthfile + if: steps.check-version.outputs.changed == 'true' run: sed -i -E 's/^(\s*FROM rust):(:?[0-9\.]+)(-.+)?$/\1:${{ steps.check-version.outputs.rust }}\3/g' Earthfile - name: Update Rust version in rust-toolchain.toml + if: steps.check-version.outputs.changed == 'true' run: sed -i -E 's/^(channel = ")[0-9\.]+(")$/\1${{ steps.check-version.outputs.rust }}\2/' rust-toolchain.toml # nix (rust-overlay) can only resolve the pinned stable version once flake.lock points at a - # rust-overlay revision that carries it, so refresh that input in the same PR. + # rust-overlay revision that carries it, so refresh that input in the same PR. Gated on an + # actual version change so we don't bump the input (and open a spurious PR) on an unchanged night. - name: Install Nix + if: steps.check-version.outputs.changed == 'true' uses: DeterminateSystems/nix-installer-action@c5a866b6ab867e88becbed4467b93592bce69f8a # v21 - name: Update rust-overlay in flake.lock + if: steps.check-version.outputs.changed == 'true' run: nix flake update rust-overlay - - uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6 + - if: steps.check-version.outputs.changed == 'true' + uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6 with: token: ${{ secrets.SERVICE_ACCOUNT_PAT }} delete-branch: true