Skip to content

Commit c793226

Browse files
authored
Merge pull request #766 from mhrivnak/travis-push-builds
Adds travis support for push builds
2 parents be39b2d + b485fb1 commit c793226

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ go:
77

88
before_install:
99
- |
10-
if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.md)|(\.MD)|(\.png)|(\.pdf)|^(doc/)|^(MAINTAINERS)|^(LICENSE)'; then
10+
if [ "$TRAVIS_COMMIT_RANGE" != "" ] && ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.md)|(\.MD)|(\.png)|(\.pdf)|^(doc/)|^(MAINTAINERS)|^(LICENSE)'; then
1111
echo "Only doc files were updated, not running the CI."
1212
exit
1313
fi

test/e2e/memcached_test.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,16 @@ func TestMemcached(t *testing.T) {
8282
ctx.AddFinalizerFn(func() error { return os.RemoveAll(absProjectPath) })
8383

8484
os.Chdir("memcached-operator")
85-
prSlug, ok := os.LookupEnv("TRAVIS_PULL_REQUEST_SLUG")
86-
if ok && prSlug != "" {
87-
prSha, ok := os.LookupEnv("TRAVIS_PULL_REQUEST_SHA")
88-
if ok && prSha != "" {
85+
repo, ok := os.LookupEnv("TRAVIS_PULL_REQUEST_SLUG")
86+
if repo == "" {
87+
repo, ok = os.LookupEnv("TRAVIS_REPO_SLUG")
88+
}
89+
if ok && repo != "" {
90+
commitSha, ok := os.LookupEnv("TRAVIS_PULL_REQUEST_SHA")
91+
if commitSha == "" {
92+
commitSha, ok = os.LookupEnv("TRAVIS_COMMIT")
93+
}
94+
if ok && commitSha != "" {
8995
gopkg, err := ioutil.ReadFile("Gopkg.toml")
9096
if err != nil {
9197
t.Fatal(err)
@@ -98,7 +104,7 @@ func TestMemcached(t *testing.T) {
98104
// correctly.
99105
gopkgString := string(gopkg)
100106
gopkgLoc := strings.LastIndex(gopkgString, "\n name = \"github.com/operator-framework/operator-sdk\"\n")
101-
gopkgString = gopkgString[:gopkgLoc] + "\n source = \"https://github.com/" + prSlug + "\"\n revision = \"" + prSha + "\"\n" + gopkgString[gopkgLoc+1:]
107+
gopkgString = gopkgString[:gopkgLoc] + "\n source = \"https://github.com/" + repo + "\"\n revision = \"" + commitSha + "\"\n" + gopkgString[gopkgLoc+1:]
102108
err = ioutil.WriteFile("Gopkg.toml", []byte(gopkgString), filemode)
103109
if err != nil {
104110
t.Fatalf("failed to write updated Gopkg.toml: %v", err)
@@ -111,7 +117,7 @@ func TestMemcached(t *testing.T) {
111117
}
112118
cmdOut, err = exec.Command("dep", "ensure").CombinedOutput()
113119
if err != nil {
114-
t.Fatalf("error: %v\nCommand Output: %s\n", err, string(cmdOut))
120+
t.Fatalf("error after modifying Gopkg.toml: %v\nCommand Output: %s\n", err, string(cmdOut))
115121
}
116122

117123
cmdOut, err = exec.Command("operator-sdk",
@@ -191,7 +197,7 @@ func TestMemcached(t *testing.T) {
191197
t.Fatalf("dep ensure failed: %v\nCommand Output:\n%v", err, string(cmdOut))
192198
}
193199
// link local sdk to vendor if not in travis
194-
if prSlug == "" {
200+
if repo == "" {
195201
os.RemoveAll("vendor/github.com/operator-framework/operator-sdk/pkg")
196202
os.Symlink(filepath.Join(gopath, "src/github.com/operator-framework/operator-sdk/pkg"),
197203
"vendor/github.com/operator-framework/operator-sdk/pkg")

0 commit comments

Comments
 (0)