is_ci-1.2.0/.cargo_vcs_info.json0000644000000001360000000000100121220ustar { "git": { "sha1": "5e7959455a90cf9a00cafbbd533ea25d747a07d3" }, "path_in_vcs": "" }is_ci-1.2.0/.editorconfig000064400000000000000000000002221046102023000133630ustar 00000000000000# 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.2.0/.gitignore000064400000000000000000000000231046102023000126750ustar 00000000000000/target Cargo.lock is_ci-1.2.0/CHANGELOG.md000064400000000000000000000016611046102023000125270ustar 00000000000000# `is_ci` Release Changelog ## 1.2.0 (2024-02-04) ### Features * **ci:** Add WoodpeckerCI support (#1) ([7eaceabd](https://github.com/zkat/is_ci/commit/7eaceabd20b443c7f72b27c354a9965f79fd1dcc)) * **bin:** add main.rs to run it as a standalone bin (#2) ([bc4fda76](https://github.com/zkat/is_ci/commit/bc4fda761a9810a0e967d1470772fedd78d79360)) ## 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.2.0/Cargo.lock0000644000000002250000000000100100740ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "is_ci" version = "1.2.0" is_ci-1.2.0/Cargo.toml0000644000000020340000000000100101170ustar # 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.2.0" 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" [profile.release] lto = true codegen-units = 1 panic = "abort" strip = true [dependencies] is_ci-1.2.0/Cargo.toml.orig000064400000000000000000000012321046102023000135770ustar 00000000000000[package] name = "is_ci" version = "1.2.0" 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] [profile.release] panic = "abort" strip = true codegen-units = 1 lto = true is_ci-1.2.0/LICENSE000064400000000000000000000014141046102023000117170ustar 00000000000000The 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.2.0/Makefile.toml000064400000000000000000000004111046102023000133200ustar 00000000000000[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.2.0/README.md000064400000000000000000000017431046102023000121760ustar 00000000000000This 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.2.0/cliff.toml000064400000000000000000000035501046102023000126750ustar 00000000000000# 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.2.0/src/lib.rs000064400000000000000000000045531046102023000126240ustar 00000000000000use 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()) || ci_var == Ok("woodpecker".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() } is_ci-1.2.0/src/main.rs000064400000000000000000000001651046102023000127750ustar 00000000000000use is_ci::uncached; pub fn main() { let code = if uncached() { 0 } else { 1 }; std::process::exit(code); }