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

#14 in Build Utils

Download history 16654/week @ 2024-08-15 14664/week @ 2024-08-22 15103/week @ 2024-08-29 15279/week @ 2024-09-05 13931/week @ 2024-09-12 13391/week @ 2024-09-19 16500/week @ 2024-09-26 17266/week @ 2024-10-03 13814/week @ 2024-10-10 17846/week @ 2024-10-17 19728/week @ 2024-10-24 22528/week @ 2024-10-31 18982/week @ 2024-11-07 19402/week @ 2024-11-14 19068/week @ 2024-11-21 13942/week @ 2024-11-28

75,824 downloads per month
Used in 149 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