-
Notifications
You must be signed in to change notification settings - Fork 0
332 lines (278 loc) · 9.85 KB
/
check-pull-request.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
name: "Check Pull Request"
on:
pull_request:
branches:
- develop
paths:
- "**/*.rs"
- "**/Cargo.toml"
- "**/Cargo.lock"
- "rust-toolchain.toml"
- "rustfmt.toml"
- ".github/workflows/*.yml"
push:
branches:
- develop
tags:
- v[0-9]+.[0-9]+.[0-9]
# Matches tags containing an arbitrary suffix starting with '-'.
- v[0-9]+.[0-9]+.[0-9]+-*
# Cancel a currently running workflow from the same PR, branch or tag when a new workflow is
# triggered (ref https://stackoverflow.com/a/72408109)
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
container:
# contains the nightly-toolchain
image: docker.io/paritytech/ci-unified:bullseye-1.75.0-2024-01-22-v20240109
continue-on-error: false
steps:
- uses: actions/checkout@v4
# some settings are only available in nightly.
- run: cargo +nightly fmt --all -- --check
lint:
name: Clippy
runs-on: ubuntu-latest
continue-on-error: false
steps:
- uses: actions/checkout@v4
- name: Install Protoc
uses: arduino/setup-protoc@v3
- name: Fetch cache
uses: Swatinem/rust-cache@v2
with:
# consistent cache across jobs
shared-key: "bajun-cache-cargo-debug"
cache-on-failure: true
- run: cargo clippy --workspace --all-features --all-targets -- -D warnings
env:
SKIP_WASM_BUILD: 1
cargo-zepter:
name: Cargo Zepter
runs-on: ubuntu-latest
steps:
- name: Install stable Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: Install Zepter
run: cargo install --locked -q zepter && zepter --version
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Don't clone historic commits.
- name: Check features
run: zepter run check
build-runtimes:
name: Build Runtimes
runs-on: ubuntu-latest
strategy:
matrix:
runtime: [ "bajun" ]
steps:
- uses: actions/checkout@v4
- name: Cache target dir
uses: actions/cache@v4
with:
save-always: true
path: "${{ github.workspace }}/runtime/${{ matrix.runtime }}/target"
key: srtool-target-${{ matrix.runtime }}-${{ github.sha }}
restore-keys: |
srtool-target-${{ matrix.runtime }}-
srtool-target-
- name: Build ${{ matrix.runtime }}
id: srtool_build
uses: chevdor/srtool-actions@v0.9.2
env:
BUILD_OPTS: "--features on-chain-release-build"
with:
image: paritytech/srtool
chain: ${{ matrix.runtime }}
runtime_dir: runtime/${{ matrix.runtime }}
profile: "production"
- name: Store ${{ matrix.runtime }} srtool digest to disk
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.runtime }}_srtool_output.json
- name: Upload ${{ matrix.runtime }} srtool json
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.runtime }}-srtool-json
path: ${{ matrix.runtime }}_srtool_output.json
- name: Upload ${{ matrix.runtime }}-runtime
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.runtime }}-runtime-${{ github.sha }}
path: |
${{ steps.srtool_build.outputs.wasm_compressed }}
build-binary:
name: Build Release Binary
runs-on: ubuntu-latest
continue-on-error: false
steps:
- uses: actions/checkout@v4
- name: Install Protoc
uses: arduino/setup-protoc@v3
- name: Fetch cache
uses: Swatinem/rust-cache@v2
with:
# consistent cache across jobs
shared-key: "bajun-cache-cargo-release"
cache-on-failure: true
- name: Build release binary
run: cargo build --release --locked
- name: Upload bajun-node
uses: actions/upload-artifact@v4
with:
name: bajun-node-${{ github.sha }}
path: target/release/bajun-node
test:
name: Cargo test (all features)
runs-on: ubuntu-latest
continue-on-error: false
steps:
- uses: actions/checkout@v4
- name: Install Protoc
uses: arduino/setup-protoc@v3
- name: Fetch cache
uses: Swatinem/rust-cache@v2
with:
# consistent cache across jobs
shared-key: "bajun-cache-cargo-test"
cache-on-failure: true
- run: cargo test --release --all-features --all-targets
env:
RUSTFLAGS: "-C debug-assertions -D warnings"
SKIP_WASM_BUILD: 1
zombienet-tests:
name: Zombienet tests
runs-on: ubuntu-latest
needs: [ build-binary ]
strategy:
matrix:
binary: [ bajun-node ]
env:
ZOMBIENET_VERSION: v1.3.82
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create testing directories
run: mkdir -p zombienet-tests/bin
- name: Setup zombienet binaries
run: |
cd zombienet-tests/bin
wget -q "https://github.com/paritytech/zombienet/releases/download/${{ env.ZOMBIENET_VERSION }}/zombienet-linux-x64"
chmod +x zombienet-linux-x64
mv zombienet-linux-x64 zombienet
./zombienet setup polkadot -y || :
./zombienet version
- name: Copy network config and tests
run: cp .maintain/zombienet-* zombienet-tests/
- uses: actions/download-artifact@v4
with:
name: bajun-node-${{ github.sha }}
- name: 'Setup Bajun-Node'
run: |
chmod +x ./bajun-node
cp ./bajun-node zombienet-tests/bin/collator
- name: Run zombienet tests
run: ./zombienet-tests/bin/zombienet -l "text" -p native test ./zombienet-tests/zombienet-tests.zndsl
publish-release:
name: Publish Release
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: [ build-binary ]
outputs:
release_url: ${{ steps.create-release.outputs.html_url }}
asset_upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
- name: Download Bajun Collator
uses: actions/download-artifact@v4
with:
name: bajun-node-${{ github.sha }}
- name: Download srtool json output
uses: actions/download-artifact@v4
- name: Archive context output
uses: actions/upload-artifact@v4
with:
name: release-notes-context
path: |
**/*_srtool_output.json
# Adapted version from fellowship runtimes
- name: Add runtime info to changelog
run: |
CONTEXT=$(find . -name '*_srtool_output.json')
SRTOOL() { <$(<<<$CONTEXT head -n1) jq -r .$1; }
WASM() { <${JSON} jq -r ".runtimes.compressed.subwasm.$1"; }
touch DRAFT
tee -a DRAFT <<-EOF
# Runtime info
*These runtimes were built with **$(SRTOOL rustc)** using **[$(SRTOOL gen)](https://github.com/paritytech/srtool)***
\`\`\`sh
srtool build
--root --profile production
--package CRATE_NAME --runtime-dir PATH_TO_CRATE
\`\`\`
EOF
for JSON in $(<<<$CONTEXT sort -sr)
do
SPEC_NAME=$(WASM 'core_version.specName')
HEADING=$(WASM 'core_version.specName / "-" | map(. / "" | first |= ascii_upcase | add) | join(" ")')
tee -a DRAFT <<-EOF
## $HEADING
~~~
🏋️ Runtime Size: $(numfmt --to iec-i --format "%.2f" $(WASM size)) ($(WASM size) bytes)
🗜 Compressed: $(WASM 'compression | if .compressed then "Yes: \(1 - .size_compressed / .size_decompressed | . * 10000 | round / 100)%" else "No" end')
🔥 Core Version: $(WASM 'core_version | "\(.specName)-\(.specVersion) \(.implName)-\(.implVersion).tx\(.transactionVersion).au\(.authoringVersion)"')
🎁 Metadata version: V$(WASM metadata_version)
🗳️ Blake2-256 hash: $(WASM blake2_256)
📦 IPFS: $(WASM ipfs_hash)
~~~
EOF
done
- name: Release
id: create-release
uses: softprops/action-gh-release@v2
# Generate relase notes with commit history and append srtool output from above.
with:
draft: true
generate_release_notes: true
append_body: true
body_path: DRAFT
files: |
bajun-node
publish-runtimes:
name: Publish Runtimes
needs: [ publish-release ]
continue-on-error: true
runs-on: ubuntu-latest
strategy:
matrix:
runtime: [ bajun ]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Get runtime info
env:
JSON: release-notes-context/${{ matrix.runtime }}-srtool-json/${{ matrix.runtime }}_srtool_output.json
run: |
>>$GITHUB_ENV echo SPEC=$(<${JSON} jq -r .runtimes.compact.subwasm.core_version.specVersion)
- name: Upload compressed ${{ matrix.runtime }} v${{ env.SPEC }} wasm
uses: shogo82148/actions-upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-release.outputs.asset_upload_url }}
asset_path: "${{ matrix.runtime }}-runtime-${{ github.sha }}/${{ matrix.runtime }}_runtime.compact.compressed.wasm"
asset_name: ${{ matrix.runtime }}_runtime-v${{ env.SPEC }}.compact.compressed.wasm
asset_content_type: application/wasm