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 16758/week @ 2024-07-30 15325/week @ 2024-08-06 14858/week @ 2024-08-13 17150/week @ 2024-08-20 13914/week @ 2024-08-27 15988/week @ 2024-09-03 13834/week @ 2024-09-10 13214/week @ 2024-09-17 15768/week @ 2024-09-24 17560/week @ 2024-10-01 14482/week @ 2024-10-08 15807/week @ 2024-10-15 19334/week @ 2024-10-22 21390/week @ 2024-10-29 20358/week @ 2024-11-05 16825/week @ 2024-11-12

81,167 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