-
Notifications
You must be signed in to change notification settings - Fork 19
338 lines (284 loc) · 15.5 KB
/
test-and-release.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
327
328
329
330
331
332
333
334
335
336
337
338
name: Test and release
# ref. https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
on:
push:
branches:
- main
tags:
- "*"
pull_request:
permissions:
contents: write
jobs:
static_analysis:
name: Static analysis (lint)
runs-on: ubuntu-22.04-16
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
components: rustfmt, clippy
override: true
- name: Check Rust version
run: rustc --version
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true
- name: Run static analysis tests
shell: bash
run: scripts/tests.lint.sh
# check_cargo_unused:
# name: Check Cargo unused
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: nightly
# profile: minimal
# components: rustfmt, clippy
# override: true
# - name: Check Rust version
# run: rustc --version
# - uses: Swatinem/rust-cache@v1
# with:
# cache-on-failure: true
# - name: Check unused Cargo dependencies
# shell: bash
# run: scripts/tests.unused.sh
unit_tests:
name: Unit tests
runs-on: ubuntu-22.04-16
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Check Rust version
run: rustc --version
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true
- name: Run unit tests
run: scripts/tests.unit.sh
release:
name: Release ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}
needs: [static_analysis, unit_tests]
strategy:
matrix:
job:
# use the same OS version as EC2/cloud host
# otherwise, it can fail with:
# error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory
# ref. https://github.com/sfackler/rust-openssl/issues/1748
# ref. https://doc.rust-lang.org/nightly/rustc/platform-support.html
- os: ubuntu-20.04-16
platform: linux
target: x86_64-unknown-linux-gnu
# use the same OS version as CloudFormation template ImageId
# https://github.com/sharkdp/fd/blob/master/.github/workflows/CICD.yml
#
# may require manual builds without cross-linker for linux
# https://users.rust-lang.org/t/cant-cross-compile-project-with-openssl/70922
- os: ubuntu-20.04-16
platform: linux
target: aarch64-unknown-linux-gnu
use-cross: true
# allow failures
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-preventing-a-specific-failing-matrix-job-from-failing-a-workflow-run
experimental: true
- os: macos-latest-large
platform: darwin
target: x86_64-apple-darwin
- os: macos-latest-large
platform: darwin
target: aarch64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v3
# https://github.com/sharkdp/fd/blob/master/.github/workflows/CICD.yml
# https://github.com/cross-rs/cross/wiki/Recipes#openssl
- name: Install OS dependencies
shell: bash
run: |
case ${{ matrix.job.target }} in
arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
esac
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.job.target }}
override: true
- name: Show version information (Rust, cargo, GCC)
shell: bash
run: |
gcc --version || true
rustup -V
rustup toolchain list
rustup default
cargo -V
rustc -V
- name: Set cargo cmd
shell: bash
run: echo "CARGO_CMD=cargo" >> $GITHUB_ENV
- name: Set cargo cmd to cross
shell: bash
if: ${{ matrix.job.use-cross == true }}
run: echo "CARGO_CMD=cross" >> $GITHUB_ENV
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.job.os }}-${{ matrix.job.target }}
- name: Install cross
if: ${{ matrix.job.use-cross == true }}
run: cargo install cross --locked
- name: Build
run: ${{ env.CARGO_CMD }} build --release --target=${{ matrix.job.target }} --bin avalanche-kms --bin avalanched-aws --bin avalancheup-aws --bin blizzard-aws --bin blizzardup-aws --bin staking-key-cert-s3-downloader --bin staking-signer-key-s3-downloader --bin devnet-faucet
- name: Compress binaries
id: release_artifacts
env:
PLATFORM_NAME: ${{ matrix.job.platform }}
TARGET: ${{ matrix.job.target }}
shell: bash
run: |
if [ "$PLATFORM_NAME" == "linux" ]; then
cp ./target/${TARGET}/release/avalanche-kms avalanche-kms.${TARGET}
echo "file_name_avalanche_kms=avalanche-kms.${TARGET}" >> $GITHUB_OUTPUT
tar -czvf avalanche-kms.${TARGET}.tar.gz -C ./target/${TARGET}/release avalanche-kms
echo "file_name_avalanche_kms_tar_gz=avalanche-kms.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
cp ./target/${TARGET}/release/avalanched-aws avalanched-aws.${TARGET}
echo "file_name_avalanched_aws=avalanched-aws.${TARGET}" >> $GITHUB_OUTPUT
tar -czvf avalanched-aws.${TARGET}.tar.gz -C ./target/${TARGET}/release avalanched-aws
echo "file_name_avalanched_aws_tar_gz=avalanched-aws.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
cp ./target/${TARGET}/release/avalancheup-aws avalancheup-aws.${TARGET}
echo "file_name_avalancheup_aws=avalancheup-aws.${TARGET}" >> $GITHUB_OUTPUT
tar -czvf avalancheup-aws.${TARGET}.tar.gz -C ./target/${TARGET}/release avalancheup-aws
echo "file_name_avalancheup_aws_tar_gz=avalancheup-aws.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
cp ./target/${TARGET}/release/blizzard-aws blizzard-aws.${TARGET}
echo "file_name_blizzard_aws=blizzard-aws.${TARGET}" >> $GITHUB_OUTPUT
tar -czvf blizzard-aws.${TARGET}.tar.gz -C ./target/${TARGET}/release blizzard-aws
echo "file_name_blizzard_aws_tar_gz=blizzard-aws.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
cp ./target/${TARGET}/release/blizzardup-aws blizzardup-aws.${TARGET}
echo "file_name_blizzardup_aws=blizzardup-aws.${TARGET}" >> $GITHUB_OUTPUT
tar -czvf blizzardup-aws.${TARGET}.tar.gz -C ./target/${TARGET}/release blizzardup-aws
echo "file_name_blizzardup_aws_tar_gz=blizzardup-aws.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
cp ./target/${TARGET}/release/staking-key-cert-s3-downloader staking-key-cert-s3-downloader.${TARGET}
echo "file_name_staking_key_cert_s3_downloader=staking-key-cert-s3-downloader.${TARGET}" >> $GITHUB_OUTPUT
tar -czvf staking-key-cert-s3-downloader.${TARGET}.tar.gz -C ./target/${TARGET}/release staking-key-cert-s3-downloader
echo "file_name_staking_key_cert_s3_downloader_tar_gz=staking-key-cert-s3-downloader.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
cp ./target/${TARGET}/release/staking-signer-key-s3-downloader staking-signer-key-s3-downloader.${TARGET}
echo "file_name_staking_signer_key_s3_downloader=staking-signer-key-s3-downloader.${TARGET}" >> $GITHUB_OUTPUT
tar -czvf staking-signer-key-s3-downloader.${TARGET}.tar.gz -C ./target/${TARGET}/release staking-signer-key-s3-downloader
echo "file_name_staking_signer_key_s3_downloader_tar_gz=staking-signer-key-s3-downloader.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
cp ./target/${TARGET}/release/devnet-faucet devnet-faucet.${TARGET}
echo "file_name_devnet_faucet=devnet-faucet.${TARGET}" >> $GITHUB_OUTPUT
tar -czvf devnet-faucet.${TARGET}.tar.gz -C ./target/${TARGET}/release devnet-faucet
echo "file_name_devnet_faucet_tar_gz=devnet-faucet.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
elif [ "$PLATFORM_NAME" == "darwin" ]; then
cp ./target/${TARGET}/release/avalanche-kms avalanche-kms.${TARGET}
echo "file_name_avalanche_kms=avalanche-kms.${TARGET}" >> $GITHUB_OUTPUT
gtar -czvf avalanche-kms.${TARGET}.tar.gz -C ./target/${TARGET}/release avalanche-kms
echo "file_name_avalanche_kms_tar_gz=avalanche-kms.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
cp ./target/${TARGET}/release/avalanched-aws avalanched-aws.${TARGET}
echo "file_name_avalanched_aws=avalanched-aws.${TARGET}" >> $GITHUB_OUTPUT
gtar -czvf avalanched-aws.${TARGET}.tar.gz -C ./target/${TARGET}/release avalanched-aws
echo "file_name_avalanched_aws_tar_gz=avalanched-aws.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
cp ./target/${TARGET}/release/avalancheup-aws avalancheup-aws.${TARGET}
echo "file_name_avalancheup_aws=avalancheup-aws.${TARGET}" >> $GITHUB_OUTPUT
gtar -czvf avalancheup-aws.${TARGET}.tar.gz -C ./target/${TARGET}/release avalancheup-aws
echo "file_name_avalancheup_aws_tar_gz=avalancheup-aws.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
cp ./target/${TARGET}/release/blizzard-aws blizzard-aws.${TARGET}
echo "file_name_blizzard_aws=blizzard-aws.${TARGET}" >> $GITHUB_OUTPUT
gtar -czvf blizzard-aws.${TARGET}.tar.gz -C ./target/${TARGET}/release blizzard-aws
echo "file_name_blizzard_aws_tar_gz=blizzard-aws.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
cp ./target/${TARGET}/release/blizzardup-aws blizzardup-aws.${TARGET}
echo "file_name_blizzardup_aws=blizzardup-aws.${TARGET}" >> $GITHUB_OUTPUT
gtar -czvf blizzardup-aws.${TARGET}.tar.gz -C ./target/${TARGET}/release blizzardup-aws
echo "file_name_blizzardup_aws_tar_gz=blizzardup-aws.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
cp ./target/${TARGET}/release/staking-key-cert-s3-downloader staking-key-cert-s3-downloader.${TARGET}
echo "file_name_staking_key_cert_s3_downloader=staking-key-cert-s3-downloader.${TARGET}" >> $GITHUB_OUTPUT
gtar -czvf staking-key-cert-s3-downloader.${TARGET}.tar.gz -C ./target/${TARGET}/release staking-key-cert-s3-downloader
echo "file_name_staking_key_cert_s3_downloader_tar_gz=staking-key-cert-s3-downloader.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
cp ./target/${TARGET}/release/staking-signer-key-s3-downloader staking-signer-key-s3-downloader.${TARGET}
echo "file_name_staking_signer_key_s3_downloader=staking-signer-key-s3-downloader.${TARGET}" >> $GITHUB_OUTPUT
gtar -czvf staking-signer-key-s3-downloader.${TARGET}.tar.gz -C ./target/${TARGET}/release staking-signer-key-s3-downloader
echo "file_name_staking_signer_key_s3_downloader_tar_gz=staking-signer-key-s3-downloader.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
cp ./target/${TARGET}/release/devnet-faucet devnet-faucet.${TARGET}
echo "file_name_devnet_faucet=devnet-faucet.${TARGET}" >> $GITHUB_OUTPUT
gtar -czvf devnet-faucet.${TARGET}.tar.gz -C ./target/${TARGET}/release devnet-faucet
echo "file_name_devnet_faucet_tar_gz=devnet-faucet.${TARGET}.tar.gz" >> $GITHUB_OUTPUT
else
echo "skipping $PLATFORM_NAME"
fi
# release tip from latest commits
# https://github.com/softprops/action-gh-release
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
- name: Release latest
uses: softprops/action-gh-release@v1
if: ${{ github.ref == 'refs/heads/main' }}
with:
name: Latest release
tag_name: latest
draft: false
prerelease: false
body: Latest builds from the last commit.
files: |
${{ steps.release_artifacts.outputs.file_name_avalanche_kms }}
${{ steps.release_artifacts.outputs.file_name_avalanche_kms_tar_gz }}
${{ steps.release_artifacts.outputs.file_name_avalanched_aws }}
${{ steps.release_artifacts.outputs.file_name_avalanched_aws_tar_gz }}
${{ steps.release_artifacts.outputs.file_name_avalancheup_aws }}
${{ steps.release_artifacts.outputs.file_name_avalancheup_aws_tar_gz }}
${{ steps.release_artifacts.outputs.file_name_blizzard_aws }}
${{ steps.release_artifacts.outputs.file_name_blizzard_aws_tar_gz }}
${{ steps.release_artifacts.outputs.file_name_blizzardup_aws }}
${{ steps.release_artifacts.outputs.file_name_blizzardup_aws_tar_gz }}
${{ steps.release_artifacts.outputs.file_name_staking_key_cert_s3_downloader }}
${{ steps.release_artifacts.outputs.file_name_staking_key_cert_s3_downloader_tar_gz }}
${{ steps.release_artifacts.outputs.file_name_staking_signer_key_s3_downloader }}
${{ steps.release_artifacts.outputs.file_name_staking_signer_key_s3_downloader_tar_gz }}
${{ steps.release_artifacts.outputs.file_name_devnet_faucet }}
${{ steps.release_artifacts.outputs.file_name_devnet_faucet_tar_gz }}
# release only for tags
# https://github.com/softprops/action-gh-release
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
- name: Release tag
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
draft: false
prerelease: false
body: Release builds for ${{ github.ref_name }}.
files: |
${{ steps.release_artifacts.outputs.file_name_avalanche_kms }}
${{ steps.release_artifacts.outputs.file_name_avalanche_kms_tar_gz }}
${{ steps.release_artifacts.outputs.file_name_avalanched_aws }}
${{ steps.release_artifacts.outputs.file_name_avalanched_aws_tar_gz }}
${{ steps.release_artifacts.outputs.file_name_avalancheup_aws }}
${{ steps.release_artifacts.outputs.file_name_avalancheup_aws_tar_gz }}
${{ steps.release_artifacts.outputs.file_name_blizzard_aws }}
${{ steps.release_artifacts.outputs.file_name_blizzard_aws_tar_gz }}
${{ steps.release_artifacts.outputs.file_name_blizzardup_aws }}
${{ steps.release_artifacts.outputs.file_name_blizzardup_aws_tar_gz }}
${{ steps.release_artifacts.outputs.file_name_staking_key_cert_s3_downloader }}
${{ steps.release_artifacts.outputs.file_name_staking_key_cert_s3_downloader_tar_gz }}
${{ steps.release_artifacts.outputs.file_name_staking_signer_key_s3_downloader }}
${{ steps.release_artifacts.outputs.file_name_staking_signer_key_s3_downloader_tar_gz }}
${{ steps.release_artifacts.outputs.file_name_devnet_faucet }}
${{ steps.release_artifacts.outputs.file_name_devnet_faucet_tar_gz }}