Documentation
¶
Overview ¶
Package ci provides utilities for detecting and handling CI/CD environments.
Usage ¶
Index ¶
- Variables
- func FailBenchmarkIfCI(b *testing.B)
- func FailBenchmarkIfNotCI(b *testing.B)
- func FailFuzzIfCI(f *testing.F)
- func FailFuzzIfNotCI(f *testing.F)
- func FailTestIfCI(t *testing.T)
- func FailTestIfNotCI(t *testing.T)
- func IsCI() bool
- func IsNotCI() bool
- func SkipBenchmarkIfCI(b *testing.B)
- func SkipBenchmarkIfNotCI(b *testing.B)
- func SkipFuzzIfCI(f *testing.F)
- func SkipFuzzIfNotCI(f *testing.F)
- func SkipTestIfCI(t *testing.T)
- func SkipTestIfNotCI(t *testing.T)
- type Testing
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var CICDEnvVars = map[string]string{
"CI": "true",
"JENKINS_URL": "",
"BUILD_REASON": "",
"AGENT_JOBSTATUS": "",
"BITBUCKET_BUILD_NUMBER": "",
"TEAMCITY_VERSION": "",
"bamboo_buildKey": "",
"APPVEYOR": "true",
"BUILDKITE": "true",
"SEMAPHORE": "true",
"SHIPPABLE": "true",
"GO_SERVER_URL": "",
"CODEBUILD_CI": "true",
"WERCKER": "true",
"STRIDER": "true",
}
CICDEnvVars format follows the pattern: `environment variable`:`expected value`
Note that if the provided expected value is an empty string, it implies that the check involves ensuring the environment variable is NOT an empty string.
Functions ¶
func FailBenchmarkIfCI ¶
FailBenchmarkIfCI is a testing helper function that fails the execution of a benchmark if it is running within a CI/CD pipeline.
func FailBenchmarkIfNotCI ¶
FailBenchmarkIfNotCI is a testing helper function that fails the execution of a benchmark if it is not running within a CI/CD pipeline.
func FailFuzzIfCI ¶
FailFuzzIfCI is a testing helper function that fails the execution of a fuzz test if it is running within a CI/CD pipeline.
func FailFuzzIfNotCI ¶
FailFuzzIfNotCI is a testing helper function that fails the execution of a fuzz test if it is not running within a CI/CD pipeline.
func FailTestIfCI ¶
FailTestIfCI is a testing helper function that fails the execution of a test if it is running within a CI/CD pipeline.
func FailTestIfNotCI ¶
FailTestIfNotCI is a testing helper function that fails the execution of a test if it is not running within a CI/CD pipeline.
func IsCI ¶
func IsCI() bool
IsCI determines whether the current environment is within a CI/CD pipeline.
Example ¶
os.Setenv("CI", "false") fmt.Println(IsCI())
Output: false
func IsNotCI ¶
func IsNotCI() bool
IsNotCI negates the result of IsCI. It returns true if the current environment is not within a CI/CD pipeline.
func SkipBenchmarkIfCI ¶
SkipBenchmarkIfCI is a testing helper function that skips the execution of a benchmark if it is running within a CI/CD pipeline.
func SkipBenchmarkIfNotCI ¶
SkipBenchmarkIfNotCI is a testing helper function that skips the execution of a benchmark if it is not running within a CI/CD pipeline.
func SkipFuzzIfCI ¶
SkipFuzzIfCI is a testing helper function that skips the execution of a fuzz test if it is running within a CI/CD pipeline.
func SkipFuzzIfNotCI ¶
SkipFuzzIfNotCI is a testing helper function that skips the execution of a fuzz test if it is not running within a CI/CD pipeline.
func SkipTestIfCI ¶
SkipTestIfCI is a testing helper function that skips the execution of a test if it is running within a CI/CD pipeline.
Example:
func TestYourFunc(t *testing.T) { defer func() { println(t.Skipped()) // Output: true }() t.Setenv("CI", "true") ci.SkipTestIfCI(t) // do your test... }
func SkipTestIfNotCI ¶
SkipTestIfNotCI is a testing helper function that skips the execution of a test if it is not running within a CI/CD pipeline.