extern crate proc_macro;
use proc_macro::TokenStream;
static CHECK_EXISTENCE: &[&str] = &[
"CODEBUILD_CI", "BUILD_DEFINITIONVERSION", "bamboo_buildKey", "BITBUCKET_COMMIT", "BUDDY", "CIRCLECI", "GITHUB_ACTIONS", "GITLAB_CI", "JENKINS_URL", "TEAMCITY_VERSION", "TRAVIS", ];
static CHECK_VALUE: &[(&str, &str)] = &[
("APPVEYOR", "True"), ("CI_NAME", "codeship"), ("CI", "drone"), ("WERCKER", "true"), ];
fn is_ci() -> bool {
CHECK_EXISTENCE.iter().map(std::env::var).flatten().count() > 0
|| CHECK_VALUE
.iter()
.filter(|(name, value)| &std::env::var(name).unwrap_or_default() == value)
.count()
> 0
}
#[proc_macro]
pub fn fail_on_ci(item: TokenStream) -> TokenStream {
if is_ci() {
panic!("Code is not allowed to compile on CI Servers!");
}
item
}