is_ci-1.1.1/.cargo_vcs_info.json 0000644 00000000112 00000000001 0012114 0 ustar {
"git": {
"sha1": "c21402d64e69c275367c3cbd0e6f02c432214f49"
}
}
is_ci-1.1.1/.editorconfig 0000644 0000000 0000000 00000000231 00726746425 0013413 0 ustar 0000000 0000000 # top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
is_ci-1.1.1/.gitignore 0000644 0000000 0000000 00000000023 00726746425 0012725 0 ustar 0000000 0000000 /target
Cargo.lock
is_ci-1.1.1/CHANGELOG.md 0000644 0000000 0000000 00000001134 00726746425 0012552 0 ustar 0000000 0000000 # `is_ci` Release Changelog
## 1.1.1 (2021-09-22)
### Bug Fixes
* **now:** fix typo in bitbucket check ([d89ed22f](https://github.com/zkat/is_ci/commit/d89ed22fa489ef4fb8fda5eaf54e26610900b4e1))
## 1.1.0 (2021-09-22)
### Features
* **api:** Add cache/uncached APIs and deprecate is_ci ([adc5ec15](https://github.com/zkat/is_ci/commit/adc5ec152503f9ef6157f487fd7fc4ea251b4ff6))
## 1.0.0 (2021-09-22)
### Features
* **api:** Add initial API ([301f0a9b](https://github.com/zkat/is_ci/commit/301f0a9ba418da349140e93f2c031f2fd83c9a8a))
is_ci-1.1.1/Cargo.toml 0000644 00000001665 00000000001 0010130 0 ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "is_ci"
version = "1.1.1"
authors = ["Kat Marchán "]
description = "Super lightweight CI environment checker. Just tells you if you're in CI or not without much fuss."
documentation = "https://docs.rs/is_ci"
readme = "README.md"
keywords = ["ci", "build"]
categories = ["development-tools", "development-tools::build-utils", "development-tools::testing"]
license = "ISC"
repository = "https://github.com/zkat/is_ci"
[dependencies]
is_ci-1.1.1/Cargo.toml.orig 0000644 0000000 0000000 00000001115 00726746425 0013627 0 ustar 0000000 0000000 [package]
name = "is_ci"
version = "1.1.1"
edition = "2018"
authors = ["Kat Marchán "]
description = "Super lightweight CI environment checker. Just tells you if you're in CI or not without much fuss."
repository = "https://github.com/zkat/is_ci"
documentation = "https://docs.rs/is_ci"
license = "ISC"
keywords = ["ci", "build"]
categories = [
"development-tools",
"development-tools::build-utils",
"development-tools::testing",
]
readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
is_ci-1.1.1/LICENSE 0000644 0000000 0000000 00000001414 00726746425 0011747 0 ustar 0000000 0000000 The ISC License
Copyright (c) Kat Marchán and other contributors.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.Apache License
is_ci-1.1.1/Makefile.toml 0000644 0000000 0000000 00000000424 00726746425 0013354 0 ustar 0000000 0000000 [tasks.changelog]
workspace=false
install_crate="git-cliff"
command = "git-cliff"
args = ["--prepend", "CHANGELOG.md", "-u", "--tag", "${@}"]
[tasks.release]
workspace=false
install_crate="cargo-release"
command = "cargo"
args = ["release", "--workspace", "${@}"]
is_ci-1.1.1/README.md 0000644 0000000 0000000 00000001743 00726746425 0012226 0 ustar 0000000 0000000 This crate tells you if you're in a CI environment or not. It does not tell
you **which** you're in, but it makes a good effort to make sure to accurately
tell you whether you're in one.
This crate is based on the
[`@npmcli/ci-detect`](https://npm.im/@npmcli/ci-detect) package.
If you need more information about the specific CI environment you're running
in and you can handle a heavier dependency, please consider using
[`ci_info`](https://crates.io/crates/ci_info) instead.
## Example
```rust
// You can call this repeatedly if you want to get the same result, cached.
let am_i_in_ci_right_now = is_ci::cached();
// If you expect your environment to change between calls, use this instead:
let checking_again_just_in_case = is_ci::uncached();
```
## License
`is_ci` is released to the Rust community under the [ISC License](./LICENSE).
It is based on `@npmcli/ci-detect` which is released to the community under
the [ISC License](https://github.com/npm/ci-detect/blob/main/LICENSE).
is_ci-1.1.1/cliff.toml 0000644 0000000 0000000 00000003550 00726746425 0012725 0 ustar 0000000 0000000 # configuration file for git-cliff (0.1.0)
[changelog]
# changelog header
header = """
# `is_ci` Release Changelog
"""
# template for the changelog body
# https://tera.netlify.app/docs/#introduction
body = """
{% if version %}\
## {{ version | replace(from="v", to="") }} ({{ timestamp | date(format="%Y-%m-%d") }})
{% else %}\
## Unreleased
{% endif %}\
{% for group, commits in commits | filter(attribute="scope") | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
{% if commit.scope %}\
* **{{ commit.scope }}:** {{ commit.message }} ([{{ commit.id | truncate(length=8, end="") }}](https://github.com/zkat/is_ci/commit/{{ commit.id }}))
{%- if commit.breaking %}
* **BREAKING CHANGE**: {{ commit.breaking_description }}
{%- endif %}\
{% endif %}\
{% endfor %}
{% endfor %}
"""
# remove the leading and trailing whitespace from the template
trim = false
# changelog footer
# footer = """
#
# """
[git]
# allow only conventional commits
# https://www.conventionalcommits.org
conventional_commits = true
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat*", group = "Features"},
{ message = "^fix*", group = "Bug Fixes"},
{ message = "^doc*", group = "Documentation"},
{ message = "^perf*", group = "Performance"},
{ message = "^refactor*", group = "Refactor"},
{ message = "^style*", group = "Styling"},
{ message = "^test*", group = "Testing"},
{ message = "^chore\\(release\\): prepare for*", skip = true},
{ message = "^chore*", group = "Miscellaneous Tasks"},
{ body = ".*security", group = "Security"},
]
# filter out the commits that are not matched by commit parsers
filter_commits = true
# glob pattern for matching git tags
# tag_pattern = "v?[0-9]*"
# regex for skipping tags
# skip_tags = "v0.1.0-beta.1"
is_ci-1.1.1/src/lib.rs 0000644 0000000 0000000 00000004476 00726746425 0012660 0 ustar 0000000 0000000 use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Once;
static INIT: Once = Once::new();
static IS_CI: AtomicBool = AtomicBool::new(false);
/// Returns true if the current environment is found to probably be a CI
/// environment or service. That's it, that's all it does.
#[deprecated(since = "1.1.0", note = "Use `cached` or `uncached` instead")]
pub fn is_ci() -> bool {
uncached()
}
/// Returns true if the current environment is found to probably be a CI
/// environment or service, and caches the result for future calls. If you
/// expect the environment to change, use [uncached].
pub fn cached() -> bool {
INIT.call_once(|| IS_CI.store(uncached(), Ordering::Relaxed));
IS_CI.load(Ordering::Relaxed)
}
/// Returns true if the current environment is found to probably be a CI
/// environment or service. If you expect to call this multiple times without
/// the environment changing, use [cached].
pub fn uncached() -> bool {
let ci_var = std::env::var("CI");
ci_var == Ok("true".into())
|| ci_var == Ok("1".into())
|| check("CI_NAME")
|| check("GITHUB_ACTION")
|| check("GITLAB_CI")
|| check("NETLIFY")
|| check("TRAVIS")
|| matches!(std::env::var("NODE"), Ok(node) if node.ends_with("//heroku/node/bin/node"))
|| check("CODEBUILD_SRC_DIR")
|| check("BUILDER_OUTPUT")
|| check("GITLAB_DEPLOYMENT")
|| check("NOW_GITHUB_DEPLOYMENT")
|| check("NOW_BUILDER")
|| check("BITBUCKET_DEPLOYMENT")
|| check("GERRIT_PROJECT")
|| check("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI")
|| check("BITRISE_IO")
|| check("BUDDY_WORKSPACE_ID")
|| check("BUILDKITE")
|| check("CIRRUS_CI")
|| check("APPVEYOR")
|| check("CIRCLECI")
|| check("SEMAPHORE")
|| check("DRONE")
|| check("DSARI")
|| check("TDDIUM")
|| check("STRIDER")
|| check("TASKCLUSTER_ROOT_URL")
|| check("JENKINS_URL")
|| check("bamboo.buildKey")
|| check("GO_PIPELINE_NAME")
|| check("HUDSON_URL")
|| check("WERCKER")
|| check("MAGNUM")
|| check("NEVERCODE")
|| check("RENDER")
|| check("SAIL_CI")
|| check("SHIPPABLE")
}
fn check(name: &str) -> bool {
std::env::var(name).is_ok()
}