Crates.io | fail_on_ci |
lib.rs | fail_on_ci |
version | 0.1.7 |
source | src |
created_at | 2021-02-05 12:56:58.056895 |
updated_at | 2021-02-05 15:00:21.907887 |
description | Script to abort compilation if one of the known CI-Servers is detected. |
homepage | |
repository | https://github.com/hardliner66/fail_on_ci |
max_upload_size | |
id | 351047 |
size | 16,569 |
Have you ever written temporary test code, forgot about it and push it to prod?
This crate provides you with a macro which fails to compile on known CI servers. Just wrap your test code in it and it will only compile it locally.
Most CI servers define specific environment variables which can be used to detect if a process is running on a CI server.
Below is a list of the CI servers that should be detected.
Alternatively you can set the environment variable FAIL_ON_CI
to true
. This can be used for CI servers that are not supported.
use fail_on_ci::*;
// Struct used for local test
#[derive(FailOnCi)]
struct TestStruct {}
// alias for FailOnCi
#[derive(TempStruct)]
struct TestStruct2 {}
#[temp_function]
fn test_function() -> bool {
true
}
fn main() {
// insert arbitrary code
fail_on_ci!{
println!("This doesn't compile on CI!");
}
// alias for fail_on_ci
temp_code!{
println!("This doesn't compile on CI!");
}
// returns true
if temp_true!() {
println!("Hello, world!");
}
// returns false
if temp_false!() {
println!("Hello, world!");
}
}