https://github.com/swellaby/ci-detective
CI environment detector
https://github.com/swellaby/ci-detective
ci ci-environment detect go golang
Last synced: about 1 month ago
JSON representation
CI environment detector
- Host: GitHub
- URL: https://github.com/swellaby/ci-detective
- Owner: swellaby
- License: mit
- Created: 2018-10-13T16:28:15.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-09-27T16:56:25.000Z (over 2 years ago)
- Last Synced: 2025-03-28T08:35:41.263Z (about 2 months ago)
- Topics: ci, ci-environment, detect, go, golang
- Language: Go
- Homepage:
- Size: 1000 KB
- Stars: 1
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# ci-detective
Simple utility to detect whether you are running in a CI server/environment[![Latest Release][github-release-badge]][github-release-url]
[![GoDoc][godoc-badge]][godoc-url]
[![License Badge][license-badge]][license-url][![Linux CI Badge][linux-ci-badge]][linux-ci-url]
[![Mac CI Badge][mac-ci-badge]][mac-ci-url]
[![Windows CI Badge][windows-ci-badge]][windows-ci-url][![Go Report Card][go-report-card-badge]][go-report-card-url]
[![Test Results Badge][tests-badge]][sonar-tests-url]
[![Codecov Badge][codecov-badge]][codecov-url]
[![Sonar Quality Gate Badge][sonar-quality-gate-badge]][sonar-url]
## Installation
`ci-detective` is available as both an executable/cli and a package/api.Grab a [binary release][github-release-url] or use `go get`:
```sh
go get -u github.com/swellaby/ci-detective
```If you want to consume the package/api programmatically, just add the package import:
```go
import (
"github.com/swellaby/ci-detective/cidetective"
)
```## Usage
### CLI
To use `ci-detective` as a CLI simply run the command:```sh
ci-detective
```The CLI will return an exit code of Zero if it detects the current environment is a CI engine/server. Otherwise it will return a non-Zero exit code.
### Lib
The `cidetective` package exposes a single function: `IsCI` that returns a boolean indicating whether or not the current environment is a CI server/engine.```go
package mainimport (
"fmt"
"github.com/swellaby/ci-detective/cidetective"
)func main() {
if cidetective.IsCI() {
fmt.Println("Running in a CI environment!")
} else {
fmt.Println("Nope, this is NOT a CI environment!")
}
}
```### Generator
Initially created by this [swell generator][parent-generator-url]!### Supported CIs
- [Woodpecker CI][woodpecker-ci]
[github-release-badge]: https://img.shields.io/github/release/swellaby/ci-detective?style=flat-square
[github-release-url]: https://github.com/swellaby/ci-detective/releases/latest
[go-report-card-badge]: https://goreportcard.com/badge/github.com/swellaby/ci-detective?style=flat-square
[go-report-card-url]: https://goreportcard.com/report/github.com/swellaby/ci-detective
[godoc-badge]: https://img.shields.io/badge/godoc-reference-blue?style=flat-square
[godoc-url]: https://godoc.org/github.com/swellaby/ci-detective/cidetective
[license-url]: ./LICENSE
[license-badge]: https://img.shields.io/github/license/swellaby/ci-detective.svg?style=flat-square&color=blue
[linux-ci-badge]: https://img.shields.io/azure-devops/build/swellaby/opensource/134/master?style=flat-square&label=linux%20build
[linux-ci-url]: https://dev.azure.com/swellaby/OpenSource/_build/latest?definitionId=134
[mac-ci-badge]: https://img.shields.io/azure-devops/build/swellaby/opensource/131/master?style=flat-square&label=mac%20build
[mac-ci-url]: https://dev.azure.com/swellaby/OpenSource/_build/latest?definitionId=131
[windows-ci-badge]: https://img.shields.io/azure-devops/build/swellaby/opensource/133/master?style=flat-square&label=windows%20build
[windows-ci-url]: https://dev.azure.com/swellaby/OpenSource/_build/latest?definitionId=133
[codecov-badge]: https://img.shields.io/codecov/c/github/swellaby/ci-detective.svg?style=flat-square
[codecov-url]: https://codecov.io/gh/swellaby/ci-detective
[tests-badge]: https://img.shields.io/azure-devops/tests/swellaby/opensource/134?style=flat-square
[sonar-quality-gate-badge]: https://img.shields.io/sonar/quality_gate/swellaby:ci-detective?server=https%3A%2F%2Fsonarcloud.io&style=flat-square
[sonar-url]: https://sonarcloud.io/dashboard?id=swellaby%3Aci-detective
[sonar-tests-url]: https://sonarcloud.io/component_measures?id=swellaby%3Aci-detective&metric=tests
[parent-generator-url]: https://github.com/swellaby/generator-lets-go
[woodpecker-ci]: https://woodpecker-ci.org