You've already forked go-semantic-release
refactor(ci): improve testing
This commit is contained in:
@@ -3,22 +3,21 @@ package ci
|
||||
import (
|
||||
"fmt"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"os"
|
||||
)
|
||||
|
||||
//Travis struct
|
||||
type Travis struct{}
|
||||
|
||||
//Detect if on travis
|
||||
func (t Travis) detect() (*ProviderConfig, error) {
|
||||
func (t Travis) detect(envs map[string]string) (*ProviderConfig, error) {
|
||||
|
||||
if _, exists := os.LookupEnv("TRAVIS"); !exists {
|
||||
if _, exists := envs["TRAVIS"]; !exists {
|
||||
return nil, fmt.Errorf("not running on travis")
|
||||
}
|
||||
|
||||
isPR := false
|
||||
|
||||
value := os.Getenv("TRAVIS_PULL_REQUEST")
|
||||
value := envs["TRAVIS_PULL_REQUEST"]
|
||||
pr := ""
|
||||
|
||||
if value == "false" {
|
||||
@@ -31,12 +30,12 @@ func (t Travis) detect() (*ProviderConfig, error) {
|
||||
return &ProviderConfig{
|
||||
Service: "travis",
|
||||
Name: "Travis CI",
|
||||
Commit: os.Getenv("TRAVIS_COMMIT"),
|
||||
Tag: os.Getenv("TRAVIS_TAG"),
|
||||
BuildURL: os.Getenv("TRAVIS_BUILD_WEB_URL"),
|
||||
Branch: os.Getenv("TRAVIS_BRANCH"),
|
||||
Commit: envs["TRAVIS_COMMIT"],
|
||||
Tag: envs["TRAVIS_TAG"],
|
||||
BuildURL: envs["TRAVIS_BUILD_WEB_URL"],
|
||||
Branch: envs["TRAVIS_BRANCH"],
|
||||
IsPR: isPR,
|
||||
PR: pr,
|
||||
PRBranch: os.Getenv("TRAVIS_PULL_REQUEST_BRANCH"),
|
||||
PRBranch: envs["TRAVIS_PULL_REQUEST_BRANCH"],
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user