From fb78d96bc87cf87a6798021b1a86b3ad6378cdc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 28 Sep 2022 14:18:01 -0400 Subject: [PATCH] Add rust-lang CI environment check --- src/bootstrap/config.rs | 2 +- src/bootstrap/util.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 74530dec97b70..43b18f7902d96 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -1294,7 +1294,7 @@ impl Config { // CI should always run stage 2 builds, unless it specifically states otherwise #[cfg(not(test))] - if flags.stage.is_none() && crate::CiEnv::current() != crate::CiEnv::None { + if flags.stage.is_none() && crate::CiEnv::is_rust_lang_ci() { match config.cmd { Subcommand::Test { .. } | Subcommand::Doc { .. } diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index 0ebabbd5ca5c0..867efc6584d87 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -264,6 +264,21 @@ impl CiEnv { Self::current() != CiEnv::None } + pub fn is_rust_lang_ci() -> bool { + if let Ok(rust_lang_ci) = env::var("RUST_LANG_CI") { + match rust_lang_ci.as_str() { + "1" | "true" | "yes" | "on" => true, + "0" | "false" | "no" | "off" => false, + other => { + // Let's make sure typos don't go unnoticed + panic!("Unrecognized option '{}' set in RUST_LANG_CI", other) + } + } + } else { + Self::is_ci() + } + } + /// If in a CI environment, forces the command to run with colors. pub fn force_coloring_in_ci(self, cmd: &mut Command) { if self != CiEnv::None {