forked from mobilecoinfoundation/mobilecoin
-
Notifications
You must be signed in to change notification settings - Fork 0
499 lines (452 loc) · 15.8 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
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
# 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_3X_TAG: v3.0.0-dev
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: [self-hosted, Linux, small]
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_3x_tag: ${{ env.RELEASE_3X_TAG }}
steps:
- name: Checkout
uses: actions/checkout@v3
- 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: [self-hosted, Linux, large-cd]
container:
image: mobilecoin/rust-sgx-base:v0.0.23
env:
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
if: "! contains(github.event.head_commit.message, '[skip build]')"
uses: actions/checkout@v3
- name: Write environment values
if: "! contains(github.event.head_commit.message, '[skip build]')"
env:
ENCLAVE_SIGNING_KEY: ${{ secrets.DEV_ENCLAVE_SIGNING_KEY }}
MINTING_TRUST_ROOT_PUBLIC: ${{ secrets.DEV_MINTING_TRUST_ROOT_PUBLIC }}
run: |
mkdir -p "${GITHUB_WORKSPACE}/.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
if: "! contains(github.event.head_commit.message, '[skip build]')"
id: rust_artifact_cache
uses: ./.github/actions/mobilecoin-cache-rust-binaries
with:
cache_buster: ${{ secrets.CACHE_BUSTER }}
- name: Cache cargo packages
# We don't need cargo packages if we already have binaries.
if: |
steps.rust_artifact_cache.outputs.cache-hit != 'true' &&
! contains(github.event.head_commit.message, '[skip build]')
uses: ./.github/actions/mobilecoin-cache-cargo-package
with:
cache_buster: ${{ secrets.CACHE_BUSTER }}
- name: Build rust hardware projects
if: |
steps.rust_artifact_cache.outputs.cache-hit != 'true' &&
! contains(github.event.head_commit.message, '[skip build]')
env:
IAS_MODE: DEV
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: |
git config --global --add safe.directory '*'
cargo build --release \
-p mc-admin-http-gateway \
-p mc-consensus-mint-client \
-p mc-consensus-service \
-p mc-fog-distribution \
-p mc-fog-ingest-client \
-p mc-fog-ingest-server \
-p mc-fog-ledger-server \
-p mc-fog-report-cli \
-p mc-fog-report-server \
-p mc-fog-sql-recovery-db \
-p mc-fog-test-client \
-p mc-fog-view-server \
-p mc-ledger-distribution \
-p mc-ledger-from-archive \
-p mc-ledger-migration \
-p mc-mobilecoind \
-p mc-mobilecoind-dev-faucet \
-p mc-mobilecoind-json \
-p mc-util-generate-sample-ledger \
-p mc-util-grpc-admin-tool \
-p mc-util-grpc-token-generator \
-p mc-util-keyfile \
-p mc-util-seeded-ed25519-key-gen \
-p mc-watcher
- name: Copy artifacts to cache
if: |
steps.rust_artifact_cache.outputs.cache-hit != 'true' &&
! contains(github.event.head_commit.message, '[skip build]')
run: |
mkdir -p rust_build_artifacts
find target/release -maxdepth 1 -executable -type f -exec cp "{}" rust_build_artifacts/ \;
find target/release -maxdepth 1 -name "*.signed.so" -exec cp "{}" rust_build_artifacts/ \;
- name: Create css measurements
if: |
steps.rust_artifact_cache.outputs.cache-hit != 'true' &&
! contains(github.event.head_commit.message, '[skip build]')
shell: bash
run: |
cd rust_build_artifacts
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"
done
- name: Check artifacts
if: "! contains(github.event.head_commit.message, '[skip build]')"
run: |
ls -alR rust_build_artifacts
- name: Upload artifacts
if: "! contains(github.event.head_commit.message, '[skip build]')"
uses: actions/upload-artifact@v3
with:
name: rust-binaries
path: rust_build_artifacts/
build-go-projects:
runs-on: [self-hosted, Linux, small]
needs:
- generate-metadata
container:
image: golang:1.18.5
steps:
- name: Checkout
if: "! contains(github.event.head_commit.message, '[skip build]')"
uses: actions/checkout@v3
- name: Add protobuf-compiler
if: "! contains(github.event.head_commit.message, '[skip build]')"
run: |
apt update
apt install -y protobuf-compiler zstd
- name: Cache go build binaries
if: "! contains(github.event.head_commit.message, '[skip build]')"
id: go_artifact_cache
uses: ./.github/actions/mobilecoin-cache-go-binaries
with:
cache_buster: ${{ secrets.CACHE_BUSTER }}
- name: Build go-grpc-gateway
if: |
steps.go_artifact_cache.outputs.cache-hit != 'true' &&
! contains(github.event.head_commit.message, '[skip build]')
run: |
cd go-grpc-gateway
./install_tools.sh
./build.sh
mkdir -p ../go_build_artifacts
cp grpc-proxy ../go_build_artifacts/
- name: check artifacts
if: "! contains(github.event.head_commit.message, '[skip build]')"
run: |
ls -alR go_build_artifacts
- name: Upload Artifacts
if: "! contains(github.event.head_commit.message, '[skip build]')"
uses: actions/upload-artifact@v3
with:
name: go-binaries
path: go_build_artifacts/
########################################
# Create/Refresh base runtime image
########################################
docker-base:
runs-on: [self-hosted, Linux, small]
needs:
- generate-metadata
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Generate Docker Tags
id: docker_meta
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_ORG }}/runtime-base
flavor: |
latest=true
tags: |
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Publish to DockerHub
id: docker_publish_dockerhub
uses: docker/build-push-action@v4
with:
build-args: |
REPO_ORG=${{ env.DOCKER_ORG }}
context: .
file: .internal-ci/docker/Dockerfile.runtime-base
labels: ${{ steps.docker_meta.outputs.labels }}
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
#########################################
# Build/Publish public artifacts
#########################################
docker:
runs-on: [self-hosted, Linux, small]
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: actions/checkout@v3
- name: Cache rust build binaries
id: rust_artifact_cache
uses: ./.github/actions/mobilecoin-cache-rust-binaries
with:
cache_buster: ${{ secrets.CACHE_BUSTER }}
- name: Cache go build binaries
id: go_artifact_cache
uses: ./.github/actions/mobilecoin-cache-go-binaries
with:
cache_buster: ${{ secrets.CACHE_BUSTER }}
- name: Generate Docker Tags
id: docker_meta
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_ORG }}/${{ matrix.image }}
tags: ${{ needs.generate-metadata.outputs.docker_tag }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get short SHA
run: echo "GH_SHORT_SHA=sha-$(echo "${GITHUB_SHA}" | cut -c1-7)" >> "${GITHUB_ENV}"
- name: Publish to DockerHub
id: docker_publish_dockerhub
uses: docker/build-push-action@v4
with:
build-args: |
REPO_ORG=${{ env.DOCKER_ORG }}
BASE_TAG=${{ env.GH_SHORT_SHA }}
RUST_BIN_PATH=rust_build_artifacts
GO_BIN_PATH=go_build_artifacts
cache-from: type=registry,ref=${{ env.DOCKER_ORG }}/${{ matrix.image }}:buildcache-${{ needs.generate-metadata.outputs.namespace }}
cache-to: type=registry,ref=${{ env.DOCKER_ORG }}/${{ matrix.image }}:buildcache-${{ needs.generate-metadata.outputs.namespace }}
context: .
file: .internal-ci/docker/Dockerfile.${{ matrix.image }}
labels: ${{ steps.docker_meta.outputs.labels }}
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
charts:
runs-on: [self-hosted, Linux, small]
needs:
- docker
- generate-metadata
strategy:
matrix:
chart:
- consensus-node
- consensus-node-config
- fog-ingest
- fog-ingest-config
- fog-services
- fog-services-config
- fog-test-client
- mc-core-common-config
- mc-core-dev-env-setup
- mobilecoind
- watcher
steps:
- name: Checkout
if: "! contains(github.event.head_commit.message, '[skip charts]')"
uses: actions/checkout@v3
- name: Package and publish chart
if: "! contains(github.event.head_commit.message, '[skip charts]')"
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 v3.0.0-dev from backup
################################################
bootstrap-v3-bv2:
uses: ./.github/workflows/mobilecoin-workflow-dev-bootstrap.yaml
needs:
- generate-metadata
with:
block_version: 2
chart_repo: ${{ needs.generate-metadata.outputs.chart_repo }}
namespace: ${{ needs.generate-metadata.outputs.namespace }}
version: ${{ needs.generate-metadata.outputs.release_3x_tag }}
secrets: inherit
###############################################
# Deploy current version to namespace block v2
###############################################
deploy-current-bv2-release:
uses: ./.github/workflows/mobilecoin-workflow-dev-deploy.yaml
needs:
- bootstrap-v3-bv2
- charts
- generate-metadata
with:
block_version: 2
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 }}
secrets: inherit
test-current-bv2-release:
uses: ./.github/workflows/mobilecoin-workflow-dev-test.yaml
needs:
- deploy-current-bv2-release
- generate-metadata
with:
fog_distribution: false
ingest_color: blue
namespace: ${{ needs.generate-metadata.outputs.namespace }}
testing_block_v0: false
testing_block_v2: true
testing_block_v3: false
generate_and_submit_mint_config_tx_uses_json: true
secrets: inherit
#################################################
# Update current consensus to namespace block v3
#################################################
update-current-to-bv3:
uses: ./.github/workflows/mobilecoin-workflow-dev-update-consensus.yaml
needs:
- test-current-bv2-release
- generate-metadata
with:
block_version: 3
chart_repo: ${{ needs.generate-metadata.outputs.chart_repo }}
namespace: ${{ needs.generate-metadata.outputs.namespace }}
version: ${{ needs.generate-metadata.outputs.tag }}
secrets: inherit
test-current-bv3-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: [self-hosted, Linux, small]
needs:
- test-current-bv3-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-bv3-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-bv3-release
- generate-metadata
uses: ./.github/workflows/mobilecoin-workflow-dev-reset.yaml
with:
namespace: ${{ needs.generate-metadata.outputs.namespace }}
delete_namespace: true
secrets: inherit