From a593d88ea458d969a152446877676602fcbda3fa Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Wed, 1 May 2019 08:33:17 +0100 Subject: [PATCH 1/4] Add 'secret' dump-testament command In cases where users somehow get hold of versions of rustup which are not cleanly built by CI, we need a way to find out what the dirtiness was caused by. This will let us do it either by: $ rustup-init --dump-testament or, once installed, $ rustup dump-testament Signed-off-by: Daniel Silverstone --- src/cli/common.rs | 24 ++++++++++++++++++++++++ src/cli/rustup_mode.rs | 6 ++++++ src/cli/setup_mode.rs | 7 +++++++ 3 files changed, 37 insertions(+) diff --git a/src/cli/common.rs b/src/cli/common.rs index 40de32802e..14a579c759 100644 --- a/src/cli/common.rs +++ b/src/cli/common.rs @@ -431,6 +431,30 @@ pub fn version() -> &'static str { &RENDERED } +pub fn dump_testament() { + use git_testament::GitModification::*; + println!("Rustup version renders as: {}", version()); + println!("Current crate version: {}", env!("CARGO_PKG_VERSION")); + if TESTAMENT.branch_name.is_some() { + println!("Built from branch: {}", TESTAMENT.branch_name.unwrap()); + } else { + println!("Branch information missing"); + } + println!("Commit info: {}", TESTAMENT.commit); + if TESTAMENT.modifications.is_empty() { + println!("Working tree is clean"); + } else { + for fmod in TESTAMENT.modifications { + match fmod { + Added(f) => println!("Added: {}", String::from_utf8_lossy(f)), + Removed(f) => println!("Removed: {}", String::from_utf8_lossy(f)), + Modified(f) => println!("Modified: {}", String::from_utf8_lossy(f)), + Untracked(f) => println!("Untracked: {}", String::from_utf8_lossy(f)), + } + } + } +} + pub fn report_error(e: &Error) { err!("{}", e); diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index 2f5243a5e6..0c5ea2ce0e 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -39,6 +39,7 @@ pub fn main() -> Result<()> { cfg.check_metadata_version()?; match matches.subcommand() { + ("dump-testament", _) => common::dump_testament(), ("show", Some(c)) => match c.subcommand() { ("active-toolchain", Some(_)) => handle_epipe(show_active_toolchain(cfg))?, (_, _) => handle_epipe(show(cfg))?, @@ -115,6 +116,11 @@ pub fn cli() -> App<'static, 'static> { .short("v") .long("verbose"), ) + .subcommand( + SubCommand::with_name("dump-testament") + .about("Dump information about the build") + .setting(AppSettings::Hidden) // Not for users, only CI + ) .subcommand( SubCommand::with_name("show") .about("Show the active and installed toolchains") diff --git a/src/cli/setup_mode.rs b/src/cli/setup_mode.rs index d2379663b7..8526beed1b 100644 --- a/src/cli/setup_mode.rs +++ b/src/cli/setup_mode.rs @@ -13,6 +13,13 @@ pub fn main() -> Result<()> { if arg1 == Some("--self-replace") { return self_update::self_replace(); } + + // Internal testament dump used during CI. Not for users. + if arg1 == Some("--dump-testament") { + common::dump_testament(); + return Ok(()); + } + // XXX: If you change anything here, please make the same changes in rustup-init.sh let cli = App::new("rustup-init") .version(common::version()) From 3f740b64293b53ada2cbdda68e2aee4f21308a65 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Wed, 1 May 2019 08:41:57 +0100 Subject: [PATCH 2/4] appveyor: Clean up after install We were leaving a `rustup-init.exe` behind which dirtied the git repository, meaning that the version number was unpleasant for Windows users. This fixes that. Signed-off-by: Daniel Silverstone --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index a01e67c034..5d695c9ca6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -50,6 +50,7 @@ install: - appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe - rustup-init.exe -y --default-host=x86_64-pc-windows-msvc - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin + - del rustup-init.exe # Install the target we're compiling for - if NOT "%TARGET%" == "x86_64-pc-windows-msvc" rustup target add %TARGET% From 9b7c3334bd59c37c3e008f88f030c2f0e73b219d Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Wed, 1 May 2019 08:58:11 +0100 Subject: [PATCH 3/4] CI: Dump testament during build To allow us to ensure that we do not have unexpected version strings due to dirty builds etc, dump the testament after the build but before running the tests. We can't do this for unusual cross-builds but for the most part we can do it on at least one of each of our major platforms. Signed-off-by: Daniel Silverstone --- appveyor.yml | 1 + ci/run.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 5d695c9ca6..be957f7a52 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -67,6 +67,7 @@ build: false test_script: - cargo build --release --target %TARGET% --locked + - cargo run --release --target %TARGET% --locked -- --dump-testament - cargo test --release --target %TARGET% notifications: diff --git a/ci/run.sh b/ci/run.sh index e61adaed42..d6092bcc30 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -8,6 +8,7 @@ cargo -vV cargo build --locked -v --release --target "$TARGET" --features vendored-openssl if [ -z "$SKIP_TESTS" ]; then + cargo run --locked --release --target "$TARGET" --features vendored-openssl -- --dump-testament cargo test --release -p download --target "$TARGET" --features vendored-openssl cargo test --release --target "$TARGET" --features vendored-openssl fi From e8a92d105b633c1f078a61177d9c23f191f0f276 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Wed, 1 May 2019 09:03:10 +0100 Subject: [PATCH 4/4] CONTRIBUTING.md: Verify versions during release build Once we've made the builds on stable, add a double-check step to ensure that the version numbers reported by the various built versions of `rustup-init` actually are the correct versions as expected for the build. Dirty git repos, missed updates, etc will show here. Signed-off-by: Daniel Silverstone --- CONTRIBUTING.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 350baf8d1d..41d57edce4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,6 +51,9 @@ Rustup is distributed. The steps for a release are: 5. While you wait for green CI, double-check the `rustup-init.sh` functionality and `rustup-init` just in case. 6. Ensure all of CI is green on the `stable` branch. + Once it is, check through a representative proportion of the builds looking + for the reported version statements to ensure that we definitely built something + cleanly which reports as the right version number when run `--version`. 7. Ping someone in the release team to perform the actual release. They can find instructions in `ci/sync-dist.py` Note: Some manual testing occurs here, so hopefully they'll catch