Skip to content

is_ci

Whether the environment looks like a CI run.

The same as detect(get).is_some(). The environment is a parameter: pass &|name| std::env::var(name).ok() for the real one.

use helpers4::ci::is_ci;

Cargo feature ci (enabled by default). To compile only this module:

cargo add helpers4 --no-default-features --features ci

or in Cargo.toml:

[dependencies]
helpers4 = { version = "0.0.6", default-features = false, features = ["ci"] }
pub fn is_ci(get: &dyn Fn(&str) -> Option<String>) -> bool
ParameterTypeDescription
get&dyn Fn(&str) -> Option<String>Looks a variable up by name.

booltrue when a known CI service, or a truthy CI variable, is present.

use helpers4::ci::is_ci;

assert!(is_ci(&|name: &str| (name == "CI").then(|| "true".to_string())));
assert!(!is_ci(&|_: &str| None));

src/ci/is_ci.rs