6 releases

0.3.0 Apr 11, 2024
0.2.2 Mar 26, 2024
0.2.1 Sep 22, 2023
0.2.0 Mar 16, 2023
0.1.1 Mar 16, 2023

#452 in Development tools

Download history 18/week @ 2024-01-01 62/week @ 2024-01-08 33/week @ 2024-01-15 130/week @ 2024-01-22 169/week @ 2024-01-29 233/week @ 2024-02-05 170/week @ 2024-02-12 108/week @ 2024-02-19 212/week @ 2024-02-26 229/week @ 2024-03-04 125/week @ 2024-03-11 294/week @ 2024-03-18 276/week @ 2024-03-25 254/week @ 2024-04-01 384/week @ 2024-04-08 319/week @ 2024-04-15

1,239 downloads per month

MIT license

40KB
948 lines

ci_env

Crates.io Crates.io

Detects CI (continuous integration) information from the current environment.

Usage

To start, detect if in a CI environment.

ci_env::is_ci();

Or detect which CI provider is being used.

ci_env::detect_provider(); // GithubActions

And most importantly, extract information about the CI environment and CI provider. This includes branch, commit, and pull request information.

use ci_env::get_environment;

if let Some(ci) = get_environment() {
	println!("Provider: {:?}", ci.provider);
	println!("Branch: {}", ci.branch);
	println!("Commit: {}", ci.revision);

	if let Some(pr_number) = ci.request_id {
		println!("PR #: {}", pr_number);
	}
}

This library will properly take into account source and target branches when a pull request is involved. Do note though that not all providers provide this information.

Dependencies

~0.4–1MB
~24K SLoC