/
config.yml
326 lines (310 loc) · 12.4 KB
/
config.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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
version: 2
jobs:
build:
docker:
- image: circleci/rust
resource_class: large
environment:
CARGO_HOME: /home/circleci/.cargo
steps:
- checkout
- run:
name: Install Dependencies
command: |
# install system dependeicies
sudo apt-get update
sudo apt-get install -y redis-server redis-tools libssl-dev
# install rust components
cargo install cargo-audit
rustup component add clippy
- run:
name: Reduce codegen Units
# If we don't include this, the linker runs out of memory when building
# the project on CI. We don't include this normally though because
# it should be able to build with more units on other machines
command: printf "[profile.dev]\ncodegen-units = 1\n" >> Cargo.toml
- run:
name: Build
command: cargo build --all-features --all-targets
- run:
name: Test
# Note the timeout is included to make sure that they
# do not run for more than 10 minutes under any circumstances
# (We have had issues with bugs causing the tests to "run"
# for 5 hours, wasting a ton of compute credits)
command: timeout 10m cargo test --all --all-features
environment:
- RUST_LOG: "interledger=trace"
- RUST_BACKTRACE: "full"
- run:
name: Check Style
command: |
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
- run:
name: Audit Dependencies
# Disable:
# 1. http/hyper advisory: outdated http due to yup-oauth2 3.1.1, tungstenite 0.9.2
command: cargo audit --ignore RUSTSEC-2019-0033 --ignore RUSTSEC-2019-0034
test-md:
docker:
- image: circleci/rust
resource_class: large
environment:
# setting BASH_ENV to custom file because .bashrc of circleci/rust doesn't work with
# non-interactive shell.
BASH_ENV: /home/circleci/.bash_circleci
CARGO_HOME: /home/circleci/.cargo
steps:
- checkout
- run:
name: Install Dependencies
command: |
# install system dependeicies
sudo apt-get update
sudo apt-get install -y redis-server redis-tools lsof libssl-dev
# install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
export NVM_DIR="/home/circleci/.nvm"
source $NVM_DIR/nvm.sh
nvm install "v11.15.0"
# install yarn & components (ganache-cli ilp-settlement-xrp conventional-changelog-cli)
curl -o- -L https://yarnpkg.com/install.sh | bash
export PATH="/home/circleci/.yarn/bin:/home/circleci/.config/yarn/global/node_modules/.bin:$PATH"
yarn global add ganache-cli ilp-settlement-xrp conventional-changelog-cli
# env
echo 'export NVM_DIR="/home/circleci/.nvm"' >> ${BASH_ENV}
echo 'source $NVM_DIR/nvm.sh' >> ${BASH_ENV}
echo "export PATH=/home/circleci/.cargo/bin:$PATH" >> ${BASH_ENV}
- run:
name: Run run-md Test
command: |
scripts/run-md-test.sh '^.*$' 1
- store_artifacts:
path: /tmp/run-md-test
destination: run-md-test
update-docker-images:
docker:
- image: circleci/rust
resource_class: medium+
steps:
- setup_remote_docker:
docker_layer_caching: true
- checkout
- run:
# builds release profile images to be released
# consider parallelizing
name: Build Docker Images
no_output_timeout: 30m
command: |
if [ "${CIRCLE_BRANCH}" = "master" ] || [[ "${CIRCLE_TAG}" =~ ^ilp-node- ]]; then
export DOCKER_IMAGE_TAG=$(./.circleci/release/get_docker_image_tag.sh ilp-node ${CIRCLE_TAG})
docker/docker-build.sh ilp-node testnet-bundle
fi
if [ "${CIRCLE_BRANCH}" = "master" ] || [[ "${CIRCLE_TAG}" =~ ^ilp-cli- ]]; then
export DOCKER_IMAGE_TAG=$(./.circleci/release/get_docker_image_tag.sh ilp-cli ${CIRCLE_TAG})
docker/docker-build.sh ilp-cli
fi
environment:
PROFILE: "release"
- run:
name: Push to DockerHub
command: |
echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin
if [ "${CIRCLE_BRANCH}" = "master" ] || [[ "${CIRCLE_TAG}" =~ ^ilp-node- ]]; then
DOCKER_IMAGE_TAG=$(./.circleci/release/get_docker_image_tag.sh ilp-node ${CIRCLE_TAG})
echo "Pushing docker image of tag: interledgerrs/ilp-node:${DOCKER_IMAGE_TAG}"
docker push interledgerrs/ilp-node:${DOCKER_IMAGE_TAG}
docker push interledgerrs/testnet-bundle:${DOCKER_IMAGE_TAG}
fi
if [ "${CIRCLE_BRANCH}" = "master" ] || [[ "${CIRCLE_TAG}" =~ ^ilp-cli- ]]; then
DOCKER_IMAGE_TAG=$(./.circleci/release/get_docker_image_tag.sh ilp-cli ${CIRCLE_TAG})
echo "Pushing docker image of tag: interledgerrs/ilp-cli:${DOCKER_IMAGE_TAG}"
docker push interledgerrs/ilp-cli:${DOCKER_IMAGE_TAG}
fi
build-release-binary-linux:
docker:
- image: circleci/rust
resource_class: medium+
steps:
- setup_remote_docker:
docker_layer_caching: true
- checkout
- run:
# Builds release profile binaries
# The artifact is stored in release-builds directory, which is persistent
name: Build binary
command: |
crate_name=$(./.circleci/release/get_crate_name.sh ${CIRCLE_TAG})
printf "Building crate_name: %s, tag: %s\n" "${crate_name}" "${CIRCLE_TAG}"
mkdir -p /tmp/release-builds/x86_64-unknown-linux-musl
./.circleci/release/build_musl_binary.sh ${crate_name} /tmp/release-builds/x86_64-unknown-linux-musl/${crate_name}
- persist_to_workspace:
root: /tmp/release-builds
paths:
- x86_64-unknown-linux-musl/*
- store_artifacts:
path: /tmp/release-builds/x86_64-unknown-linux-musl
destination: release-builds/x86_64-unknown-linux-musl
build-release-binary-darwin:
macos:
xcode: "10.2.0"
resource_class: medium+
steps:
- checkout
- run:
name: Install Rust
command: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
- run:
# Builds release profile binaries
# The artifact is stored in release-builds directory, which is persistent
name: Build binary
command: |
crate_name=$(./.circleci/release/get_crate_name.sh ${CIRCLE_TAG})
printf "Building crate_name: %s, tag: %s\n" "${crate_name}" "${CIRCLE_TAG}"
cargo build --release --package "${crate_name}" --bin "${crate_name}" --target x86_64-apple-darwin
mkdir -p /tmp/release-builds/x86_64-apple-darwin
cp target/x86_64-apple-darwin/release/${crate_name} /tmp/release-builds/x86_64-apple-darwin/${crate_name}
- persist_to_workspace:
root: /tmp/release-builds
paths:
- x86_64-apple-darwin/*
- store_artifacts:
path: /tmp/release-builds/x86_64-apple-darwin
destination: release-builds/x86_64-apple-darwin
release-binaries:
docker:
- image: circleci/rust
environment:
BASH_ENV: /home/circleci/.bash_circleci
CARGO_HOME: /home/circleci/.cargo
steps:
- attach_workspace:
at: /tmp/release-builds
- checkout
- run:
name: Install Dependencies
command: |
# install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
export NVM_DIR="/home/circleci/.nvm"
source $NVM_DIR/nvm.sh
nvm install "v11.15.0"
# install yarn & components (conventional-changelog-cli)
curl -o- -L https://yarnpkg.com/install.sh | bash
export PATH="/home/circleci/.yarn/bin:/home/circleci/.config/yarn/global/node_modules/.bin:$PATH"
yarn global add conventional-changelog-cli
# env
echo 'export NVM_DIR="/home/circleci/.nvm"' >> ${BASH_ENV}
echo 'source $NVM_DIR/nvm.sh' >> ${BASH_ENV}
echo "export PATH=/home/circleci/.cargo/bin:$PATH" >> ${BASH_ENV}
- run:
name: Release Binaries
command: |
mkdir -p logs
crate_name=$(./.circleci/release/get_crate_name.sh ${CIRCLE_TAG})
# linux musl
base_dir=/tmp/release-builds/x86_64-unknown-linux-musl
pushd ${base_dir}
musl_zip="${base_dir}/${crate_name}-x86_64-unknown-linux-musl.zip"
musl_tar_gz="${base_dir}/${crate_name}-x86_64-unknown-linux-musl.tar.gz"
zip $(basename ${musl_zip}) ${crate_name}
tar -zcvf $(basename ${musl_tar_gz}) ${crate_name}
popd
# macOS
base_dir=/tmp/release-builds/x86_64-apple-darwin
pushd ${base_dir}
darwin_zip="${base_dir}/${crate_name}-x86_64-apple-darwin.zip"
darwin_tar_gz="${base_dir}/${crate_name}-x86_64-apple-darwin.tar.gz"
zip $(basename ${darwin_zip}) ${crate_name}
tar -zcvf $(basename ${darwin_tar_gz}) ${crate_name}
popd
# Auto-generate a release note
release_note=logs/release_note.txt
conventional-changelog -t ${crate_name}- -p angular > ${release_note}
# tag release
./.circleci/release/github_release.sh \
${CIRCLE_TAG} \
${CIRCLE_TAG} \
${release_note} \
${musl_zip} \
${musl_tar_gz} \
${darwin_zip} \
${darwin_tar_gz}
# latest release, only if on the master branch
# tag the current commit as (crate_name)-latest, and release it
if [ "${CIRCLE_BRANCH}" == "master" ]; then
tag_name="${crate_name}-latest"
LOG_DIR=logs/${tag_name} ./.circleci/release/github_tag.sh \
${tag_name} \
"The latest release of ${crate_name}." \
"$(git rev-parse HEAD)" \
"commit"
./.circleci/release/github_release.sh \
${tag_name} \
${tag_name} \
${release_note} \
${musl_zip} \
${musl_tar_gz} \
${darwin_zip} \
${darwin_tar_gz}
fi
- store_artifacts:
path: logs
destination: release-binaries-logs
workflows:
version: 2
test-and-release:
jobs:
- build:
filters:
tags:
only: # we need this to kick builds when tags are given
- /.*/
- test-md:
filters:
tags:
only: # we need this to kick builds when tags are given
- /.*/
- update-docker-images: # updates docker images on DockerHub, only if the branch is master or something is tagged
filters:
branches:
only: # master branch will be tagged as `latest` image
- master
tags:
only: # whatever tagged binary crates
- /^(ilp-node-|ilp-cli-).*$/
requires:
- build
- build-release-binary-linux:
filters:
branches:
ignore: # no branch pushes are built
- /.*/
tags:
only: # whatever tagged binary crates
- /^(ilp-node-|ilp-cli-).*$/
requires:
- build
- build-release-binary-darwin:
filters:
branches:
ignore: # no branch pushes are built
- /.*/
tags:
only: # whatever tagged binary crates
- /^(ilp-node-|ilp-cli-).*$/
requires:
- build
- release-binaries:
filters:
branches:
ignore: # no branch pushes are built
- /.*/
tags:
only: # whatever tagged binary crates
- /^(ilp-node-|ilp-cli-).*$/
requires:
- build-release-binary-linux
- build-release-binary-darwin