| 1 |
package reporters |
| 2 |
|
| 3 |
import ( |
| 4 |
"os" |
| 5 |
"strconv" |
| 6 |
) |
| 7 |
|
| 8 |
type continuousIntegration struct{} |
| 9 |
|
| 10 |
// NewContinuousIntegrationReporter creates a new reporter for CI. |
| 11 |
// |
| 12 |
// The reporter checks the environment variable CI for a value of true. |
| 13 |
func NewContinuousIntegrationReporter() Reporter { |
| 14 |
return &continuousIntegration{} |
| 15 |
} |
| 16 |
|
| 17 |
func (s *continuousIntegration) Report(approved, received string) bool { |
| 18 |
value, exists := os.LookupEnv("CI") |
| 19 |
|
| 20 |
if exists { |
| 21 |
ci, err := strconv.ParseBool(value) |
| 22 |
if err == nil { |
| 23 |
return ci |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
return false |
| 28 |
} |