forked from m-lab/annotation-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
120 lines (103 loc) · 4.55 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Travis configuration for annotation-service
#
# * decrypt service account credentials
# * install the Google Cloud SDK command line tools (gcloud)
# * cache the gcloud installation and setup
# * test and build the go code
# * on success, deploy the result when the origin branch or tag matches
# a supported deployment target.
#
language: go
# Without this, annotator.sh fails, related to gcloud.
sudo: required
before_install:
- go get github.com/mattn/goveralls
- go get github.com/wadey/gocovmerge
- sudo apt-get update -q
- sudo apt-get install -y libgeoip-dev pkg-config
- go get gopkg.in/check.v1
- go get github.com/abh/geoip
# This installs gcloud, sets up devappserver.
- $TRAVIS_BUILD_DIR/annotator.sh
# NB: Encrypted values are not defined in forks or pull requests.
#
# Decrypt the tar archive containing the GCP service account key files.
# After unpacking, there should be one service account key file for every GCP
# project referenced in the "deploy" section. These keys authenticate the
# gcloud deploy operations.
#
# Reusing the etl-travis-deploy service accounts, since we need identical capabilities.
# The tar file contains newly created keys for each of the three service accounts.
- travis/decrypt.sh "$encrypted_ca29bb0d9214_key" "$encrypted_ca29bb0d9214_iv"
keys/service-accounts.tar.enc /tmp/service-accounts.tar /tmp
- if [[ -r /tmp/service-accounts.tar ]] ; then
tar tvf /tmp/service-accounts.tar ;
fi
- echo Branch is ${TRAVIS_BRANCH} and Tag is $TRAVIS_TAG
- if [[ -n "$SERVICE_ACCOUNT_mlab_testing" ]] ; then
echo "$SERVICE_ACCOUNT_mlab_testing" > $TRAVIS_BUILD_DIR/creds.json ;
export GOOGLE_APPLICATION_CREDENTIALS=$TRAVIS_BUILD_DIR/creds.json ;
fi
# These directories will be cached on successful "script" builds, and restored,
# if available, to save time on future builds.
cache:
directories:
- $HOME/google-cloud-sdk/
script:
# This sets up the dev appserver for the aetest support used by unit tests.
- if [[ -r "${HOME}/gcloud-service-key.json" ]]; then
export GOOGLE_APPLICATION_CREDENTIALS="${HOME}/gcloud-service-key.json";
fi
- export APPENGINE_DEV_APPSERVER="${HOME}/google-cloud-sdk/bin/dev_appserver.py"
- source "${HOME}/google-cloud-sdk/path.bash.inc"
# First run all tests, to ensure that we don't miss any new tests not included in
# the coverage collection.
- go test ./...
# Also run benchmarks
- go test -bench . ./search/...
# Run all tests, collecting coverage data.
- go test -covermode=count -coverprofile=handler.cov -v github.com/m-lab/annotation-service/handler
- go test -covermode=count -coverprofile=dataset.cov -v github.com/m-lab/annotation-service/handler/dataset
- go test -covermode=count -coverprofile=loader.cov -v github.com/m-lab/annotation-service/loader
- go test -covermode=count -coverprofile=metrics.cov -v github.com/m-lab/annotation-service/metrics
- go test -covermode=count -coverprofile=parser.cov -v github.com/m-lab/annotation-service/parser
- go test -covermode=count -coverprofile=search.cov -v github.com/m-lab/annotation-service/search
# Coveralls
- $HOME/gopath/bin/gocovmerge handler.cov dataset.cov loader.cov parser.cov search.cov > merge.cov
- $HOME/gopath/bin/goveralls -coverprofile=merge.cov -service=travis-ci
# Build and prepare for deployment
- go build
- $TRAVIS_BUILD_DIR/travis/install_gcloud.sh
# Deploy steps never trigger on a new Pull Request. Deploy steps will trigger
# after a merge with matching "on:" conditions.
deploy:
######################################################################
## Service: annotation-service -- AppEngine Flexible Environment.
# SANDBOX: Allows any branch with sandbox-*, to trigger deploying that
# branch to sandbox for pre-review testing.
- provider: script
script: $TRAVIS_BUILD_DIR/travis/deploy_app.sh mlab-sandbox /tmp/mlab-sandbox.json
$TRAVIS_BUILD_DIR annotator.yaml
skip_cleanup: true
on:
repo: m-lab/annotation-service
branch: sandbox-*
condition: "$TRAVIS_EVENT_TYPE == push"
# STAGING: Should trigger AFTER code review and commit to master branch.
- provider: script
script: $TRAVIS_BUILD_DIR/travis/deploy_app.sh mlab-staging /tmp/mlab-staging.json
$TRAVIS_BUILD_DIR annotator.yaml
skip_cleanup: true
on:
repo: m-lab/annotation-service
branch: master
# PROD: Should trigger AFTER code review and commit to master branch. Triggers
# when tagged with prod-*.
- provider: script
script: $TRAVIS_BUILD_DIR/travis/deploy_app.sh mlab-oti /tmp/mlab-oti.json
$TRAVIS_BUILD_DIR annotator.yaml
skip_cleanup: true
on:
repo: m-lab/annotation-service
all_branches: true
condition: "$TRAVIS_TAG == prod-*"