Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Provides current CI environment information.

License

NotificationsYou must be signed in to change notification settings

sagiegurari/ci_info

Repository files navigation

crates.ioCIcodecov
licenseLibraries.io for GitHubDocumentationdownloads
Built with cargo-make

Provides current CI environment information.

Overview

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.

Usage

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

Fetching Info

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);}}

Mocking CI environment

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);}

Installation

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"] }

API Documentation

See full docs at:API Docs

Contributing

Seecontributing guide

Release History

SeeChangelog

License

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


[8]ページ先頭

©2009-2025 Movatter.jp