Nightly sync mode - #58
Conversation
|
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? |
|
manifests.txt in the past on occasion not been getting updated for several days in a row. |
|
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 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. |
These only really make sense in combination, right? IMO they should be controlled by a single flag. |
That would mean you did have to download rustc twice, right? Once for the nightly toolchain and once for
The date reported by rustc is off by one, but the date in the toolchain name matches the current day. |
|
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. |
|
Thanks for the feedback! I swapped out chrono with ureq and now get the latest nightly + upstream_sha from the manifest file. I also moved the |
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.
It's default value is implied by the `base-commit` in the config file. No need to require configuring this and the `base-commit` separately.
This drops the chrono dependency and uses the nightly version from the latest nightly manifest instead, by pulling it with ureq.
e63a224 to
807067d
Compare
|
Rebased onto main to drop the josh version bump commit. |
b941484 to
8a5d5a0
Compare
|
Thanks for making the changes! After the |
… parsed Before it just printed an error and returned. If the file doesn't exist, it will return `Ok(None)`, indicating that no prior pull has happened.
8a5d5a0 to
29d320f
Compare
Kobzol
left a comment
There was a problem hiding this comment.
Looks good, thank you! I tested it with rust-version and it seems to work fine. I didn't test the rust-toolchain.toml version, but I'm sure that if you'll run into any issues during the Clippy migration, we can flesh out the fixes then.
Thank you very much for implementing this!
Yes, I have the Clippy PR open here: rust-lang/rust-clippy#17739. I'm doing another If anything doesn't work out, I'll open another PR fixing that. But in my initial tests everything worked out. Side note: one feature I'd like to still add is a |
|
That sounds great. Here is an updated/fixed version of my script: https://gist.github.com/Kobzol/7c8d2a5059e5e2483c7807f0007e25cd |
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
rustupwill automatically take care of toolchain management.This requires some extra logic for syncing:
rust-toolchain.tomlfile ->toml_editureq-> date+upstream_sha ->nightly-{date}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: