-
Notifications
You must be signed in to change notification settings - Fork 21
360 lines (312 loc) · 10.5 KB
/
on-pr.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
# Placeholder for the PR workflow.
name: on-pr
on:
pull_request: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
pull-requests: write
contents: read
env:
ARTIFACT_NAME: placeholder
CONSENSUS_ENCLAVE_CSS: /tmp/consensus-enclave.css
GH_SHORT_SHA: placeholder
INGEST_ENCLAVE_CSS: /tmp/ingest-enclave.css
RUST_BACKTRACE: full
RUST_BIN_PATH: placeholder
jobs:
# move lint actions to gh-actions for centralization
# lint-actions:
# runs-on: mco-dev-small-x64
# steps:
# - name: Checkout
# uses: mobilecoinofficial/gh-actions/checkout@v0
# - name: Run actionlint with reviewdog
# uses: reviewdog/action-actionlint@v1
# with:
# level: error
# reporter: github-pr-review
# lint-helm:
# runs-on: mco-dev-small-x64
# container:
# image: mobilecoin/gha-k8s-toolbox:v1
# steps:
# - name: Checkout
# uses: mobilecoinofficial/gh-actions/checkout@v0
# - name: Run helm lint
# run: |
# chart_base=".internal-ci/helm"
# chart_files=$(find "${chart_base}" -name Chart.yaml -type f)
# # helm lint on directories where there are chart.yaml files
# for c in ${chart_files}
# do
# chart=$(dirname "${c}")
# helm lint --quiet "${chart}" 2>&1
# done
# CBB: Need to do refactoring of shell scripts in the repo for this to run cleanly.
# lint-shell:
# runs-on: mco-dev-small-x64
# steps:
# - name: Checkout
# uses: mobilecoinofficial/gh-actions/checkout@v0
# - name: Run shellcheck with reviewdog
# uses: reviewdog/action-shellcheck@v1
# with:
# level: error
# reporter: github-pr-review
# lint-docker:
# runs-on: mco-dev-small-x64
# steps:
# - name: Checkout
# uses: mobilecoinofficial/gh-actions/checkout@v0
# - name: Install wget
# run: |
# sudo apt-get update
# sudo apt-get install -y wget
# - name: Run hadolint with reviewdog
# uses: reviewdog/action-hadolint@v1
# with:
# level: error
# reporter: github-pr-review
# exclude: |
# *.dockerignore
# lint-rust:
# runs-on: mco-dev-large-x64
# container:
# image: mobilecoin/rust-sgx-base:v0.0.36
# env:
# SGX_MODE: SW
# steps:
# - name: Checkout
# uses: mobilecoinofficial/gh-actions/checkout@v0
# - name: Consensus SigStruct
# uses: ./.github/actions/download-sigstruct
# with:
# sigstruct: consensus
# network: test
# download_path: ${{ env.CONSENSUS_ENCLAVE_CSS }}
# - name: Ingest SigStruct
# uses: ./.github/actions/download-sigstruct
# with:
# sigstruct: ingest
# network: test
# download_path: ${{ env.INGEST_ENCLAVE_CSS }}
# - name: Cargo sort
# shell: bash
# run: |
# cargo install cargo-sort --force
# cargo sort --workspace --grouped --check
# - name: Cargo fmt
# shell: bash
# run: |
# cargo fmt -- --unstable-features --check
# - name: Cargo Clippy
# shell: bash
# run: |
# cargo clippy --all --all-features
# test-rust:
# runs-on: mco-dev-large-x64
# container:
# image: mobilecoin/rust-sgx-base:v0.0.36
# env:
# SGX_MODE: SW
# steps:
# - name: Checkout
# uses: mobilecoinofficial/gh-actions/checkout@v0
# - name: Consensus SigStruct
# uses: ./.github/actions/download-sigstruct
# with:
# sigstruct: consensus
# network: test
# download_path: ${{ env.CONSENSUS_ENCLAVE_CSS }}
# - name: Ingest SigStruct
# uses: ./.github/actions/download-sigstruct
# with:
# sigstruct: ingest
# network: test
# download_path: ${{ env.INGEST_ENCLAVE_CSS }}
# - name: Cargo Test
# shell: bash
# env:
# CARGO_INCREMENTAL: "0"
# RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
# RUSTDOCFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
# run: |
# cargo test
# skip coverage for now, old actions-rs/grcov is deprecated
# need to learn how to generate .xml reports for codecov below
# - name: grcov
# shell: bash
# run: |
# cargo install grcov
# - name: Codecov
# uses: codecov/codecov-action@v3.1.4
# with:
# files: ${{ steps.coverage.outputs.report }}
# verbose: true
# fail_ci_if_error: true
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
build-rust-linux:
strategy:
matrix:
runner:
- mco-dev-large-x64
network:
- main
- test
runs-on: ${{ matrix.runner }}
container:
image: mobilecoin/rust-sgx-base:v0.0.36
steps:
- name: Checkout
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Build Rust
uses: ./.github/actions/build-rust
with:
network: ${{ matrix.network }}
# build-rust-macos:
# strategy:
# fail-fast: false
# matrix:
# runner:
# - [self-hosted, macOS, X64]
# - [self-hosted, macOS, ARM64]
# network:
# - main
# - test
# runs-on: ${{ matrix.runner }}
# steps:
# - name: Checkout
# uses: mobilecoinofficial/gh-actions/checkout@v0
# - name: Bootstrap macOS
# shell: bash
# run: |
# echo "-- install brew dependencies"
# rm -rf "$(brew --prefix)/var/homebrew/locks"
# brew bundle --quiet
# echo "-- install rust toolchain"
# rm -rf /Users/runner/.cargo
# rm -rf /Users/runner/.rustup
# rustup toolchain install "$(cat rust-toolchain)"
# echo "-- add cargo to path"
# rustup_cargo=$(rustup which cargo)
# echo "CARGO_HOME=${HOME}/.cargo" >> "${GITHUB_ENV}"
# echo "RUSTUP_HOME=${HOME}/.rustup" >> "${GITHUB_ENV}"
# echo "${HOME}/.cargo/bin" >> "${GITHUB_PATH}"
# echo "$(dirname "${rustup_cargo}")" >> "${GITHUB_PATH}"
# - name: Build Rust
# uses: ./.github/actions/build-rust
# with:
# network: ${{ matrix.network }}
build-publish-containers:
needs:
- build-rust-linux
strategy:
matrix:
runner:
- mco-dev-small-x64
network:
- chain_id: main
peer: mc://node1.prod.mobilecoinww.com/,mc://node2.prod.mobilecoinww.com/
tx_source_url: https://ledger.mobilecoinww.com/node1.prod.mobilecoinww.com/,https://ledger.mobilecoinww.com/node2.prod.mobilecoinww.com
- chain_id: test
peer: mc://node1.test.mobilecoin.com/,mc://node2.test.mobilecoin.com/
tx_source_url: https://s3-us-west-1.amazonaws.com/mobilecoin.chain/node1.test.mobilecoin.com/,https://s3-us-west-1.amazonaws.com/mobilecoin.chain/node2.test.mobilecoin.com/
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: mobilecoinofficial/gh-actions/checkout@v0
- name: Setup Env
shell: bash
run: |
set -e -o pipefail
# Set vars so we can use them in this step
GH_SHORT_SHA="sha-$(echo "${GITHUB_SHA}" | cut -c1-7)"
ARTIFACT_NAME="full-service-${{ matrix.network.chain_id }}net-${{ runner.os }}-${{ runner.arch }}-${GH_SHORT_SHA}"
echo "GH_SHORT_SHA=${GH_SHORT_SHA}" >> "${GITHUB_ENV}"
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> "${GITHUB_ENV}"
echo "RUST_BIN_PATH=build-artifacts/${ARTIFACT_NAME}" >> "${GITHUB_ENV}"
# CBB: Move this to gh-actions
- name: Restore Artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: build-artifacts
- name: check artifacts
shell: bash
run: |
ls -alR build-artifacts
- name: Docker - build and publish full-service
uses: mobilecoinofficial/gh-actions/docker@v0
with:
dockerfile: .internal-ci/docker/Dockerfile.full-service
images: mobilecoin/full-service
build_args: |
RUST_BIN_PATH=${{ env.RUST_BIN_PATH }}
MC_CHAIN_ID=${{ matrix.network.chain_id }}
MC_PEER=${{ matrix.network.peer }}
MC_TX_SOURCE_URL=${{ matrix.network.tx_source_url }}
flavor: |
latest=false
tags: |
v0-${{ env.GH_SHORT_SHA }}.${{ matrix.network.chain_id }}net
password: ${{ secrets.DOCKERHUB_TOKEN }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
# build-publish-charts:
# needs:
# - build-rust-linux
# strategy:
# matrix:
# network:
# - chain_id: main
# - chain_id: test
# runs-on: mco-dev-small-x64
# env:
# CHART_REPO: https://harbor.mobilecoin.com/chartrepo/mobilecoinofficial-public
# steps:
# - name: Checkout
# uses: mobilecoinofficial/gh-actions/checkout@v0
# - name: Setup Env
# shell: bash
# run: |
# set -e -o pipefail
# echo "GH_SHORT_SHA=sha-$(echo "${GITHUB_SHA}" | cut -c1-7)" >> "${GITHUB_ENV}"
# - name: Publish helm chart full-service
# uses: mobilecoinofficial/gha-k8s-toolbox@v1
# with:
# action: helm-publish
# chart_app_version: v0-${{ env.GH_SHORT_SHA }}.${{ matrix.network.chain_id }}net
# chart_path: .internal-ci/helm/full-service
# chart_repo: ${{ env.CHART_REPO }}
# chart_repo_password: ${{ secrets.HARBOR_PASSWORD }}
# chart_repo_username: ${{ secrets.HARBOR_USERNAME }}
# chart_version: v0-${{ env.GH_SHORT_SHA }}.${{ matrix.network.chain_id }}net
# - name: Publish helm chart full-service-mirror
# uses: mobilecoinofficial/gha-k8s-toolbox@v1
# with:
# action: helm-publish
# chart_app_version: v0-${{ env.GH_SHORT_SHA }}.${{ matrix.network.chain_id }}net
# chart_path: .internal-ci/helm/full-service-mirror
# chart_repo: ${{ env.CHART_REPO }}
# chart_repo_password: ${{ secrets.HARBOR_PASSWORD }}
# chart_repo_username: ${{ secrets.HARBOR_USERNAME }}
# chart_version: v0-${{ env.GH_SHORT_SHA }}.${{ matrix.network.chain_id }}net
# build binaries:
# testnet, mainnet
# linux amd64 arm64
# macos intel, apple
# containers:
# linux arm64, amd64
# test:
# lint
# docker (hadolint)
# shellcheck
# actionlint
# helm lint
# rust/cargo fmt
# rust/cargo clippy
# rust/cargo sort
# unit
# integration - testnet, mainnet