]>
git.proxmox.com Git - rustc.git/blob - src/tools/build_helper/src/ci.rs
1 use std
::process
::Command
;
3 #[derive(Copy, Clone, PartialEq, Eq, Debug)]
5 /// Not a CI environment.
7 /// The Azure Pipelines environment, for Linux (including Docker), Windows, and macOS builds.
9 /// The GitHub Actions environment, for Linux (including Docker), Windows and macOS builds.
14 /// Obtains the current CI environment.
15 pub fn current() -> CiEnv
{
16 if std
::env
::var("TF_BUILD").map_or(false, |e
| e
== "True") {
18 } else if std
::env
::var("GITHUB_ACTIONS").map_or(false, |e
| e
== "true") {
25 pub fn is_ci() -> bool
{
26 Self::current() != CiEnv
::None
29 /// If in a CI environment, forces the command to run with colors.
30 pub fn force_coloring_in_ci(self, cmd
: &mut Command
) {
31 if self != CiEnv
::None
{
32 // Due to use of stamp/docker, the output stream of rustbuild is not
33 // a TTY in CI, so coloring is by-default turned off.
34 // The explicit `TERM=xterm` environment is needed for
35 // `--color always` to actually work. This env var was lost when
36 // compiling through the Makefile. Very strange.
37 cmd
.env("TERM", "xterm").args(&["--color", "always"]);