Skip to main content

fallow_engine/
ci_env.rs

1//! Continuous integration detection shared by the API runtime and the CLI.
2//!
3//! Every surface that changes behavior in CI (next-step hints, telemetry, the
4//! update check, the cache notice and the Impact record gate) reads this one
5//! predicate, so the surfaces cannot disagree about what counts as CI.
6
7/// Environment variables whose presence marks a CI run.
8const CI_ENV_VARS: [&str; 3] = ["CI", "GITHUB_ACTIONS", "GITLAB_CI"];
9
10/// Returns `true` when the process runs in CI.
11///
12/// The check is presence-only: `CI`, `GITHUB_ACTIONS` or `GITLAB_CI` set to any
13/// value (also an empty value) marks a CI run.
14#[must_use]
15pub fn is_ci() -> bool {
16    CI_ENV_VARS
17        .iter()
18        .any(|name| std::env::var_os(name).is_some())
19}