57 releases

0.14.14 Dec 15, 2023
0.14.13 Oct 7, 2023
0.14.11 Aug 10, 2023
0.14.10 Feb 14, 2023
0.1.12 Nov 3, 2017

#13 in Build Utils

Download history 14611/week @ 2024-07-21 18383/week @ 2024-07-28 14991/week @ 2024-08-04 14565/week @ 2024-08-11 17300/week @ 2024-08-18 15073/week @ 2024-08-25 14761/week @ 2024-09-01 14268/week @ 2024-09-08 13023/week @ 2024-09-15 15103/week @ 2024-09-22 17805/week @ 2024-09-29 15209/week @ 2024-10-06 14753/week @ 2024-10-13 19595/week @ 2024-10-20 20242/week @ 2024-10-27 21719/week @ 2024-11-03

77,313 downloads per month
Used in 146 crates (13 directly)

Apache-2.0

1MB
2.5K SLoC

Contains (WOFF font, 400KB) NanumBarunGothic-00000000f861df9d.ttf.woff2, (WOFF font, 135KB) FiraSans-Medium-0000000066e2bc86.woff2, (WOFF font, 130KB) FiraSans-Regular-0000000084b1ad12.woff2, (WOFF font, 82KB) SourceSerif4-Bold-00000000ad926a49.ttf.woff2, (WOFF font, 77KB) SourceSerif4-Regular-0000000007da4a04.ttf.woff2, (WOFF font, 45KB) SourceCodePro-It-00000000668aca82.ttf.woff2 and 3 more.

ci_info

crates.io CI codecov
license Libraries.io for GitHub Documentation downloads
Built with cargo-make

Provides current CI environment information.

Overview

This library main goal is to provide development/build tools such as cargo-make the needed information on the current CI environment.
Inspired by the ci-info npm module.

Usage

Simply include the library and invoke the get function to pull all info as follows:

Fetching Info

fn main() {
    // Just check if a CI environment is detected.
    let ci = ci_info::is_ci();
    println!("Is CI: {}", ci);

    // Get CI environment information
    let info = ci_info::get();
    println!("Is CI: {}", info.ci);
    if let Some(vendor) = info.vendor {
        println!("Vendor: {:#?}", vendor);
        println!("Name: {:#?}", info.name.unwrap());
    }
    if let Some(pr) = info.pr {
        println!("Is PR: {:#?}", pr);
    }
    if let Some(branch_name) = info.branch_name {
        println!("Branch Name: {:#?}", branch_name);
    }
}

Mocking CI environment

use ci_info::types::{CiInfo, Vendor};

fn main() {
    // create the CI info manually
    let mut mock_info = CiInfo::new();
    mock_info.vendor = Some(Vendor::TravisCI);
    mock_info.ci = true;
    mock_info.pr = Some(true);
    mock_info.branch_name = Some("dev_branch".to_string());

    // mock environment
    ci_info::mock_ci(&mock_info);

    let info = ci_info::get();

    assert!(info.ci);
    assert!(info.pr.unwrap());
    assert_eq!(info.vendor.unwrap(), Vendor::TravisCI);
    assert_eq!(info.name.unwrap(), "Travis CI");
    assert_eq!(info.branch_name.unwrap(), "dev_branch");

    // clear CI environment
    mock_info = CiInfo::new();
    ci_info::mock_ci(&mock_info);

    let info = ci_info::get();

    assert!(!info.ci);
}

Installation

In order to use this library, just add it as a dependency:

[dependencies]
ci_info = "^0.14.14"

There is optional serde support that can be enabled via the serde-1 feature:

[dependencies]
ci_info = { version = "*", features = ["serde-1"] }

API Documentation

See full docs at: API Docs

Contributing

See contributing guide

Release History

See Changelog

License

Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.

Dependencies

~3.5MB
~25K SLoC