7 unstable releases

0.4.0 Feb 1, 2025
0.3.0 Apr 11, 2024
0.2.2 Mar 26, 2024
0.2.1 Sep 22, 2023
0.1.1 Mar 16, 2023

#767 in Development tools

Download history 83/week @ 2024-10-23 109/week @ 2024-10-30 92/week @ 2024-11-06 104/week @ 2024-11-13 132/week @ 2024-11-20 155/week @ 2024-11-27 159/week @ 2024-12-04 68/week @ 2024-12-11 30/week @ 2024-12-18 134/week @ 2024-12-25 217/week @ 2025-01-01 245/week @ 2025-01-08 22/week @ 2025-01-15 316/week @ 2025-01-22 465/week @ 2025-01-29 361/week @ 2025-02-05

1,196 downloads per month

MIT license

42KB
990 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.3–0.9MB
~21K SLoC