Skip to content

Commit 63aa8b7

Browse files
committed
Adds travis support for push builds
This enables a developer to activate travis-ci on their own namespace and have branches tested upon push. It's an effective way to test the CI before making a pull request to operator-sdk.
1 parent be39b2d commit 63aa8b7

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-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: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,13 @@ 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_COMMIT")
91+
if ok && commitSha != "" {
8992
gopkg, err := ioutil.ReadFile("Gopkg.toml")
9093
if err != nil {
9194
t.Fatal(err)
@@ -98,7 +101,7 @@ func TestMemcached(t *testing.T) {
98101
// correctly.
99102
gopkgString := string(gopkg)
100103
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:]
104+
gopkgString = gopkgString[:gopkgLoc] + "\n source = \"https://github.com/" + repo + "\"\n revision = \"" + commitSha + "\"\n" + gopkgString[gopkgLoc+1:]
102105
err = ioutil.WriteFile("Gopkg.toml", []byte(gopkgString), filemode)
103106
if err != nil {
104107
t.Fatalf("failed to write updated Gopkg.toml: %v", err)
@@ -111,7 +114,7 @@ func TestMemcached(t *testing.T) {
111114
}
112115
cmdOut, err = exec.Command("dep", "ensure").CombinedOutput()
113116
if err != nil {
114-
t.Fatalf("error: %v\nCommand Output: %s\n", err, string(cmdOut))
117+
t.Fatalf("error after modifying Gopkg.toml: %v\nCommand Output: %s\n", err, string(cmdOut))
115118
}
116119

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

0 commit comments

Comments
 (0)