-
Notifications
You must be signed in to change notification settings - Fork 1
/
.travis.yml
188 lines (188 loc) · 8.13 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
dist: xenial
language: node_js
notifications:
webhooks: https://coveralls.io/webhook?repo_token=COVERALLS_REPO_TOKEN
node_js:
- "10.15.3"
sudo: false
services:
- docker
branches:
only:
- master
- development
- dev2
cache:
directories:
- "$HOME/google-cloud-sdk/"
before_install:
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
openssl aes-256-cbc -K $encrypted_57c9ae68dfc1_key -iv $encrypted_57c9ae68dfc1_iv -in credentials.tar.gz.enc -out credentials.tar.gz -d;
fi
# Create environment variable for correct distribution
- export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"
# Add the Cloud SDK distribution URI as a package source
- echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
# Import the Google Cloud Platform public key
- curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
# Update the package list and install the Cloud SDK
- sudo apt-get update && sudo apt-get install google-cloud-sdk kubectl
- gcloud --quiet version
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
tar -xzf credentials.tar.gz;
fi
- mkdir -p lib
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
gcloud auth activate-service-account --key-file client-secret.json;
fi
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu
$(lsb_release -cs) stable"
- sudo apt-get update
- sudo apt-get -yq --force-yes -o Dpkg::Options::="--force-confold" install docker-ce
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
- export COMMITTER_EMAIL="$(git log -1 $TRAVIS_COMMIT --pretty="%cE")"
- export AUTHOR_NAME="$(git log -1 $TRAVIS_COMMIT --pretty="%aN")"
- git config --global user.name "Travis CI User"
- git config --global user.email "[email protected]"
# Workaround for invalid GPG keys for MongoDB, CouchDB, and git-lfs
- sudo rm -f /etc/apt/sources.list.d/mongodb*
- sudo rm -f /etc/apt/sources.list.d/couchdb*
- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 762E3157
- sudo add-apt-repository ppa:ethereum/ethereum -y
- sudo apt-get update
- sudo apt-get install build-essential -y
- sudo apt-get install gcc g++ libssl-dev libudev-dev pkg-config
- curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
- sudo apt-get install -y nodejs
- rm -rf node_modules
after_install:
- docker kill $(docker ps -q)
jobs:
include:
- stage: solidity-tests-mainchain
install:
- npm install -g [email protected] [email protected]
- cd mainchain
- npm install
script:
- ../travis/runTests.sh
after_script:
- npm run coverage
- cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
- stage: solidity-tests-sidechain
install:
- npm install -g [email protected] [email protected]
- cd sidechain
- npm install
script:
- ../travis/runTests.sh
after_script:
- npm run coverage
- cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
- stage: git-tag
if: "(NOT type IN (pull_request) AND (branch = master))"
install:
- chmod 600 github_deploy_key
- eval $(ssh-agent -s)
- ssh-add github_deploy_key
- ssh-add -l
- git remote set-url origin [email protected]:kauri-io/kauri-smart-contracts.git
- git remote -v
- git fetch origin 'refs/tags/*:refs/tags/*'
script:
- SMART_CONTRACT_VERSION=$(npm version | grep kauri-smart-contracts | head -1
| awk '{ print $3 }' | sed 's/[",]//g' | sed 's|["'\'']||g')
- bash kauri-ops/versioning/gittag.sh $SMART_CONTRACT_VERSION
- NEW_DEV_VERSION=$(kauri-ops/versioning/get-next-dev-ver.sh)
- echo $NEW_DEV_VERSION
- git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
- git fetch --all
- git checkout development
- npm version $NEW_DEV_VERSION --no-git-tag-version
- git add .
- git commit -m "Travis build $TRAVIS_BUILD_NUMBER updating version after tag"
- git push origin development
- git checkout dev2
- git checkout master
- git merge -s ours dev2
- git checkout dev2
- git merge master
- npm version $NEW_DEV_VERSION --no-git-tag-version
- git add .
- git commit -m "Travis build $TRAVIS_BUILD_NUMBER updating version after tag"
- git push origin dev2
- stage: deploy-uat
if: "(NOT type IN (pull_request) AND (branch = master))"
install:
- cd kauri-ops
- source env_setup.sh --config-file config/config-uat.json
- cd ..
- gcloud config set project $GOOGLE_PROJECT_ID
- gcloud container clusters get-credentials $ACS_NAME --zone $GOOGLE_ZONE
- kubectl config set-context $(kubectl config current-context) --namespace=${TARGET_ENV}
script:
- SMART_CONTRACTS_VERSION=$(npm version | grep kauri-smart-contracts | head -1
| awk '{ print $3 }' | sed 's/[",]//g' | sed 's|["'\'']||g')
- echo $SMART_CONTRACTS_VERSION
- npm install -g [email protected] [email protected]
- bash ./k8s/run_migrations_mainchain.sh
- bash ./k8s/run_migrations_sidechain.sh
- bash ./docker/build-kauri-abis.sh $SMART_CONTRACTS_VERSION
- bash ./k8s/redeploy-k8s.sh $SMART_CONTRACTS_VERSION
- kubectl delete pods -l app=web3-auth
- sleep 30
- kubectl delete pods -l app=monolith
- sleep 30
- kubectl delete pods -l app=eventeum
- stage: deploy-dev2
if: "(NOT type IN (pull_request) AND (branch = dev2))"
install:
- cd kauri-ops
- source env_setup.sh --config-file config/config-dev2.json
- cd ..
- gcloud config set project $GOOGLE_PROJECT_ID
- gcloud container clusters get-credentials $ACS_NAME --zone $GOOGLE_ZONE
- kubectl config set-context $(kubectl config current-context) --namespace=${TARGET_ENV}
script:
- SMART_CONTRACTS_VERSION=$(npm version | grep kauri-smart-contracts | head -1
| awk '{ print $3 }' | sed 's/[",]//g' | sed 's|["'\'']||g')
- echo $SMART_CONTRACTS_VERSION
- npm install -g [email protected] [email protected]
- bash ./k8s/run_migrations_mainchain.sh
- bash ./k8s/run_migrations_sidechain.sh
- bash ./docker/build-kauri-abis.sh $SMART_CONTRACTS_VERSION-SNAPSHOT2
- bash ./k8s/redeploy-k8s.sh $SMART_CONTRACTS_VERSION-SNAPSHOT2
# Restart middleware pods
- kubectl delete pods -l app=web3-auth
- sleep 30
- kubectl delete pods -l app=monolith
- sleep 30
- kubectl delete pods -l app=eventeum
- stage: deploy-dev
if: "(NOT env(AUTHOR_NAME) =~ ^Travis AND (NOT type IN (pull_request)) AND (branch
= development))"
install:
- cd kauri-ops
- source env_setup.sh --config-file config/config-dev.json
- cd ..
- gcloud config set project $GOOGLE_PROJECT_ID
- gcloud container clusters get-credentials $ACS_NAME --zone $GOOGLE_ZONE
- kubectl config set-context $(kubectl config current-context) --namespace=${TARGET_ENV}
script:
- SMART_CONTRACTS_VERSION=$(npm version | grep kauri-smart-contracts | head -1
| awk '{ print $3 }' | sed 's/[",]//g' | sed 's|["'\'']||g')
- if [ "$AUTHOR_NAME" != "Travis CI User" ]; then npm install -g [email protected] [email protected]; fi
- if [ "$AUTHOR_NAME" != "Travis CI User" ]; then echo $SMART_CONTRACTS_VERSION; fi
- if [ "$AUTHOR_NAME" != "Travis CI User" ]; then bash ./k8s/run_migrations_mainchain.sh; fi
- if [ "$AUTHOR_NAME" != "Travis CI User" ]; then bash ./k8s/run_migrations_sidechain.sh; fi
- if [ "$AUTHOR_NAME" != "Travis CI User" ]; then bash ./docker/build-kauri-abis.sh $SMART_CONTRACTS_VERSION-SNAPSHOT; fi
- if [ "$AUTHOR_NAME" != "Travis CI User" ]; then bash ./k8s/redeploy-k8s.sh $SMART_CONTRACTS_VERSION-SNAPSHOT; fi
- if [ "$AUTHOR_NAME" != "Travis CI User" ]; then kubectl delete pods -l app=web3-auth; fi
- if [ "$AUTHOR_NAME" != "Travis CI User" ]; then sleep 30; fi
- if [ "$AUTHOR_NAME" != "Travis CI User" ]; then kubectl delete pods -l app=monolith; fi
- if [ "$AUTHOR_NAME" != "Travis CI User" ]; then sleep 30; fi
- if [ "$AUTHOR_NAME" != "Travis CI User" ]; then kubectl delete pods -l app=eventeum; fi