Skip to content

Nightly sync mode - #58

Draft
flip1995 wants to merge 6 commits into
rust-lang:mainfrom
flip1995:nightly-sync-mode
Draft

Nightly sync mode#58
flip1995 wants to merge 6 commits into
rust-lang:mainfrom
flip1995:nightly-sync-mode

Conversation

@flip1995

@flip1995 flip1995 commented Sep 8, 2026

Copy link
Copy Markdown
Member

Clippy wants to pin its version in the repo to a nightly, so that contributors don't need any special tooling in order to compile it and rustup will automatically take care of toolchain management.

This requires some extra logic for syncing:

  • read and modify the rust-toolchain.toml file -> toml_edit
  • get the latest nightly -> chrono -> date -> nightly-{date}
  • get the commit from the current/next nightly -> rustc +nightly-{date} -vV

This PR moves a bunch of code around to add the new nightly sync-mode as just a new helper function. More details of the separate steps in the commit messages.

WIP, as I'm still testing it with this config:

org = "rust-lang"
repo = "rust-clippy"
filter = ":~(history=\"keep-trivial-merges,no-splice\")[:rev(<=7c06e7c42a8b56f9c1ac20e9ce34cadca0fce100:prefix=src/tools/clippy,<=da5114692c9ebe46b869488c5f34f92eb10b98c1:SQUASH)]:/src/tools/clippy"
filter-version = 2
base-commit = "Nightly"
rust-version-path = "rust-toolchain.toml"
post-pull = [ { cmd = [ "cargo dev sync update_nightly" ], commit-message = "Update nightly in clippy-utils README.md"} ]

chrono is used to get the current date in order to update the nightly
version, in case josh-sync is configured to use nightly versions.

toml_edit is used to read and modify the rust-toolchain.toml file.
In the `Latest` sync mode, this will be `rust-version`, but in the
`Nightly` mode this either has to be `rust-toolchain` (legacy) or
`rust-toolchain.toml`.
This lets repos choose if they want to sync from the latest rustc commit
or if they want to pin a nightly in rust-toolchain.toml.
Gets the current rust version depending on the BaseCommit mode selected.
Extracts the rust-version write logic out of the `rustc_pull` function
in its own `bump_version_latest` helper. Then it adds a new nightly sync
helper called `bump_version_nightly`.

In the new mode, it uses toml_edit to modify the `rust-toolchain.toml`
file with the latest nightly version, which it constructs through the
current date.

Small behaviorial change: The `new upstream base: <sha>` message is now
printed after the `original local HEAD: <sha>` message.
@Kobzol

Kobzol commented Sep 8, 2026

Copy link
Copy Markdown
Member

Hi, thanks for the PR. Fiddling with the TOML adds some complexity, but it makes sense.

I wonder, instead of using dates manually, maybe we can download https://static.rust-lang.org/manifests.txt and read the latest entry?

@bjorn3

bjorn3 commented Sep 10, 2026

Copy link
Copy Markdown
Member

manifests.txt in the past on occasion not been getting updated for several days in a row.

@Kobzol

Kobzol commented Sep 10, 2026

Copy link
Copy Markdown
Member

I think that only happens if we forget to update the CI job which needs to be poked once every 6 months I think 😆 But I realized that adding a dependency on a network client is perhaps a bit of a heavy hammer for this functionality.

Using the local nightly rustc to figure out its commit hash actually seems quite elegant. It could even work on CI, if we do something like rustup update nightly, and then read both the date and the commit hash from it. That might be the simplest solution, after all.

This PR already reads the hash from the nightly rustc, so maybe it could also read its date from it? Or you could pass the nightly verison explicitly. It seems better to me than guessing the date, because the nightly dates are always offset-by-one and it gets confusing.

@RalfJung

Copy link
Copy Markdown
Member
base-commit = "Nightly"
rust-version-path = "rust-toolchain.toml"

These only really make sense in combination, right? IMO they should be controlled by a single flag.

@bjorn3

bjorn3 commented Sep 10, 2026

Copy link
Copy Markdown
Member

It could even work on CI, if we do something like rustup update nightly, and then read both the date and the commit hash from it.

That would mean you did have to download rustc twice, right? Once for the nightly toolchain and once for nightly-$(date). I did rather either fetch both date and commit from the nightly manifest: https://static.rust-lang.org/dist/channel-rust-nightly.toml or take the current date and then download the corresponding nightly toolchain and get the commit from it.

It seems better to me than guessing the date, because the nightly dates are always offset-by-one and it gets confusing.

The date reported by rustc is off by one, but the date in the toolchain name matches the current day.

@Kobzol

Kobzol commented Sep 10, 2026

Copy link
Copy Markdown
Member

Ok, fair enough. Since we would anyway be dealing with parsing TOML files, downloading from the manifest seems reasonable, as it is the source of truth for Rustup too, and contains both the date and the commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants