-
Notifications
You must be signed in to change notification settings - Fork 151
514 lines (453 loc) · 16.6 KB
/
ci.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
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
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
name: CI
on:
pull_request:
push:
branches:
- main
- 'release/**'
paths-ignore:
- '**.md'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
MC_TELEMETRY: 0
SKIP_SLOW_TESTS: 1
SGX_MODE: SW
permissions:
checks: write
jobs:
build-dev:
runs-on: mcf-dev-large-x64
container: mobilecoin/builder-install:v0.0.36
steps:
- name: Check out code
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Cargo build (SW)
shell: bash
run: cargo build --locked
- name: Check dirty git
uses: ./.github/actions/check-dirty-git
build-prod:
runs-on: mcf-dev-large-x64
container: mobilecoin/builder-install:v0.0.36
steps:
- name: Check out code
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Cargo build (HW)
env:
SGX_MODE: HW
shell: bash
run: cargo build --locked
- name: Check dirty git
uses: ./.github/actions/check-dirty-git
build-and-test-wasm:
runs-on: mcf-dev-large-x64
container: mobilecoin/builder-install:v0.0.36
steps:
- name: Check out code
uses: mobilecoinofficial/gh-actions/checkout@v0
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build and test the wasm-test crate
env:
SGX_MODE: HW
run: wasm-pack test --node wasm-test
lint-rust:
runs-on: mcf-dev-large-x64
container: mobilecoin/builder-install:v0.0.36
steps:
- name: Check out code
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Run lint script
run: ./tools/lint.sh --check
- name: Check dirty git
uses: ./.github/actions/check-dirty-git
build-and-test-go:
runs-on: mcf-dev-large-x64
container: mobilecoin/builder-install:v0.0.36
steps:
- name: Check out code
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Build go
working-directory: go-grpc-gateway
shell: bash
run: ./install_tools.sh && ./build.sh
- name: Check dirty git
uses: ./.github/actions/check-dirty-git
- name: Lint Go code
working-directory: go-grpc-gateway
shell: bash
run: ./lint.sh
- name: Check dirty git
uses: ./.github/actions/check-dirty-git
- name: Build rust testing stub
working-directory: go-grpc-gateway/testing
shell: bash
run: cargo build --locked
- name: Run curl test
working-directory: go-grpc-gateway
shell: bash
run: ./test.sh
- name: Check dirty git
uses: ./.github/actions/check-dirty-git
docs:
runs-on: mcf-dev-large-x64
container: mobilecoin/builder-install:v0.0.36
steps:
- name: Check out code
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Generate docs
shell: bash
run: cargo doc --no-deps && tar -C target -czvf /tmp/doc.tgz doc/
- name: Store docs
uses: mobilecoinofficial/gh-actions/upload-artifact@v0
with:
name: doc.tgz
path: /tmp/doc.tgz
- name: Check dirty git
uses: ./.github/actions/check-dirty-git
mc-tests:
runs-on: mcf-dev-large-x64
container: mobilecoin/builder-install:v0.0.36
strategy:
matrix:
num_runners: [2]
runner_index: [1, 2]
# Run each shard to completion.
fail-fast: false
env:
NUM_RUNNERS: ${{ matrix.num_runners }}
RUNNER_INDEX: ${{ matrix.runner_index }}
steps:
- name: Check out code
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: List packages to test\
shell: bash
run: |
cargo metadata --no-deps --format-version=1 | jq -r '.packages[].name' | \
grep -v -e mc-fog -e mc-consensus | \
awk "{ print \"-p \" \$1 }" | \
sort > /tmp/test-packages
split -n "l/$RUNNER_INDEX/$NUM_RUNNERS" /tmp/test-packages | \
tee /tmp/mc-test-packages
# Hack: mc-util-sample-ledger needs mc-util-keyfile bins.
# TODO: Replace with artifact deps when that does not require
# additional cargo flags.
if grep -q generate-sample-ledger /tmp/mc-test-packages
then
echo '-p mc-util-keyfile' >> /tmp/mc-test-packages
fi
- name: Run tests
uses: ./.github/actions/run-mc-tests
with:
args: $(cat /tmp/mc-test-packages)
junit_artifact: junit-mc-tests-${{matrix.runner_index}}
consensus-tests:
runs-on: mcf-dev-large-x64
container: mobilecoin/builder-install:v0.0.36
strategy:
matrix:
num_runners: [2]
runner_index: [1, 2]
# Run each shard to completion.
fail-fast: false
env:
NUM_RUNNERS: ${{ matrix.num_runners }}
RUNNER_INDEX: ${{ matrix.runner_index }}
steps:
- name: Check out code
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: List packages to test
shell: bash
run: |
cargo metadata --no-deps --format-version=1 | jq -r '.packages[].name' | \
awk "/mc-consensus/ { print \"-p \" \$1 }" | \
sort > /tmp/test-packages
split -n "l/$RUNNER_INDEX/$NUM_RUNNERS" /tmp/test-packages | \
tee /tmp/consensus-test-packages
- name: Run tests
uses: ./.github/actions/run-mc-tests
with:
args: $(cat /tmp/consensus-test-packages)
junit_artifact: junit-consensus-tests-${{matrix.runner_index}}
fog-tests:
runs-on: mcf-dev-large-x64
container: mobilecoin/builder-install:v0.0.36
strategy:
matrix:
num_runners: [4]
runner_index: [1, 2, 3, 4]
# Run each shard to completion.
fail-fast: false
env:
NUM_RUNNERS: ${{ matrix.num_runners }}
RUNNER_INDEX: ${{ matrix.runner_index }}
services:
postgres:
image: postgres
env:
POSTGRES_HOST_AUTH_METHOD: trust
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check out code
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: List packages to test
shell: bash
run: |
cargo metadata --no-deps --format-version=1 | jq -r '.packages[].name' | \
awk "/mc-fog/ { print \"-p \" \$1 }" | \
grep -v mc-fog-ingest | \
sort > /tmp/test-packages
split -n "l/$RUNNER_INDEX/$NUM_RUNNERS" /tmp/test-packages | \
tee /tmp/fog-test-packages
# Hack: mc-fog-distribution needs bins from
# mc-util-{keyfile,generate-sample-ledger}.
# TODO: Replace with artifact deps when that does not require
# additional cargo flags.
if grep -q fog-distribution /tmp/fog-test-packages
then
echo '-p mc-util-keyfile -p mc-util-generate-sample-ledger' >> /tmp/fog-test-packages
fi
- name: Run tests
uses: ./.github/actions/run-mc-tests
with:
args: $(cat /tmp/fog-test-packages)
junit_artifact: junit-fog-tests-${{matrix.runner_index}}
env:
# TEST_DATABASE_URL points at the server, as Fog recovery DB tests
# create and drop PG databases.
TEST_DATABASE_URL: postgres://postgres@postgres
fog-ingest-tests:
runs-on: mcf-dev-large-x64
container: mobilecoin/builder-install:v0.0.36
services:
postgres:
image: postgres
env:
POSTGRES_HOST_AUTH_METHOD: trust
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check out code
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Run tests
uses: ./.github/actions/run-mc-tests
with:
# These tests time out without release mode.
args: -p 'mc-fog-ingest-*' --release
junit_artifact: junit-fog-ingest-tests
env:
# TEST_DATABASE_URL points at the server, as Fog recovery DB tests
# create and drop PG databases.
TEST_DATABASE_URL: postgres://postgres@postgres
fog-conformance-tests:
runs-on: mcf-dev-large-x64
container: mobilecoin/builder-install:v0.0.36
services:
postgres:
image: postgres
env:
POSTGRES_HOST_AUTH_METHOD: trust
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check out code
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3'
- name: Set up environment
working-directory: tools/fog-local-network
shell: bash
run: |
python3 -m venv env
. ./env/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
./build.sh
- name: fog_conformance_tests.py
working-directory: tools/fog-local-network
env:
PGHOST: postgres
PGUSER: postgres
shell: bash
run: |
. /opt/intel/sgxsdk/environment
. ./env/bin/activate
python3 fog_conformance_tests.py --release
- name: Upload core dumps
uses: ./.github/actions/upload-core-dumps
- name: Check dirty git
uses: ./.github/actions/check-dirty-git
# An end to end test to ensure minting works and that the fog local
# network script continues to work.
# This test has more than one purpose, due to the time it takes to generate
# sample keys and sample ledger
minting-and-burning-tests:
runs-on: mcf-dev-large-x64
container: mobilecoin/builder-install:v0.0.36
services:
postgres:
image: postgres
env:
POSTGRES_HOST_AUTH_METHOD: trust
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check out code
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3'
- name: Build and generate sample data
shell: bash
run: |
. /opt/intel/sgxsdk/environment
# Generate enclave signing key
openssl genrsa -out Enclave_private.pem -3 3072
export CONSENSUS_ENCLAVE_PRIVKEY="$PWD/Enclave_private.pem"
export INGEST_ENCLAVE_PRIVKEY="$PWD/Enclave_private.pem"
export LEDGER_ENCLAVE_PRIVKEY="$PWD/Enclave_private.pem"
export VIEW_ENCLAVE_PRIVKEY="$PWD/Enclave_private.pem"
export MC_LOG=debug
# Build binaries
cargo build \
-p mc-admin-http-gateway \
-p mc-consensus-mint-client \
-p mc-consensus-service \
-p mc-consensus-tool \
-p mc-crypto-x509-test-vectors \
-p mc-fog-distribution \
-p mc-fog-ingest-client \
-p mc-fog-ingest-server \
-p mc-fog-ledger-server \
-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-mobilecoind \
-p mc-mobilecoind-dev-faucet \
-p mc-util-generate-sample-ledger \
-p mc-util-grpc-admin-tool \
-p mc-util-keyfile \
-p mc-util-seeded-ed25519-key-gen \
--release
BIN_DIR="$PWD/target/release"
# Run in temp dir to appease check-dirty-git.
mkdir -p /tmp/fog-local-network
cd /tmp/fog-local-network || exit 1
# Generate sample keys and ledger.
FOG_AUTHORITY_ROOT=$("$BIN_DIR/mc-crypto-x509-test-vectors" --type=chain --test-name=ok_rsa_head)
"$BIN_DIR/sample-keys" --num 10 --seed=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
"$BIN_DIR/generate-sample-ledger" --txs 100
# Generate sample Fog keys.
"$BIN_DIR/sample-keys" --num 4 --output-dir fog_keys --fog-report-url 'insecure-fog://localhost:6200' --fog-authority-root "$FOG_AUTHORITY_ROOT"
- name: Run local network
env:
PGHOST: postgres
PGUSER: postgres
shell: bash
run: |
BIN_DIR="$PWD/target/release"
SCRIPT_DIR="$PWD/tools/fog-local-network"
STRATEGIES_DIR="$PWD/mobilecoind/strategies"
export MC_CHAIN_ID="local"
export MC_LOG=info
# This is needed since we want to capture the output of mc-consensus-tool, and we can't have the
# logs getting in the way.
export MC_LOG_STDERR=1
# Used by mc-consensus-tool
export MC_PEER="insecure-mc://localhost:3200/,insecure-mc://localhost:3201/,insecure-mc://localhost:3202/,insecure-mc://localhost:3203/,insecure-mc://localhost:3204/"
cd /tmp/fog-local-network
export LEDGER_BASE="$PWD/ledger"
# Run local network in background.
MC_LOG="info,rustls=warn,hyper=warn,tokio_reactor=warn,mio=warn,want=warn,rusoto_core=error,h2=error,reqwest=error,rocket=error,<unknown>=error" \
python3 "$SCRIPT_DIR/fog_local_network.py" --network-type dense5 --skip-build &
# Give it time to spin up
for PORT in 3200 3201 3202 3203 3204 4444; do
for _unused in $(seq 0 60); do
if ss -l | grep -q ":$PORT"; then break; else sleep 1; fi;
done
done
PRE_AUTH_BLOCK_INDEX=$("$BIN_DIR/mc-consensus-tool" wait-for-quiet)
# Authorize minters
echo "Authorizing minters"
python3 "$SCRIPT_DIR/../local-network/authorize-minters.py"
echo "Waiting for quiet after authorizing minters..."
PRE_MINT_BLOCK_INDEX=$("$BIN_DIR/mc-consensus-tool" wait-for-quiet --beyond-block="$PRE_AUTH_BLOCK_INDEX")
echo "Done waiting, PRE_MINT_BLOCK_INDEX=${PRE_MINT_BLOCK_INDEX}"
# Mint 1 million token1's to the first 4 accounts
echo "Minting"
for ACCOUNT_NUM in $(seq 0 3); do
"$BIN_DIR/mc-consensus-mint-client" \
generate-and-submit-mint-tx \
--node insecure-mc://localhost:3200/ \
--signing-key "$BIN_DIR/mc-local-network/minting-keys/minter1" \
--recipient "$(cat "keys/account_keys_${ACCOUNT_NUM}.b58pub")" \
--token-id 1 \
--amount 1000000
done
echo "Waiting for quiet after minting"
POST_MINT_BLOCK_INDEX=$("$BIN_DIR/mc-consensus-tool" wait-for-quiet --beyond-block "$PRE_MINT_BLOCK_INDEX")
echo "Done waiting, POST_MINT_BLOCK_INDEX = ${POST_MINT_BLOCK_INDEX}"
# Use burn.py to burn some token1
cd "$STRATEGIES_DIR" || exit 1
./compile_proto.sh
python3 burn.py \
--mobilecoind-host localhost \
--mobilecoind-port 4444 \
--key "$LEDGER_BASE/../keys/account_keys_2.json" \
--value 550000 \
--token-id 1 \
--fee 10000 \
--burn-redemption-memo "0xf43f5e8C04519efE0f54d7eBAEab20E86b235114"
- name: Upload core dumps
uses: ./.github/actions/upload-core-dumps
- name: Check dirty git
uses: ./.github/actions/check-dirty-git
publish-test-results:
runs-on: mcf-dev-small-x64
if: success() || failure()
needs:
- mc-tests
- consensus-tests
- fog-tests
- fog-ingest-tests
steps:
- name: Download XML reports
if: success() || failure()
uses: actions/download-artifact@v4
- name: Publish Test Report
if: success() || failure()
uses: mikepenz/action-junit-report@v4
with:
check_name: Test Report
report_paths: '**/*.xml'
# via https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true