Skip to content

Commit 4b594da

Browse files
committed
Testing the real API with Travis
1 parent 574f42f commit 4b594da

File tree

2 files changed

+48
-10
lines changed

2 files changed

+48
-10
lines changed

.travis.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ env:
99
- PATH=$HOME/gopath/bin:$PATH
1010

1111

12-
go:
13-
- 1.3
14-
- 1.4
15-
- 1.5
16-
- tip
17-
1812
matrix:
13+
include:
14+
- go: 1.3
15+
- go: 1.4
16+
- go: 1.5 TEST_WITH_REAL_API=1
17+
- go: tip
1918
allow_failures:
2019
- go: tip
2120

@@ -28,7 +27,16 @@ before_install:
2827

2928

3029
script:
31-
- make build
32-
- ./scw version
33-
- make cover
34-
- goveralls -service=travis-ci -v -coverprofile=profile.out
30+
- make build show_version
31+
- if [ -z "${TEST_WITH_REAL_API}" -o -z "${TRAVIS_SCALEWAY_TOKEN}" ]; then make test; fi
32+
- if [ "${TEST_WITH_REAL_API}" -a "${TRAVIS_SCALEWAY_TOKEN}" ]; then make travis_login; fi
33+
- if [ "${TEST_WITH_REAL_API}" -a "${TRAVIS_SCALEWAY_TOKEN}" ]; then make travis_cleanup || true; fi
34+
- if [ "${TEST_WITH_REAL_API}" -a "${TRAVIS_SCALEWAY_TOKEN}" ]; then make cover; fi
35+
- if [ "${TEST_WITH_REAL_API}" -a "${TRAVIS_SCALEWAY_TOKEN}" ]; then make travis_coveralls; fi
36+
- if [ "${TEST_WITH_REAL_API}" -a "${TRAVIS_SCALEWAY_TOKEN}" ]; then make travis_cleanup; fi
37+
38+
after_success:
39+
- if [ "${TEST_WITH_REAL_API}" -a "${TRAVIS_SCALEWAY_TOKEN}" ]; then make travis_cleanup; fi
40+
41+
after_failure:
42+
- if [ "${TEST_WITH_REAL_API}" -a "${TRAVIS_SCALEWAY_TOKEN}" ]; then make travis_cleanup; fi

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,33 @@ party:
149149
convey:
150150
go get github.com/smartystreets/goconvey
151151
goconvey -cover -port=9042 -workDir="$(realpath .)/pkg" -depth=-1
152+
153+
154+
.PHONY: travis_login
155+
travis_login:
156+
@if [ "$(TRAVIS_SCALEWAY_TOKEN)" -a "$(TRAVIS_SCALEWAY_ORGANIZATION)" ]; then \
157+
echo '{"api_endpoint":"https://api.scaleway.com/","account_endpoint":"https://account.scaleway.com/","organization":"$(TRAVIS_SCALEWAY_ORGANIZATION)","token":"$(TRAVIS_SCALEWAY_TOKEN)"}' > ~/.scwrc && \
158+
chmod 600 ~/.scwrc; \
159+
else \
160+
echo "Cannot login, credentials are missing"; \
161+
fi
162+
163+
164+
.PHONY: travis_coveralls
165+
travis_coveralls:
166+
if [ -f ~/.scwrc ]; then goveralls -service=travis-ci -v -coverprofile=profile.out; fi
167+
168+
169+
.PHONY: travis_cleanup
170+
travis_cleanup:
171+
# FIXME: delete only resources created for this project
172+
if [ "$(TRAVIS_SCALEWAY_TOKEN)" -a "$(TRAVIS_SCALEWAY_ORGANIZATION)" ]; then \
173+
./scw stop -t $(shell ./scw ps -q) || true; \
174+
./scw rm $(shell ./scw ps -aq) || true; \
175+
./scw rmi $(shell ./scw images -q) || true; \
176+
fi
177+
178+
179+
.PHONY: show_version
180+
show_version:
181+
./scw version

0 commit comments

Comments
 (0)