Skip to content

Commit 4d78d11

Browse files
authored
Rollup merge of #128342 - onur-ozkan:ci-env-usage, r=Kobzol
simplify the use of `CiEnv` self-explanatory
2 parents a73a025 + 06d64ea commit 4d78d11

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

src/bootstrap/src/core/build_steps/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
20862086
let git_config = builder.config.git_config();
20872087
cmd.arg("--git-repository").arg(git_config.git_repository);
20882088
cmd.arg("--nightly-branch").arg(git_config.nightly_branch);
2089-
cmd.force_coloring_in_ci(builder.ci_env);
2089+
cmd.force_coloring_in_ci();
20902090

20912091
#[cfg(feature = "build-metrics")]
20922092
builder.metrics.begin_test_suite(

src/bootstrap/src/core/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2157,7 +2157,7 @@ impl<'a> Builder<'a> {
21572157
// Try to use a sysroot-relative bindir, in case it was configured absolutely.
21582158
cargo.env("RUSTC_INSTALL_BINDIR", self.config.bindir_relative());
21592159

2160-
cargo.force_coloring_in_ci(self.ci_env);
2160+
cargo.force_coloring_in_ci();
21612161

21622162
// When we build Rust dylibs they're all intended for intermediate
21632163
// usage, so make sure we pass the -Cprefer-dynamic flag instead of

src/bootstrap/src/core/config/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2092,7 +2092,7 @@ impl Config {
20922092

20932093
// CI should always run stage 2 builds, unless it specifically states otherwise
20942094
#[cfg(not(test))]
2095-
if flags.stage.is_none() && crate::CiEnv::current() != crate::CiEnv::None {
2095+
if flags.stage.is_none() && build_helper::ci::CiEnv::is_ci() {
20962096
match config.cmd {
20972097
Subcommand::Test { .. }
20982098
| Subcommand::Miri { .. }

src/bootstrap/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use std::sync::OnceLock;
2626
use std::time::SystemTime;
2727
use std::{env, io, str};
2828

29-
use build_helper::ci::{gha, CiEnv};
29+
use build_helper::ci::gha;
3030
use build_helper::exit;
3131
use sha2::digest::Digest;
3232
use termcolor::{ColorChoice, StandardStream, WriteColor};
@@ -168,7 +168,6 @@ pub struct Build {
168168
crates: HashMap<String, Crate>,
169169
crate_paths: HashMap<PathBuf, String>,
170170
is_sudo: bool,
171-
ci_env: CiEnv,
172171
delayed_failures: RefCell<Vec<String>>,
173172
prerelease_version: Cell<Option<u32>>,
174173

@@ -400,7 +399,6 @@ impl Build {
400399
crates: HashMap::new(),
401400
crate_paths: HashMap::new(),
402401
is_sudo,
403-
ci_env: CiEnv::current(),
404402
delayed_failures: RefCell::new(Vec::new()),
405403
prerelease_version: Cell::new(None),
406404

src/bootstrap/src/utils/exec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ impl BootstrapCommand {
175175
}
176176

177177
/// If in a CI environment, forces the command to run with colors.
178-
pub fn force_coloring_in_ci(&mut self, ci_env: CiEnv) {
179-
if ci_env != CiEnv::None {
178+
pub fn force_coloring_in_ci(&mut self) {
179+
if CiEnv::is_ci() {
180180
// Due to use of stamp/docker, the output stream of bootstrap is not
181181
// a TTY in CI, so coloring is by-default turned off.
182182
// The explicit `TERM=xterm` environment is needed for

0 commit comments

Comments
 (0)