-
Notifications
You must be signed in to change notification settings - Fork 39
402 lines (402 loc) · 13.3 KB
/
checks.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
name: Unit Tests
on:
push:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -euxlo pipefail {0}
jobs:
formatting:
runs-on: ubuntu-20.04
env:
DFX_NETWORK: mainnet
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get cargo sort version
run: jq -r '"CARGO_SORT_VERSION=\(.defaults.build.config.CARGO_SORT_VERSION)"' dfx.json >> $GITHUB_ENV
- name: Get node version
run: jq -r '"NODE_VERSION=\(.defaults.build.config.NODE_VERSION)"' dfx.json >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install shfmt
run: sudo snap install --classic shfmt
- name: Install yq
run: sudo snap install yq
- name: Install cargo dependency sorter
run: cargo install cargo-sort@${{ env.CARGO_SORT_VERSION }}
- name: Format
run: ./scripts/fmt
- name: Check formatted
run: |
test -z "$(git status --porcelain)" || {
echo "FIX: Please run ./scripts/fmt"
git diff
exit 1
}
spelling:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install spellcheck
run: |
cd /
sudo apt-get update
sudo apt-get install -yy hunspell hunspell-en-gb hunspell-en-us clang libclang-dev
cargo install --locked --target x86_64-unknown-linux-gnu [email protected]
- name: Spellcheck Rust
run: cargo spellcheck --code 1
- name: Spellcheck changelog
run: scripts/spellcheck-changelog
cargo-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-1
- name: Lint rust code
run: ./scripts/lint-rs
- name: Run Tests
shell: bash
run: |
cargo test --all-targets --all-features
env:
RUST_BACKTRACE: 1
- name: Lint rustdoc
run: ./scripts/lint-rustdoc
svelte-tests:
runs-on: ubuntu-latest-m
defaults:
run:
shell: bash
env:
DFX_NETWORK: mainnet
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get node version
run: jq -r '"NODE_VERSION=\(.defaults.build.config.NODE_VERSION)"' dfx.json >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci
working-directory: ./frontend
- name: Test
run: npm run test
working-directory: ./frontend
svelte-lint:
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
env:
DFX_NETWORK: mainnet
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get node version
run: jq -r '"NODE_VERSION=\(.defaults.build.config.NODE_VERSION)"' dfx.json >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci
working-directory: ./frontend
- name: Run linter
run: npm run check
working-directory: ./frontend
shell-checks:
name: ShellCheck
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Run ShellCheck
run: |
sudo apt-get update
sudo apt-get install -yy shellcheck
./scripts/lint-sh
ic-commit-consistency:
name: IC Commit
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install didc
run: |
USER_BIN="$HOME/.local/bin"
mkdir -p "$USER_BIN"
echo "$USER_BIN" >> $GITHUB_PATH
version="$(jq -r .defaults.build.config.DIDC_VERSION dfx.json)"
# TODO: Make `didc` support `binstall`, then use `binstall` here.
curl -Lf "https://github.com/dfinity/candid/releases/download/${version}/didc-linux64" | install -m 755 /dev/stdin "$USER_BIN/didc"
- name: Check didc
run: command -v didc
- name: Run the ic_commit code generator
run: ./scripts/update_ic_commit --ic_commit "$(jq -re .defaults.build.config.IC_COMMIT dfx.json)"
- name: Verify that there are no code changes
run: |
if git diff | grep . ; then
echo "ERROR: The code is not consistent with the IC_COMMIT in dfx.json"
echo "Note: didc version: $(didc --version)"
exit 1
fi
release-templating-works:
name: Release template
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install didc
run: |
USER_BIN="$HOME/.local/bin"
mkdir -p "$USER_BIN"
echo "$USER_BIN" >> $GITHUB_PATH
version="$(jq -r .defaults.build.config.DIDC_VERSION dfx.json)"
# TODO: Use `binstall`, once `didc` supports it.
curl -Lf "https://github.com/dfinity/candid/releases/download/${version}/didc-linux64" | install -m 755 /dev/stdin "$USER_BIN/didc"
- name: Check didc
run: command -v didc
- name: Install dfx
uses: dfinity/setup-dfx@main
- name: Verify template creation
run: |
echo Create a fake wasm
mkdir -p release/ci
touch release/ci/nns-dapp.wasm.gz
echo Create a proposal template
scripts/nns-dapp/release-template
echo Check the proposal
./scripts/nns-dapp/release-check
config-check:
name: Config is as expected
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install dfx
uses: dfinity/setup-dfx@main
- name: Install cargo binstall
uses: ./.github/actions/install_binstall
- name: Install tools
run: |
cargo binstall --no-confirm "idl2json_cli@$(jq -r .defaults.build.config.IDL2JSON_VERSION dfx.json)"
- name: Check mainnet config
run: bash -x config.test
asset-chunking-works:
name: Asset chunking works
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Test chunking
run: scripts/nns-dapp/split-assets.test
migration-test-utils-work:
name: Migration test utilities work
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install cargo binstall
uses: ./.github/actions/install_binstall
- name: Install idl2json
run: cargo binstall --no-confirm "idl2json_cli@$(jq -r .defaults.build.config.IDL2JSON_VERSION dfx.json)" && idl2json --version
- name: Test migration utilities
run: |
set +x
scripts/nns-dapp/migration-test.getters.test
scripts/nns-dapp/migration-test.on-exit.test
scripts/nns-dapp/migration-test.canister.test
dfx-nns-proposal-args-works:
# TODO: Re-enable (add it in line 338) once fixed, should it depend on mainnet?
if: false
name: Can get NNS proposal args
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install didc
run: |
USER_BIN="$HOME/.local/bin"
mkdir -p "$USER_BIN"
echo "$USER_BIN" >> $GITHUB_PATH
version="$(jq -r .defaults.build.config.DIDC_VERSION dfx.json)"
# TODO: Make `didc` support `binstall`, then use `binstall` here.
curl -Lf "https://github.com/dfinity/candid/releases/download/${version}/didc-linux64" | install -m 755 /dev/stdin "$USER_BIN/didc"
- name: Install cargo binstall
uses: ./.github/actions/install_binstall
- name: Install idl2json
run: cargo binstall --no-confirm "idl2json_cli@$(jq -r .defaults.build.config.IDL2JSON_VERSION dfx.json)" && idl2json --version
- name: Install sponge
run: sudo apt-get update -yy && sudo apt-get install -yy moreutils && command -v sponge
- name: Install dfx
uses: dfinity/setup-dfx@main
- name: Test getting proposal args
run: scripts/dfx-nns-proposal-args.test
docker-build-cli-flags:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: docker-build prints help
run: ./scripts/docker-build --help | grep -i usage
minor-version-bump-works:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install yq
run: sudo snap install yq
- name: Install sponge
run: sudo apt-get update -yy && sudo apt-get install -yy moreutils && command -v sponge
- name: Get node version
run: jq -r '"NODE_VERSION=\(.defaults.build.config.NODE_VERSION)"' dfx.json >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Bumping the package versions works
run: ./scripts/nns-dapp/bump-patch.test
- name: Set git user
run: |
git config --global user.email "[email protected]"
git config --global user.name "GIX bot"
- name: Command creates commits
run: |
original_commit="$(git rev-parse HEAD)"
git checkout .
./scripts/nns-dapp/bump-patch --commit
num_commits="$(git log --oneline "$original_commit..HEAD" | wc -l)"
(( num_commits == 2 )) || {
echo "Expected two commits. Got:"
git log --oneline "$original_commit..HEAD"
exit 1
} >&2
# TODO: Verify that the commits contain the expected changes.
download-nns-dapp-ci-wasm:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-13]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install bash and sha256sum if on Mac
run: |
if command -v brew ; then
brew install bash
brew install coreutils
fi
- name: Download NNS-dapp CI wasm
run: |
MAIN_COMMIT="$(git ls-remote --refs https://github.com/dfinity/nns-dapp.git main | awk '{print $1}')"
scripts/nns-dapp/download-ci-wasm.test --commit "$MAIN_COMMIT"
env:
GH_TOKEN: ${{ github.token }}
canister-ids-tool:
name: Test canister_ids tool
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-13]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install bash if on Mac
run: |
if command -v brew ; then
brew install bash
fi
- run: scripts/canister_ids.test
release-sop:
name: Test release-sop script
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-13]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install bash if on Mac
run: |
if command -v brew ; then
brew install bash
fi
- run: scripts/nns-dapp/release-sop.test
split-changelog:
name: Test split-changelog script
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-13]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install bash if on Mac
run: |
if command -v brew ; then
brew install bash
fi
- run: scripts/nns-dapp/split-changelog.test
unused-i18n:
name: Find unused i18n messages
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- run: scripts/unused-i18n
version-match:
name: The nns-dapp npm and cargo versions should match
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Backend and frontend have the same version
run: |
backend_version="$(cargo metadata | jq -r '.packages[] | select(.name == "nns-dapp").version')"
frontend_version="$(jq -r .version frontend/package.json)"
[[ "${backend_version}" == "${frontend_version}" ]] || {
echo "ERROR: The nns-dapp frontend and backend should have the same version but:"
echo "Backend: $backend_version"
echo "Frontend: $frontend_version"
exit 1
} >&2
network-config:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install sponge
run: sudo apt-get update -yy && sudo apt-get install -yy moreutils && command -v sponge
- name: Getting network config works
run: scripts/network-config.test
checks-pass:
needs:
- formatting
- spelling
- cargo-tests
- svelte-lint
- svelte-tests
- shell-checks
- ic-commit-consistency
- release-templating-works
- config-check
- asset-chunking-works
- docker-build-cli-flags
- download-nns-dapp-ci-wasm
- canister-ids-tool
- release-sop
- split-changelog
- minor-version-bump-works
- version-match
- network-config
- migration-test-utils-work
if: ${{ always() }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/needs_success
with:
needs: '${{ toJson(needs) }}'