/
.travis.yml
289 lines (255 loc) · 13.9 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# Use small container and not VM:
sudo: false
# Choose a build environment:
dist: xenial
# Only clone the repository tip & track all branches
git:
depth: false
env:
global:
- WALLET_CLI_JORMUNGANDR=$HOME/.local/bin/cardano-wallet-jormungandr
- WALLET_CLI_JORMUNGANDR_CHECKSUM=$HOME/.local/bin/cardano-wallet-jormungandr.sha256
- WALLET_CLI_JORMUNGANDR_TARGZ=$HOME/.local/bin/cardano-wallet-jormungandr.tar.gz
- WALLET_CLI_HTTP_BRIDGE=$HOME/.local/bin/cardano-wallet-http-bridge
- WALLET_CLI_HTTP_BRIDGE_CHECKSUM=$HOME/.local/bin/cardano-wallet-http-bridge.sha256
- WALLET_CLI_HTTP_BRIDGE_TARGZ=$HOME/.local/bin/cardano-wallet-http-bridge.tar.gz
- STACK_WORK_CACHE=$HOME/.stack/stack-work.tar.gz
- PATH=$PATH:$HOME/.local/bin
- LOCAL_MIX_DIR=.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/hpc/
# We use a hybrid setup with Rust and Haskell, so we handle the compilation ourselves
language: generic
# Deactivate builds on branches but `master` and the bors branches.
# CI is still triggered by PRs).
# We do also CI to kick in when pushing a tag `git push --tags` for releases.
if: "(branch IN (master, bors/staging, bors/trying)) OR (tag =~ ^v)"
# Caching so the next build will be fast too:
cache:
timeout: 1337
directories:
- $HOME/.stack
before_cache:
- rm -rf $HOME/.stack/programs/x86_64-linux/ghc-*.tar.*
- rm -rf $HOME/.stack/indices/Hackage/00-index.tar $HOME/.stack/indices/Hackage/00-index.tar.gz
- find $HOME/.stack/programs/x86_64-linux/ghc-*/lib/ghc-* -type f -name *_p.a -delete
before_install:
- mkdir -p $HOME/.local/bin
- tar xzf $STACK_WORK_CACHE || echo "no .stack-work yet"
- travis_retry curl -L https://raw.githubusercontent.com/input-output-hk/cardano-wallet/master/lib/http-bridge/test/data/cardano-node-simple/cardano-node-simple-3.0.1.tar.gz | tar xz -C $HOME/.local/bin
- cardano-node-simple --version
- travis_retry curl -L https://github.com/KtorZ/cardano-http-bridge/releases/download/v0.0.4/cardano-http-bridge-v0.0.4-x86_64-linux.tar.gz | tar xz -C $HOME/.local/bin
- cardano-http-bridge --version
- travis_retry curl -L https://github.com/input-output-hk/jormungandr/releases/download/v0.2.3/jormungandr-v0.2.3-x86_64-unknown-linux-gnu.tar.gz | tar xz -C $HOME/.local/bin
- jcli --version && jormungandr --version
- travis_retry curl -L https://github.com/commercialhaskell/stack/releases/download/v1.9.3/stack-1.9.3-linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C $HOME/.local/bin '*/stack'
- travis_retry stack --no-terminal setup
# Ensure necessary system libraries are present:
addons:
apt:
packages:
- libgmp-dev
- librocksdb-dev
- libsystemd-dev
service:
- docker
# Define custom set of stages
stages:
- cache 💾
- build project 🔨
- checks 🔬
- deploy 🚀
jobs:
fast_finish: true
include:
################################################################################
#
# PR
#
# Pipeline we run on each PR. Slightly different from the pipeline we run when
# stuff get merged into `master`. In this setup, we do want a quick feedback, and
# we therefore parallelize as much as we can using many different jobs. We also
# avoid options like `--coverage` or `--haddock` on each build since those take
# needless time.
#
################################################################################
- stage: build project 🔨
if: type = pull_request OR (branch IN (bors/staging, bors/trying))
name: "Compiling Project"
script:
- stack clean
- stack --no-terminal build --fast --test --no-run-tests --bench --no-run-benchmarks --haddock --no-haddock-deps
- tar czf $STACK_WORK_CACHE .stack-work lib/**/.stack-work
- stage: checks 🔬
if: type = pull_request OR (branch IN (bors/staging, bors/trying))
name: "Code Style"
script:
- travis_retry curl -sSL https://raw.github.com/jaspervdj/stylish-haskell/master/scripts/latest.sh | sh -s $(find . -type f -name "*.hs" ! -path "*.stack-work*") -i
- git diff --exit-code
- travis_retry curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s .
- travis_retry curl -sSL https://raw.github.com/ndmitchell/weeder/master/misc/travis.sh | sh -s .
# Somehow, we can't install open-spec-validator using `pip` directly in the travis VM.
# I've tried several things, including removing some existing conflicting packages, upgrading
# pip and using some more permissive options. In the end, I gave up and went for a container.
- cd specifications/api
- "echo -n 'FROM python:3.7-alpine\nRUN pip install openapi-spec-validator\nENTRYPOINT [\"openapi-spec-validator\"]' > Dockerfile"
- docker build -t openapi-spec-validator .
- docker run -v $PWD:/files openapi-spec-validator --schema 2.0 /files/swagger.yaml
- cd -
- stage: checks 🔬
if: type = pull_request OR (branch IN (bors/staging, bors/trying))
name: "Tests: unit"
script:
- stack --no-terminal test --fast cardano-wallet-core cardano-wallet-launcher cardano-wallet-cli text-class bech32 cardano-wallet-http-bridge:unit cardano-wallet-jormungandr:unit
- stage: checks 🔬
if: type = pull_request OR (branch IN (bors/staging, bors/trying))
name: "Tests: integration (http-bridge)"
script:
- travis_retry curl -L -o hermes-testnet.tar.gz https://raw.githubusercontent.com/input-output-hk/cardano-wallet/master/lib/http-bridge/test/data/cardano-http-bridge/hermes-testnet.tar.gz
- tar xzf hermes-testnet.tar.gz -C $HOME
- stack --no-terminal test --fast cardano-wallet-http-bridge:integration --ta "--skip PR_DISABLED"
- stage: checks 🔬
if: type = pull_request OR (branch IN (bors/staging, bors/trying))
name: "Tests: integration (jormungandr)"
script:
- stack --no-terminal test --fast cardano-wallet-jormungandr:integration --ta "--skip PR_DISABLED"
################################################################################
#
# Push / Cron / Api
#
# This runs for other type of build (non PR) and are slightly heavier since they
# also compute coverage and documentation. This is also the only way to rebuild
# an initial default cache and re-inject 3rd-party dependencies like:
#
# - cardano-node-simple
# - cardano-http-bridge
# - jormungandr
# - jcli
#
################################################################################
- stage: cache 💾
if: (type != pull_request AND branch = master) OR (tag =~ ^v)
name: "Caching Dependencies"
script:
- stack --no-terminal build --fast --test --no-run-tests --bench --no-run-benchmarks --only-snapshot
- stack --no-terminal build --fast --test --no-run-tests --bench --no-run-benchmarks --only-dependencies
- tar czf $STACK_WORK_CACHE .stack-work
- stage: build project 🔨
if: (type != pull_request AND branch = master) OR (tag =~ ^v)
name: "Compiling Project"
script:
- stack --no-terminal build --fast --test --no-run-tests --bench --no-run-benchmarks --haddock --no-haddock-deps --coverage
- tar czf $STACK_WORK_CACHE .stack-work lib/**/.stack-work
- stage: checks 🔬
if: (type != pull_request AND branch = master) OR (tag =~ ^v)
name: "Code Style"
script:
- travis_retry curl -sSL https://raw.github.com/jaspervdj/stylish-haskell/master/scripts/latest.sh | sh -s $(find . -type f -name "*.hs" ! -path "*.stack-work*") -i
- git diff --exit-code # Exit if Stylish-Haskell yields any diff
- travis_retry curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s .
- travis_retry curl -sSL https://raw.github.com/ndmitchell/weeder/master/misc/travis.sh | sh -s .
# Somehow, we can't install open-spec-validator using `pip` directly in the travis VM.
# I've tried several things, including removing some existing conflicting packages, upgrading
# pip and using some more permissive options. In the end, I gave up and went for a container.
- cd specifications/api
- "echo -n 'FROM python:3.7-alpine\nRUN pip install openapi-spec-validator\nENTRYPOINT [\"openapi-spec-validator\"]' > Dockerfile"
- docker build -t openapi-spec-validator .
- docker run -v $PWD:/files openapi-spec-validator --schema 2.0 /files/swagger.yaml
- cd -
- stage: checks 🔬
if: (type != pull_request AND branch = master) OR (tag =~ ^v)
name: "Tests"
script:
- travis_retry curl -L -o hermes-testnet.tar.gz https://raw.githubusercontent.com/input-output-hk/cardano-wallet/master/lib/http-bridge/test/data/cardano-http-bridge/hermes-testnet.tar.gz
- tar xzf hermes-testnet.tar.gz -C $HOME
- stack --no-terminal test --fast --haddock --no-haddock-deps --coverage cardano-wallet-core
- mkdir -p .coverage/core && find . -name "*.tix" ! -path "*.coverage*" -exec cp \{} .coverage/core \;
- stack --no-terminal test --fast --haddock --no-haddock-deps --coverage cardano-wallet-launcher
- mkdir -p .coverage/launcher && find . -name "*.tix" ! -path "*.coverage*" -exec cp \{} .coverage/launcher \;
- stack --no-terminal test --fast --haddock --no-haddock-deps --coverage cardano-wallet-cli
- mkdir -p .coverage/cli && find . -name "*.tix" ! -path "*.coverage*" -exec cp \{} .coverage/cli \;
- stack --no-terminal test --fast --haddock --no-haddock-deps --coverage text-class
- mkdir -p .coverage/text-class && find . -name "*.tix" ! -path "*.coverage*" -exec cp \{} .coverage/text-class \;
- stack --no-terminal test --fast --haddock --no-haddock-deps --coverage bech32
- mkdir -p .coverage/bech32 && find . -name "*.tix" ! -path "*.coverage*" -exec cp \{} .coverage/bech32 \;
- stack --no-terminal test --fast --haddock --no-haddock-deps --coverage cardano-wallet-http-bridge 2>/dev/null
- mkdir -p .coverage/http-bridge && find . -name "*.tix" ! -path "*.coverage*" -exec cp \{} .coverage/http-bridge \;
- stack --no-terminal test --fast --haddock --no-haddock-deps --coverage cardano-wallet-jormungandr 2>/dev/null
- mkdir -p .coverage/jormungandr && find . -name "*.tix" ! -path "*.coverage*" -exec cp \{} .coverage/jormungandr \;
- tar czf $STACK_WORK_CACHE .stack-work .coverage lib/**/.stack-work lib/**/*.tix
- stage: deploy 🚀
if: (type != pull_request AND branch = master) OR (tag =~ ^v)
name: "Haddock"
script:
- mkdir -p haddock/edge api/edge
- cp -Rv specifications/api/* api/edge
- mv $(stack path --local-doc-root)/* haddock/edge
- git checkout --orphan gh-pages-deploy && git reset
- git add api haddock && git commit -m $TRAVIS_COMMIT
- git checkout gh-pages && git merge -X theirs --no-commit --no-ff --allow-unrelated-histories - && git commit --allow-empty --no-edit
- git push -f -q https://WilliamKingNoel-Bot:$GITHUB_ACCESS_TOKEN@github.com/input-output-hk/cardano-wallet gh-pages &>/dev/null
- stage: deploy 🚀
if: (type != pull_request AND branch = master) OR (tag =~ ^v)
name: "Coveralls"
script:
- export LTS=$(cat stack.yaml | grep resolver) # Extract the LTS from the stack.yaml
- git clone https://github.com/rubik/stack-hpc-coveralls && cd stack-hpc-coveralls && git checkout 3d8352d5642ab214a7a574bd797880ae39595a44 && echo $LTS > stack.yaml
- stack --no-terminal install && cd -
- stack --no-terminal install hpc
# Ignore modules that are full of Template Haskell auto-generated code
- cd lib/core
- find $LOCAL_MIX_DIR -type f -name "Cardano.Wallet.DB.Sqlite.TH.mix" > overlay.hpc
- 'sed -i "s/.*hpc\/\(.*\).mix/module \"\1\" {}/" overlay.hpc'
- stack exec -- hpc overlay --hpcdir $LOCAL_MIX_DIR overlay.hpc > Cardano.Wallet.DB.Sqlite.TH.tix
- 'sed -i "s/0,/1,/g" Cardano.Wallet.DB.Sqlite.TH.tix'
- cd -
- mv lib/core/*.tix .coverage/core
# Re-build the coverage report taking .tix from executables running outside of the test suites
- stack hpc report .coverage/**/*.tix
- shc combined custom
################################################################################
#
# Deployment
#
# Only when a tag is present, we do install and deploy the software.
################################################################################
- stage: deploy 🚀
if: tag =~ ^v
name: "Executables"
script:
# Create optimized binaries and checksums
- stack clean
- stack --no-terminal build
- stack --no-terminal install
# Bundle cardano-wallet-jormungandr
- cp $WALLET_CLI_JORMUNGANDR cardano-wallet
- tar czf $WALLET_CLI_JORMUNGANDR_TARGZ cardano-wallet
- sha256sum $WALLET_CLI_JORMUNGANDR | head -c 64 > $WALLET_CLI_JORMUNGANDR_CHECKSUM
- ls $WALLET_CLI_JORMUNGANDR_TARGZ
- ls $WALLET_CLI_JORMUNGANDR_CHECKSUM
# Bundle cardano-wallet-http-bridge
- cp $WALLET_CLI_HTTP_BRIDGE cardano-wallet
- tar czf $WALLET_CLI_HTTP_BRIDGE_TARGZ cardano-wallet
- sha256sum $WALLET_CLI_HTTP_BRIDGE | head -c 64 > $WALLET_CLI_HTTP_BRIDGE_CHECKSUM
- ls $WALLET_CLI_HTTP_BRIDGE_TARGZ
- ls $WALLET_CLI_HTTP_BRIDGE_CHECKSUM
# Deploy documentation snapshot
- mkdir -p haddock/$TRAVIS_TAG api/$TRAVIS_TAG
- cp -Rv specifications/api/* api/$TRAVIS_TAG
- mv $(stack path --local-doc-root)/* haddock/$TRAVIS_TAG
- git checkout --orphan gh-pages-deploy && git reset
- git add api haddock && git commit -m $TRAVIS_COMMIT
- git checkout gh-pages && git merge -X theirs --no-commit --no-ff --allow-unrelated-histories - && git commit --allow-empty --no-edit
- travis_retry git push -f -q https://WilliamKingNoel-Bot:$GITHUB_ACCESS_TOKEN@github.com/input-output-hk/cardano-wallet gh-pages &>/dev/null
deploy:
provider: releases
api_key: $GITHUB_ACCESS_TOKEN
draft: true # Allow editing the release before publishing it officially on GitHub
skip_cleanup: true # Make sure that files from the previous stages aren't cleaned up
file:
- $WALLET_CLI_JORMUNGANDR_TARGZ
- $WALLET_CLI_JORMUNGANDR_CHECKSUM
- $WALLET_CLI_HTTP_BRIDGE_TARGZ
- $WALLET_CLI_HTTP_BRIDGE_CHECKSUM
on:
repo: input-output-hk/cardano-wallet
branch: master
tags: true # Only release when a tag is pushed