-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add full git commit hash to release channel manifests #44218
Conversation
The full hash is necessary to build the download URL for "alternate" compiler builds. This is a first step for rust-lang/rustup#1099
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
src/bootstrap/dist.rs
Outdated
t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes())); | ||
t!(t!(File::create(overlay.join("git-commit-hash"))).write_all(sha.as_bytes())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version
file is currently present in a number of tarballs that we produce, and from a consistency point of view it seems odd for the hash to only be in one? Would it be possible to refactor this to ensure there's a git commit file in all the tarballs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added for source and extended tarballs. I don’t know if the rust-lang/rust commit hash makes sense in Cargo and RLS tarballs, and the rust-lang/cargo and rust-lang-nursery/rls commit hashes are not easily available.
src/tools/build-manifest/src/main.rs
Outdated
fn write_channel_files(&self, channel_name: &str, manifest: &Manifest) { | ||
self.write(&toml::to_string(&manifest).unwrap(), channel_name, ".toml"); | ||
self.write(&manifest.date, channel_name, "-date.txt"); | ||
self.write(&manifest.git_commit_hash, channel_name, "-git-commit-hash.txt"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we for sure need a dedicated file for the git commit? This'll already be present in the manifest, and the date.txt
was only added much later as a request (ideally this extra file wouldn't exist)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don’t really need it, just like we don’t really need date.txt
. A separate file makes it marginally easier for Servo’s bootstrap to extract the commit hash, but we can also parse the TOML file.
I can remove it if you prefer.
src/tools/build-manifest/src/main.rs
Outdated
@@ -107,6 +107,7 @@ static MINGW: &'static [&'static str] = &[ | |||
struct Manifest { | |||
manifest_version: String, | |||
date: String, | |||
git_commit_hash: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this commit may be best inside each Package
? I'd imagine that maybe eventually we'd have a use for the commit information other than just for rustc
but also for cargo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything under https://s3.amazonaws.com/rust-lang-ci/rustc-builds are in "subdirectories" named after the rust-lang/rust commit hash, even for other packages like Cargo. But if you prefer I could work on that change in case the Cargo commit hash is needed later for some reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figuring out the respective build systems in respective repositories to add text files in various tarballs to make this info available in the first place is non-trivial, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve made it optional (always missing at the moment for Cargo and RLS) and per-package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine in general but there are a few implementation nits. Others can comment more on the rustup/artifact side.
src/bootstrap/dist.rs
Outdated
@@ -364,7 +364,9 @@ impl Step for Rustc { | |||
cp("README.md"); | |||
// tiny morsel of metadata is used by rust-packaging | |||
let version = build.rust_version(); | |||
let sha = build.rust_sha().unwrap_or(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<unknown>
seems better to me than an empty string, but I'm not sure if it'll work well with other logic. Perhaps we could not create the file if we don't know it instead? Empty files are somewhat painful to debug...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this omit the file at first, but then I didn’t know how to separate “this tarball does not contain this file” from other kinds of errors in Command::new("tar").arg("xf") …
Any suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it should be an error to try to build a manifest with ignore-git = true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to not including the file when the info is missing.
String::from_utf8_lossy(&output.stdout), | ||
String::from_utf8_lossy(&output.stderr)); | ||
} | ||
String::from_utf8_lossy(&output.stdout).trim().to_string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm not quite following, but why the changes to version()
? It still should be doing the same thing, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed a variable name before copy/pasting the method, but it’s otherwise unchanged. I can revert that if you prefer.
… instead of writing an empty file.
@@ -167,6 +168,9 @@ struct Builder { | |||
rust_version: String, | |||
cargo_version: String, | |||
rls_version: String, | |||
rust_git_commit_hash: Option<String>, | |||
cargo_git_commit_hash: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like these are never initialized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Looks good! I think though that cargo/rls tarballs don't have files with the git commit in them? |
At the moment it is always missing for Cargo and RLS. Their respective build systems need to be modified to include `git-commit-hash` files in their "dist" tarballs.
e371f53
to
f912d77
Compare
That’s correct. These would need to be added separately. (If someone finds a use for them, they are not used for rust-lang/rustup#1099 which motivates this PR.) |
@bors: r+ |
📌 Commit f912d77 has been approved by |
@bors rollup |
Add full git commit hash to release channel manifests The full hash is necessary to build the download URL for "alternate" compiler builds. This is a first step for rust-lang/rustup#1099.
Add full git commit hash to release channel manifests The full hash is necessary to build the download URL for "alternate" compiler builds. This is a first step for rust-lang/rustup#1099.
… added in rust-lang/rust#44218, instead of using the GitHub API. And upgrade to rustc 1.22.0-nightly (d93036a04 2017-09-07)
Get rustc commit hash from channel manifest … added in rust-lang/rust#44218, instead of using the GitHub API. Also upgrade to rustc 1.22.0-nightly (d93036a04 2017-09-07), and app_units 0.5.6 (for servo/app_units#37) <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18420) <!-- Reviewable:end -->
Get rustc commit hash from channel manifest … added in rust-lang/rust#44218, instead of using the GitHub API. Also upgrade to rustc 1.22.0-nightly (d93036a04 2017-09-07), and app_units 0.5.6 (for servo/app_units#37) <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18420) <!-- Reviewable:end -->
… added in rust-lang/rust#44218, instead of using the GitHub API. And upgrade to rustc 1.22.0-nightly (d93036a04 2017-09-07)
Get rustc commit hash from channel manifest … added in rust-lang/rust#44218, instead of using the GitHub API. Also upgrade to rustc 1.22.0-nightly (d93036a04 2017-09-07), and app_units 0.5.6 (for servo/app_units#37) <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18420) <!-- Reviewable:end -->
… added in rust-lang/rust#44218, instead of using the GitHub API.
Get rustc commit hash from channel manifest … added in rust-lang/rust#44218, instead of using the GitHub API. Also upgrade to rustc 1.22.0-nightly (d93036a04 2017-09-07). <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18420) <!-- Reviewable:end -->
… added in rust-lang/rust#44218, instead of using the GitHub API.
Get rustc commit hash from channel manifest … added in rust-lang/rust#44218, instead of using the GitHub API. Also upgrade to rustc 1.22.0-nightly (d93036a04 2017-09-07). <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18420) <!-- Reviewable:end -->
…om servo:toml); r=nox,emilio … added in rust-lang/rust#44218, instead of using the GitHub API. Also upgrade to rustc 1.22.0-nightly (d93036a04 2017-09-07). Source-Repo: https://github.com/servo/servo Source-Revision: af077a722225193b38d80622fb939b7719b46db0 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 4ec174151648685b4eb0204ec8798d4f82fde9c9
…om servo:toml); r=nox,emilio … added in rust-lang/rust#44218, instead of using the GitHub API. Also upgrade to rustc 1.22.0-nightly (d93036a04 2017-09-07). Source-Repo: https://github.com/servo/servo Source-Revision: af077a722225193b38d80622fb939b7719b46db0
…om servo:toml); r=nox,emilio … added in rust-lang/rust#44218, instead of using the GitHub API. Also upgrade to rustc 1.22.0-nightly (d93036a04 2017-09-07). Source-Repo: https://github.com/servo/servo Source-Revision: af077a722225193b38d80622fb939b7719b46db0
…om servo:toml); r=nox,emilio … added in rust-lang/rust#44218, instead of using the GitHub API. Also upgrade to rustc 1.22.0-nightly (d93036a04 2017-09-07). Source-Repo: https://github.com/servo/servo Source-Revision: af077a722225193b38d80622fb939b7719b46db0 UltraBlame original commit: b674d9f6d1d65fba6b68cb847619d1c7d84c0d4c
…om servo:toml); r=nox,emilio … added in rust-lang/rust#44218, instead of using the GitHub API. Also upgrade to rustc 1.22.0-nightly (d93036a04 2017-09-07). Source-Repo: https://github.com/servo/servo Source-Revision: af077a722225193b38d80622fb939b7719b46db0 UltraBlame original commit: b674d9f6d1d65fba6b68cb847619d1c7d84c0d4c
…om servo:toml); r=nox,emilio … added in rust-lang/rust#44218, instead of using the GitHub API. Also upgrade to rustc 1.22.0-nightly (d93036a04 2017-09-07). Source-Repo: https://github.com/servo/servo Source-Revision: af077a722225193b38d80622fb939b7719b46db0 UltraBlame original commit: b674d9f6d1d65fba6b68cb847619d1c7d84c0d4c
The full hash is necessary to build the download URL for "alternate" compiler builds. This is a first step for rust-lang/rustup#1099.