forked from GoogleCloudPlatform/golang-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
83 lines (75 loc) · 2.94 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
language: go
# Don't build other branches that are being used for PRs.
# Currently only the master branch is used in this repo.
branches:
only:
- master
matrix:
include:
- go: 1.6.x
- go: 1.7.x
- go: 1.8.x
- go: 1.9.x
env: ALLOW_E2E=true # Don't run e2e tests more than once.
# NOTE: no tip, see https://github.com/travis-ci/gimme/issues/38
before_cache:
- rm -rf $GOPATH/src/github.com/GoogleCloudPlatform/golang-samples/*
- rm -rf $GOPATH/pkg/**/github.com/GoogleCloudPlatform/golang-samples
# go get -u won't work if we've pinned the version.
- rm -rf $GOPATH/src/github.com/go-sql-driver/mysql
cache:
directories:
- $GOPATH/src
- $GOPATH/pkg
before_install:
- if [ $SYSTEM_TESTS ]; then
openssl aes-256-cbc -K $encrypted_e44ee91b46d4_key -iv $encrypted_e44ee91b46d4_iv -in key.json.enc -out key.json -d;
export GOOGLE_APPLICATION_CREDENTIALS="$(pwd)/key.json";
export GOLANG_SAMPLES_KMS_KEYRING=ring1;
export GOLANG_SAMPLES_KMS_CRYPTOKEY=key1;
curl https://storage.googleapis.com/gimme-proj/linux_amd64/gimmeproj > gimmeproj && chmod +x gimmeproj;
./gimmeproj version;
export GOLANG_SAMPLES_PROJECT_ID=$(./gimmeproj -project golang-samples-tests lease 12m);
if [ -z "$GOLANG_SAMPLES_PROJECT_ID" ]; then
echo "Lease failed.";
exit 1;
fi;
echo "Running tests in project $GOLANG_SAMPLES_PROJECT_ID";
export GOLANG_SAMPLES_SPANNER=projects/golang-samples-tests/instances/golang-samples-tests;
else
echo "Not running system tests.";
fi
- if [ $ALLOW_E2E ]; then
curl -s https://api.travis-ci.org/builds/$TRAVIS_BUILD_ID | jq . | tee /tmp/build.json;
export NIGHTLY=$(jq '.event_type=="api" and (.message|contains("CIAEON=true"))' < /tmp/build.json);
export FORCE_E2E=$(jq '.message|contains("FORCE_E2E=true")' < /tmp/build.json);
if [ $NIGHTLY = "true" ] || [ $FORCE_E2E = "true" ]; then
export GOLANG_SAMPLES_E2E_TEST=true;
fi;
fi
- if [ $GOLANG_SAMPLES_E2E_TEST ]; then
echo "This test run will run end-to-end tests.";
export PATH="$PATH:/tmp/google-cloud-sdk/bin";
./testing/travis/configure_gcloud.bash;
fi
- '! grep -R ''"context"$'' * || { echo "Use golang.org/x/net/context"; false; }'
- go vet ./...
- diff -u <(echo -n) <(gofmt -d -s .)
install:
# Install all external dependencies, ensuring they are updated.
- GO_IMPORTS=$(go list -f '{{join .Imports "\n"}}{{"\n"}}{{join .TestImports "\n"}}' ./... | sort | uniq | grep -v golang-samples)
- go get -u -v -d $GO_IMPORTS
# pin go-sql-driver/mysql to v1.3 (which supports Go 1.6)
- if go version | grep go1\.6\.; then
pushd $GOPATH/src/github.com/go-sql-driver/mysql;
git checkout v1.3;
popd;
fi
- go install -v $GO_IMPORTS
- go get -u -v github.com/rakyll/gotest
- export CI=TRAVIS # for gotest to force colors
script:
- travis_wait 20 gotest -p 10 -timeout 20m -v ./...;
- if [ $SYSTEM_TESTS ]; then
./gimmeproj -project golang-samples-tests done $GOLANG_SAMPLES_PROJECT_ID;
fi