Skip to content

Commit dc33248

Browse files
refactor: use shuheiktgw/go-travis
1 parent 1b5058e commit dc33248

File tree

4 files changed

+18
-25
lines changed

4 files changed

+18
-25
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
language: go
2+
os:
3+
- linux
4+
- osx
25
go:
36
- 1.14.x
47
before_script:

go.mod

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ go 1.14
44

55
require (
66
github.com/Masterminds/semver v1.5.0
7-
github.com/christophwitzko/go-travis v0.0.0-20180115212951-5311d81d834b
8-
github.com/fatih/structs v1.1.0 // indirect
97
github.com/google/go-github/v30 v30.1.0
10-
github.com/oleiade/reflections v1.0.0 // indirect
11-
github.com/stretchr/testify v1.5.1 // indirect
8+
github.com/shuheiktgw/go-travis v0.2.4
129
github.com/urfave/cli/v2 v2.2.0
1310
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
1411
)

go.sum

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,24 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
22
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
33
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
44
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
5-
github.com/christophwitzko/go-travis v0.0.0-20180115212951-5311d81d834b h1:YKFJ/MSTMtRCR7UeF4I2Ovi8HDwsVA7F/qWxwr7J6tU=
6-
github.com/christophwitzko/go-travis v0.0.0-20180115212951-5311d81d834b/go.mod h1:0PHJRx/NZav97xUaOdeXLPZmPKBjSHVBAeiFFkaRSmc=
75
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
86
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
9-
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
10-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
11-
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
12-
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
137
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
148
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
159
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
1610
github.com/google/go-github/v30 v30.1.0 h1:VLDx+UolQICEOKu2m4uAoMti1SxuEBAl7RSEG16L+Oo=
1711
github.com/google/go-github/v30 v30.1.0/go.mod h1:n8jBpHl45a/rlBUtRJMOG4GhNADUQFEufcolZ95JfU8=
12+
github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
1813
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
1914
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
20-
github.com/oleiade/reflections v1.0.0 h1:0ir4pc6v8/PJ0yw5AEtMddfXpWBXg9cnG7SgSoJuCgY=
21-
github.com/oleiade/reflections v1.0.0/go.mod h1:RbATFBbKYkVdqmSFtx13Bb/tVhR0lgOBXunWTZKeL4w=
2215
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2316
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2417
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
2518
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
19+
github.com/shuheiktgw/go-travis v0.2.4 h1:IAnh/Dyv7ql87qtJWUcvR5MM8e5iCDGoENl9VzpxAHc=
20+
github.com/shuheiktgw/go-travis v0.2.4/go.mod h1:RtODX49bvgHTvfzFvGEPFtU0dKVk0D3PyvUQR/63hT0=
2621
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
2722
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
28-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
29-
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
30-
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
3123
github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4=
3224
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
3325
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=

pkg/condition/travis.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package condition
22

33
import (
4+
"context"
45
"errors"
56
"fmt"
6-
"github.com/christophwitzko/go-travis"
7+
"github.com/shuheiktgw/go-travis"
78
"log"
89
"os"
910
"strconv"
@@ -59,40 +60,40 @@ func (ci *TravisCI) RunCondition(config CIConfig) error {
5960
return errors.New("could not parse TRAVIS_BUILD_ID/TRAVIS_JOB_ID")
6061
}
6162

62-
endpoint := travis.TRAVIS_API_DEFAULT_URL
63+
endpoint := travis.ApiOrgUrl
6364
if travisHost := os.Getenv("TRAVIS_ENTERPRISE_HOST"); travisHost != "" {
6465
logger.Printf("Using Travis CI enterprise host: %s\n", travisHost)
6566
endpoint = fmt.Sprintf("https://%s/api/", travisHost)
6667
} else if private {
67-
endpoint = travis.TRAVIS_API_PRO_URL
68+
endpoint = travis.ApiComUrl
6869
}
6970

7071
client := travis.NewClient(endpoint, "")
7172
client.Headers["User-Agent"] = "Travis"
72-
if _, _, err := client.Authentication.UsingGithubToken(token); err != nil {
73+
if _, _, err := client.Authentication.UsingGithubToken(context.Background(), token); err != nil {
7374
return err
7475
}
7576

7677
for i := 1; i <= 100; i++ {
77-
jobs, _, err := client.Jobs.ListFromBuild(uint(buildId))
78+
jobs, _, err := client.Jobs.ListByBuild(context.Background(), uint(buildId))
7879
if err != nil {
7980
return err
8081
}
8182

8283
successes := 0
8384
for _, job := range jobs {
84-
if job.Id == uint(currentJobId) || job.AllowFailure || job.State == "passed" {
85+
if *job.Id == uint(currentJobId) || *job.AllowFailure || *job.State == "passed" {
8586
successes++
8687
continue
8788
}
8889

89-
if job.State == "created" || job.State == "started" {
90-
logger.Printf("Aborting attempt %d, because job %s is still pending.\n", i, job.Number)
90+
if *job.State == "created" || *job.State == "started" {
91+
logger.Printf("Aborting attempt %d, because job %s is still pending.\n", i, *job.Number)
9192
break
9293
}
9394

94-
if job.State == "errored" || job.State == "failed" {
95-
logger.Printf("Aborting attempt %d. Job %s failed.\n", i, job.Number)
95+
if *job.State == "errored" || *job.State == "failed" {
96+
logger.Printf("Aborting attempt %d. Job %s failed.\n", i, *job.Number)
9697
return errors.New("In this test run not all jobs passed and therefore a new version won’t be published.")
9798
}
9899
}

0 commit comments

Comments
 (0)