- Notifications
You must be signed in to change notification settings - Fork3
Provides current CI environment information.
License
NotificationsYou must be signed in to change notification settings
sagiegurari/ci_info
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Provides current CI environment information.
This library main goal is to provide development/build tools such ascargo-make the needed information on the current CI environment.
Inspired by theci-info npm module.
Simply include the library and invoke the get function to pull all info as follows:
fnmain(){// Just check if a CI environment is detected.let ci = ci_info::is_ci();println!("Is CI: {}", ci);// Get CI environment informationlet info = ci_info::get();println!("Is CI: {}", info.ci);ifletSome(vendor) = info.vendor{println!("Vendor: {:#?}", vendor);println!("Name: {:#?}", info.name.unwrap());}ifletSome(pr) = info.pr{println!("Is PR: {:#?}", pr);}ifletSome(branch_name) = info.branch_name{println!("Branch Name: {:#?}", branch_name);}}
use ci_info::types::{CiInfo,Vendor};fnmain(){// create the CI info manuallyletmut 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);}
In order to use this library, just add it as a dependency:
[dependencies]ci_info ="^0.14.14"
There is optionalserde
support that can be enabled via theserde-1
feature:
[dependencies]ci_info = {version ="*",features = ["serde-1"] }
See full docs at:API Docs
SeeChangelog
Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.
About
Provides current CI environment information.
Topics
Resources
License
Stars
Watchers
Forks
Packages0
No packages published