-
Notifications
You must be signed in to change notification settings - Fork 151
468 lines (420 loc) · 14.5 KB
/
mobilecoin-dev-cd.yaml
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# Copyright (c) 2018-2022 The MobileCoin Foundation
#
# MobileCoin Core projects - Build, deploy to development.
name: Mobilecoin CD
env:
CHART_REPO: https://harbor.mobilecoin.com/chartrepo/mobilecoinfoundation-public
DOCKER_ORG: mobilecoin
RELEASE_5X_TAG: v5.2.3-dev.alpha.6224
MINIMUM_BLOCK: '6224'
GH_SHORT_SHA: placeholder
RUST_CACHE_PATH: .tmp/rust-bin-cache
RUST_ARTIFACTS_PATH: .tmp/rust-bin-cache/bin/mobilecoin
MEASUREMENTS_ARTIFACTS_PATH: .tmp/rust-bin-cache/measurements/mobilecoin
GO_CACHE_PATH: .tmp/go-bin-cache
GO_ARTIFACTS_PATH: .tmp/go-bin-cache/bin/mobilecoin
on:
pull_request:
branches:
- 'release/**'
paths-ignore:
- '**.md'
push:
branches:
- 'feature/**'
tags:
- 'v[0-9]+*'
paths-ignore:
- '**.md'
# don't run more than one at a time for a branch/tag
concurrency:
group: mobilecoin-dev-cd-${{ github.head_ref || github.ref }}
cancel-in-progress: true
# Ignore dependabot. We just need to 'if' the top level jobs.
# Other jobs that 'need' these top level jobs will be skipped.
jobs:
############################################
# Generate environment information
############################################
generate-metadata:
if: ${{ ! startsWith(github.head_ref, 'dependabot/') }}
name: 👾 Environment Info 👾
runs-on: mcf-dev-small-x64
outputs:
namespace: ${{ steps.meta.outputs.namespace }}
tag: ${{ steps.meta.outputs.tag }}
docker_tag: ${{ steps.meta.outputs.docker_tag }}
docker_org: ${{ env.DOCKER_ORG }}
chart_repo: ${{ env.CHART_REPO }}
release_5x_tag: ${{ env.RELEASE_5X_TAG }}
minimum_block: ${{ env.MINIMUM_BLOCK }}
steps:
- name: Checkout
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Generate version metadata
id: meta
shell: bash
run: |
.internal-ci/util/metadata.sh
- name: 👾 Print Environment Details 👾
shell: bash
env:
CHART_REPO: ${{ env.CHART_REPO }}
NAMESPACE: ${{ steps.meta.outputs.namespace }}
VERSION: ${{ steps.meta.outputs.tag }}
run: |
.internal-ci/util/print_details.sh
#########################################
# Build binaries
#########################################
build-rust-hardware-projects:
needs:
- generate-metadata
runs-on: mcf-dev-large-x64
container:
image: mobilecoin/rust-sgx-base:v0.0.36
env:
# build cannot use relative paths for singing and minting trust root.
ENCLAVE_SIGNING_KEY_PATH: ${{ github.workspace }}/.tmp/enclave_signing.pem
MINTING_TRUST_ROOT_PUBLIC_KEY_PEM: ${{ github.workspace }}/.tmp/minting_trust_root.public.pem
steps:
- name: Checkout
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Write environment values
env:
ENCLAVE_SIGNING_KEY: ${{ secrets.DEV_ENCLAVE_SIGNING_KEY }}
MINTING_TRUST_ROOT_PUBLIC: ${{ secrets.DEV_MINTING_TRUST_ROOT_PUBLIC }}
run: |
mkdir -p .tmp
echo "${ENCLAVE_SIGNING_KEY}" > "${ENCLAVE_SIGNING_KEY_PATH}"
echo "${MINTING_TRUST_ROOT_PUBLIC}" > "${MINTING_TRUST_ROOT_PUBLIC_KEY_PEM}"
- name: Cache rust build binaries
id: rust_artifact_cache
uses: mobilecoinofficial/gh-actions/cache-rust-binaries@v0
with:
cache_buster: ${{ vars.CACHE_BUSTER }}
path: ${{ env.RUST_CACHE_PATH }}
- name: Build rust hardware projects
if: steps.rust_artifact_cache.outputs.cache-hit != 'true'
env:
SGX_MODE: HW
RUST_BACKTRACE: full
MOB_RELEASE: 1
CONSENSUS_ENCLAVE_PRIVKEY: ${{ env.ENCLAVE_SIGNING_KEY_PATH }}
LEDGER_ENCLAVE_PRIVKEY: ${{ env.ENCLAVE_SIGNING_KEY_PATH }}
VIEW_ENCLAVE_PRIVKEY: ${{ env.ENCLAVE_SIGNING_KEY_PATH }}
INGEST_ENCLAVE_PRIVKEY: ${{ env.ENCLAVE_SIGNING_KEY_PATH }}
run: |
cargo build --release --locked
- name: Copy artifacts to cache
if: steps.rust_artifact_cache.outputs.cache-hit != 'true'
shell: bash
run: |
mkdir -p "${RUST_ARTIFACTS_PATH}"
find target/release -maxdepth 1 -executable -type f -exec cp "{}" "${RUST_ARTIFACTS_PATH}" \;
find target/release -maxdepth 1 -name "*.signed.so" -exec cp "{}" "${RUST_ARTIFACTS_PATH}" \;
# clean up target directory so the cache hash compute doesn't fail.
# unable to access ???:
# target/release/build/mc-crypto-x509-test-vectors-***/out/openssl/ok_intermediate1/private
rm -rf target/release
- name: Create css measurements
if: steps.rust_artifact_cache.outputs.cache-hit != 'true'
shell: bash
run: |
mkdir -p "${MEASUREMENTS_ARTIFACTS_PATH}"
orig_dir=$(pwd)
cd "${RUST_ARTIFACTS_PATH}"
for i in *.signed.so
do
css=$(echo -n "${i}" | sed -r 's/(.*)\.signed\.so/\1/')
sgx_sign dump -enclave "${i}" -dumpfile /dev/null -cssfile "${css}.css"
cp "${css}.css" "${orig_dir}/${MEASUREMENTS_ARTIFACTS_PATH}"
done
- name: Check artifacts
shell: bash
run: |
ls -alR "${RUST_CACHE_PATH}"
- name: Upload artifacts - rust
uses: mobilecoinofficial/gh-actions/upload-artifact@v0
with:
name: rust-binaries
path: ${{ env.RUST_ARTIFACTS_PATH }}
- name: Upload artifacts - measurements
uses: mobilecoinofficial/gh-actions/upload-artifact@v0
with:
name: measurements
path: ${{ env.MEASUREMENTS_ARTIFACTS_PATH }}
mrenclave-values:
strategy:
matrix:
enclave:
- libconsensus-enclave.signed.so
- libledger-enclave.signed.so
- libview-enclave.signed.so
- libingest-enclave.signed.so
runs-on: mcf-dev-small-x64
needs:
- build-rust-hardware-projects
container:
image: mobilecoin/rust-sgx-base:v0.0.36
steps:
- name: Checkout
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Cache rust build binaries
id: rust_artifact_cache
uses: mobilecoinofficial/gh-actions/cache-rust-binaries@v0
with:
cache_buster: ${{ vars.CACHE_BUSTER }}
path: ${{ env.RUST_CACHE_PATH }}
- name: Get enclave MRSIGNER/MRENCLAVE values
id: enclave
uses: mobilecoinofficial/gh-actions/enclave-measurements@v0
with:
enclave_so_path: ${{ env.RUST_ARTIFACTS_PATH }}/${{ matrix.enclave }}
build-go-projects:
runs-on: mcf-dev-small-x64
needs:
- generate-metadata
container:
image: golang:1.22.2-bullseye
steps:
- name: Checkout
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Add protobuf-compiler
run: |
apt update
apt install -y protobuf-compiler zstd
- name: Cache go build binaries
id: go_cache
uses: mobilecoinofficial/gh-actions/cache-go-binaries@v0
with:
cache_buster: ${{ vars.CACHE_BUSTER }}
path: ${{ env.GO_CACHE_PATH }}
- name: Build go-grpc-gateway
if: steps.go_cache.outputs.cache-hit != 'true'
shell: bash
run: |
mkdir -p "${GO_ARTIFACTS_PATH}"
pushd go-grpc-gateway
./install_tools.sh
./build.sh
popd
cp go-grpc-gateway/go-grpc-gateway "${GO_ARTIFACTS_PATH}"
- name: check artifacts
shell: bash
run: |
ls -alR "${GO_ARTIFACTS_PATH}"
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: go-binaries
path: ${{ env.GO_ARTIFACTS_PATH }}
########################################
# Create/Refresh base runtime image
########################################
docker-base:
runs-on: mcf-dev-small-x64
needs:
- generate-metadata
steps:
- name: Checkout
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Docker
uses: mobilecoinofficial/gh-actions/docker@v0
with:
dockerfile: .internal-ci/docker/Dockerfile.dcap-runtime-base
flavor: latest=true
images: ${{ env.DOCKER_ORG }}/dcap-runtime-base
tags: |
type=sha
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
#########################################
# Build/Publish public artifacts
#########################################
docker:
runs-on: mcf-dev-small-x64
needs:
- build-go-projects
- build-rust-hardware-projects
- docker-base
- generate-metadata
strategy:
matrix:
image:
- bootstrap-tools
- fogingest
- fog-ledger
- fogreport
- fog-test-client
- fogview
- go-grpc-gateway
- node_hw
- mobilecoind
- watcher
steps:
- name: Checkout
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Cache rust build binaries
id: rust_artifact_cache
uses: mobilecoinofficial/gh-actions/cache-rust-binaries@v0
with:
cache_buster: ${{ vars.CACHE_BUSTER }}
path: ${{ env.RUST_CACHE_PATH }}
- name: Cache go build binaries
uses: mobilecoinofficial/gh-actions/cache-go-binaries@v0
with:
cache_buster: ${{ vars.CACHE_BUSTER }}
path: ${{ env.GO_CACHE_PATH }}
- name: Get short SHA
run: echo "GH_SHORT_SHA=sha-$(echo "${GITHUB_SHA}" | cut -c1-7)" >> "${GITHUB_ENV}"
- name: Docker
uses: mobilecoinofficial/gh-actions/docker@v0
with:
build_args: |
REPO_ORG=${{ env.DOCKER_ORG }}
BASE_TAG=${{ env.GH_SHORT_SHA }}
RUST_BIN_PATH=${{ env.RUST_ARTIFACTS_PATH }}
GO_BIN_PATH=${{ env.GO_ARTIFACTS_PATH }}
dockerfile: .internal-ci/docker/Dockerfile.${{ matrix.image }}
flavor: latest=true
images: ${{ env.DOCKER_ORG }}/${{ matrix.image }}
tags: ${{ needs.generate-metadata.outputs.docker_tag }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
charts:
runs-on: mcf-dev-small-x64
needs:
- docker
- generate-metadata
strategy:
matrix:
chart:
- consensus-node
- fog-ingest
- fog-test-client
- mobilecoind
- watcher
- fog-report
- fog-view
- fog-ledger
steps:
- name: Checkout
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Package and publish chart
uses: mobilecoinofficial/gha-k8s-toolbox@v1
with:
action: helm-publish
chart_repo_username: ${{ secrets.HARBOR_USERNAME }}
chart_repo_password: ${{ secrets.HARBOR_PASSWORD }}
chart_repo: ${{ env.CHART_REPO }}
chart_app_version: ${{ needs.generate-metadata.outputs.tag }}
chart_version: ${{ needs.generate-metadata.outputs.tag }}
chart_path: .internal-ci/helm/${{ matrix.chart }}
################################################
# Bootstrap namespace to v5.2.3-dev from backup
################################################
bootstrap-v5-bv3:
uses: ./.github/workflows/mobilecoin-workflow-dev-bootstrap.yaml
needs:
- generate-metadata
with:
block_version: 3
chart_repo: ${{ needs.generate-metadata.outputs.chart_repo }}
namespace: ${{ needs.generate-metadata.outputs.namespace }}
bootstrap_version: ${{ needs.generate-metadata.outputs.release_5x_tag }}
secrets: inherit
###############################################
# Deploy current version to namespace block v4
###############################################
deploy-current-bv4-release:
uses: ./.github/workflows/mobilecoin-workflow-dev-deploy.yaml
needs:
- bootstrap-v5-bv3
- charts
- generate-metadata
with:
block_version: 4
chart_repo: ${{ needs.generate-metadata.outputs.chart_repo }}
docker_image_org: ${{ needs.generate-metadata.outputs.docker_org }}
ingest_color: blue
namespace: ${{ needs.generate-metadata.outputs.namespace }}
version: ${{ needs.generate-metadata.outputs.tag }}
minimum_block: ${{ needs.generate-metadata.outputs.minimum_block }}
secrets: inherit
test-current-bv4-release:
uses: ./.github/workflows/mobilecoin-workflow-dev-test.yaml
needs:
- deploy-current-bv4-release
- generate-metadata
with:
fog_distribution: false
ingest_color: blue
namespace: ${{ needs.generate-metadata.outputs.namespace }}
testing_block_v0: false
testing_block_v2: false
testing_block_v3: true
generate_and_submit_mint_config_tx_uses_json: true
secrets: inherit
#################################################
# Update current consensus to namespace block vX
#################################################
# update-current-to-bv3:
# uses: ./.github/workflows/mobilecoin-workflow-dev-update-consensus.yaml
# needs:
# - test-current-bv2-release
# - generate-metadata
# with:
# block_version: 4
# chart_repo: ${{ needs.generate-metadata.outputs.chart_repo }}
# namespace: ${{ needs.generate-metadata.outputs.namespace }}
# version: ${{ needs.generate-metadata.outputs.tag }}
# secrets: inherit
# test-current-bv4-release:
# uses: ./.github/workflows/mobilecoin-workflow-dev-test.yaml
# needs:
# - update-current-to-bv3
# - generate-metadata
# with:
# fog_distribution: false
# ingest_color: blue
# namespace: ${{ needs.generate-metadata.outputs.namespace }}
# testing_block_v0: false
# testing_block_v2: false
# testing_block_v3: true
# generate_and_submit_mint_config_tx_uses_json: true
# secrets: inherit
mobilecoin-cd-complete:
# Dummy step for a standard GHA Check that won't change when we update the tests.
runs-on: mcf-dev-small-x64
needs:
- test-current-bv4-release
steps:
- name: CD is Complete
run: 'true'
###############################################################
# Clean up deployments
###############################################################
# we keep feature/*
# run on tag
# run on pr to release/*
cleanup-after-tag:
if: github.ref_type == 'tag'
needs:
- test-current-bv4-release
- generate-metadata
uses: ./.github/workflows/mobilecoin-workflow-dev-reset.yaml
with:
namespace: ${{ needs.generate-metadata.outputs.namespace }}
delete_namespace: true
secrets: inherit
cleanup-after-pr-to-release-branch:
if: github.event_name == 'pull_request' && startsWith(github.base_ref, 'release/')
needs:
- test-current-bv4-release
- generate-metadata
uses: ./.github/workflows/mobilecoin-workflow-dev-reset.yaml
with:
namespace: ${{ needs.generate-metadata.outputs.namespace }}
delete_namespace: true
secrets: inherit