1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use std::env;

/// Check if we are running in `CI` by checking the 'RUN_IN_CI' env var
pub fn running_in_ci() -> bool {
    env::var("RUN_IN_CI").unwrap_or_default() == "1"
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn check_runing_in_ci_env_var() {
        assert!(!running_in_ci());
        // now set the env var
        env::set_var("RUN_IN_CI", "1");
        assert!(running_in_ci());
        // reset
        env::set_var("RUN_IN_CI", "");
    }
}