-
Notifications
You must be signed in to change notification settings - Fork 2
347 lines (333 loc) · 11.8 KB
/
ci.yml
File metadata and controls
347 lines (333 loc) · 11.8 KB
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
name: CI
on:
push:
branches: [main, master, "worker/**"]
tags: ["v*"]
pull_request:
branches: [main, master]
workflow_dispatch:
inputs:
run_nightly:
description: "Run optional nightly build/tests"
type: boolean
default: false
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: short
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
PLATFORM_TEST_DOCKER_MODE: skip
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build
runs-on: blacksmith-32vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y bash ripgrep
- name: Verify nightly config (stable dry-run)
run: scripts/verify-nightly-config.sh
- uses: Swatinem/rust-cache@v2
with:
shared-key: "platform-ci"
- run: cargo build --release
clippy:
name: Clippy
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y bash ripgrep
- uses: Swatinem/rust-cache@v2
with:
shared-key: "platform-ci"
save-if: false
- run: cargo clippy --all-targets --workspace -- -W clippy::all
test:
name: Test
runs-on: blacksmith-32vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y bash ripgrep
- uses: taiki-e/install-action@v2
with:
tool: cargo-nextest
- uses: Swatinem/rust-cache@v2
with:
shared-key: "platform-ci"
save-if: false
- name: Run tests
run: cargo nextest run --workspace -E 'not (test(/live/) | test(/integration/) | test(/e2e/))'
integration:
name: Integration
runs-on: blacksmith-32vcpu-ubuntu-2404
needs: [build, clippy, test]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y bash ripgrep
- uses: taiki-e/install-action@v2
with:
tool: cargo-nextest
- uses: Swatinem/rust-cache@v2
with:
shared-key: "platform-ci"
save-if: false
- name: Ensure Docker available for integration tests
run: scripts/install-docker.sh
- name: Run integration tests
run: cargo nextest run --workspace -E 'test(/integration/)'
e2e:
name: E2E
runs-on: blacksmith-32vcpu-ubuntu-2404
needs: [build, clippy, test]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y bash ripgrep
- uses: taiki-e/install-action@v2
with:
tool: cargo-nextest
- uses: Swatinem/rust-cache@v2
with:
shared-key: "platform-ci"
save-if: false
- name: Ensure Docker available for e2e tests
run: scripts/install-docker.sh
- name: Run e2e tests
run: cargo nextest run --workspace -E 'test(/e2e/)'
docker-test:
name: Docker Integration (5 Validators + WASM)
runs-on: blacksmith-32vcpu-ubuntu-2404
needs: [build, clippy, test]
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: PlatformNetwork/term-challenge
path: term-challenge
token: ${{ secrets.GITHUB_TOKEN }}
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y bash ripgrep
- uses: Swatinem/rust-cache@v2
with:
shared-key: "platform-ci"
save-if: false
- name: Ensure Docker available
run: scripts/install-docker.sh
- name: Build term-challenge WASM module
run: |
mkdir -p term-challenge/.cargo
printf "[patch.'https://github.com/PlatformNetwork/platform-v2']\nplatform-challenge-sdk-wasm = { path = \"${{ github.workspace }}/crates/challenge-sdk-wasm\" }\n" > term-challenge/.cargo/config.toml
cd term-challenge && cargo build --release --target wasm32-unknown-unknown -p term-challenge-wasm
- name: Run 5-validator Docker integration tests
env:
TERM_CHALLENGE_WASM_PATH: ${{ github.workspace }}/term-challenge/target/wasm32-unknown-unknown/release/term_challenge_wasm.wasm
PLATFORM_TEST_DOCKER_MODE: auto
run: bash tests/docker/test-multi-validator.sh
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: docker-test-artifacts
path: |
artifacts/tests/
/tmp/platform-tests/
retention-days: 7
if-no-files-found: warn
coverage:
name: Coverage
runs-on: blacksmith-32vcpu-ubuntu-2404
if: github.ref == 'refs/heads/main'
concurrency:
group: coverage-deploy
cancel-in-progress: false
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- uses: taiki-e/install-action@v2
with:
tool: cargo-nextest,cargo-llvm-cov
- uses: Swatinem/rust-cache@v2
with:
shared-key: "platform-ci"
save-if: false
- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y bash curl jq
- name: Run tests with coverage
run: |
cargo llvm-cov nextest --workspace --json --output-path coverage.json -E 'not (test(/live/) | test(/integration/) | test(/e2e/))'
cargo llvm-cov report --html --output-dir coverage-html
- name: Upload coverage HTML report
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: coverage-html/
- name: Publish coverage HTML to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./coverage-html
destination_dir: coverage-html
keep_files: true
- name: Generate and deploy coverage badge
run: |
COVERAGE=$(jq '.data[0].totals.lines.percent // 0 | round' coverage.json)
echo "Coverage: $COVERAGE%"
mkdir -p badges
if (( COVERAGE >= 80 )); then COLOR="brightgreen"
elif (( COVERAGE >= 60 )); then COLOR="green"
elif (( COVERAGE >= 40 )); then COLOR="yellow"
else COLOR="red"; fi
curl -s "https://img.shields.io/badge/coverage-${COVERAGE}%25-${COLOR}" > badges/coverage.svg
- name: Deploy coverage badge
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./badges
destination_dir: badges
keep_files: true
docker:
name: Docker
runs-on: blacksmith-32vcpu-ubuntu-2404
needs: [build, clippy, test]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Ensure Docker available
run: scripts/install-docker.sh
- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y bash ripgrep
- uses: useblacksmith/setup-docker-builder@v1
- uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha,prefix=
type=raw,value=latest,enable={{is_default_branch}}
- uses: useblacksmith/build-push-action@v2
with:
context: .
build-args: |
RUSTUP_TOOLCHAIN=stable
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
release:
name: Release
runs-on: blacksmith-32vcpu-ubuntu-2404
needs: [build, clippy, test, docker]
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: "platform-ci"
save-if: false
- run: cargo build --release
- run: |
mkdir -p release
cp target/release/validator-node release/
cp target/release/csudo release/ 2>/dev/null || true
tar -czvf platform-${{ github.ref_name }}-linux-x86_64.tar.gz -C release .
- uses: softprops/action-gh-release@v2
with:
files: platform-${{ github.ref_name }}-linux-x86_64.tar.gz
generate_release_notes: true
nightly:
name: Nightly Build & Test
runs-on: blacksmith-32vcpu-ubuntu-2404
if: github.event_name == 'workflow_dispatch' && github.event.inputs.run_nightly == 'true'
env:
RUSTUP_TOOLCHAIN: nightly
PLATFORM_RUST_NIGHTLY: "1"
PLATFORM_NIGHTLY_RUSTFLAGS: "-Z threads=0"
PLATFORM_FAST_LINKER_RUSTFLAGS: "-C link-arg=-fuse-ld=mold"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Install nightly dependencies
run: sudo apt-get update && sudo apt-get install -y bash ripgrep mold
- uses: taiki-e/install-action@v2
with:
tool: cargo-nextest
- name: Verify nightly config (nightly dry-run)
run: scripts/verify-nightly-config.sh
- uses: Swatinem/rust-cache@v2
with:
shared-key: "platform-ci-nightly"
save-if: false
- name: Nightly build
run: cargo build --release
- name: Nightly tests
run: cargo nextest run --workspace -E 'not (test(/live/) | test(/integration/) | test(/e2e/))'
docker-nightly:
name: Docker Nightly Build
runs-on: blacksmith-32vcpu-ubuntu-2404
if: github.event_name == 'workflow_dispatch' && github.event.inputs.run_nightly == 'true'
needs: [nightly]
env:
RUSTUP_TOOLCHAIN: nightly
PLATFORM_RUST_NIGHTLY: "1"
PLATFORM_NIGHTLY_RUSTFLAGS: "-Z threads=0"
PLATFORM_FAST_LINKER_RUSTFLAGS: "-C link-arg=-fuse-ld=mold"
steps:
- uses: actions/checkout@v4
- name: Ensure Docker available
run: scripts/install-docker.sh
- uses: useblacksmith/setup-docker-builder@v1
- uses: useblacksmith/build-push-action@v2
with:
context: .
push: false
build-args: |
RUSTUP_TOOLCHAIN=nightly
PLATFORM_NIGHTLY_RUSTFLAGS=-Z threads=0
PLATFORM_FAST_LINKER_RUSTFLAGS=-C link-arg=-fuse-ld=mold
- uses: dtolnay/rust-toolchain@nightly
- name: Install nightly dependencies
run: sudo apt-get update && sudo apt-get install -y bash ripgrep mold
- uses: taiki-e/install-action@v2
with:
tool: cargo-nextest
- name: Nightly build
run: cargo build --release
- name: Nightly tests
run: cargo nextest run --workspace -E 'not (test(/live/) | test(/integration/) | test(/e2e/))'