-
Notifications
You must be signed in to change notification settings - Fork 42
353 lines (353 loc) · 12.4 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
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: |
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: 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 Unit Tests
shell: bash
run: |
RUSTFLAGS="-D warnings" cargo test --lib --bins --benches --examples --all-features
env:
RUST_BACKTRACE: 1
- name: Lint rustdoc
run: ./scripts/lint-rustdoc
vitest-shard-1-of-2:
runs-on: ubuntu-latest-m
steps:
- name: Checkout nns-dapp
uses: actions/checkout@v4
- name: Run vitest shard 1/2
uses: ./.github/actions/vitest
with:
shard_number: 1
shard_count: 2
vitest-shard-2-of-2:
runs-on: ubuntu-latest-m
steps:
- name: Checkout nns-dapp
uses: actions/checkout@v4
- name: Run vitest shard 2/2
uses: ./.github/actions/vitest
with:
shard_number: 2
shard_count: 2
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: scripts/install-didc
- name: Check didc
run: command -v didc
- name: Run the ic_commit code generator for proposals
run: |
./scripts/update_ic_commit --crate proposals --ic_commit "$(jq -re .defaults.build.config.IC_COMMIT_FOR_PROPOSALS dfx.json)"
./scripts/proposals/did2rs
- name: Run the ic_commit code generator for sns_aggregator
run: |
./scripts/update_ic_commit --crate sns_aggregator --ic_commit "$(jq -re .defaults.build.config.IC_COMMIT_FOR_SNS_AGGREGATOR dfx.json)"
./scripts/sns/aggregator/mk_nns_patch.sh
- 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: scripts/install-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
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.on-exit.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: scripts/install-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
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.
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
small-tests:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-13]
runs-on: ${{ matrix.os }}
env:
# Used by download-ci-wasm.test
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v4
- name: Install tools on Linux
run: |
if command -v apt-get; then
# libarchive-zip-perl is needed for crc32, used by convert-id.test
sudo apt-get update -yy && sudo apt-get install -yy moreutils libarchive-zip-perl && command -v sponge
fi
- name: Install tools on Mac
run: |
if command -v brew ; then
# coreutils is needed for
# base32, used by convert-id.test, and
# sha256sum, used download-ci-wasm.test
# moreutils is needed for sponge, used by network-config.test
brew install bash coreutils moreutils
fi
- name: Install dfx
uses: dfinity/setup-dfx@main
- name: Install didc
run: |
scripts/install-didc
# `didc` is installed in $HOME/.local/bin, which is in the path by
# default on Linux but not on Mac.
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Ensure required didc version
run: ./scripts/ensure-required-didc-version.test
- name: docker-build prints help
run: ./scripts/docker-build --help | grep -i usage
- 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"
- name: Test canister_ids tool
run: scripts/canister_ids.test
- name: Test release-sop script
run: scripts/nns-dapp/release-sop.test
- name: Test split-changelog script
run: scripts/nns-dapp/split-changelog.test
- name: Find unused i18n messages
run: scripts/unused-i18n
- name: Test the ID conversion script
run: scripts/convert-id.test
- name: Getting network config works
run: scripts/network-config.test
- name: Get SNS tool
run: |
diff <(scripts/sns/aggregator/get-sns dog) <(echo "Name: DOGMI
Symbol: DOGMI
Aggregator URL: https://3r4gx-wqaaa-aaaaq-aaaia-cai.icp0.io/v1/sns/root/nb7he-piaaa-aaaaq-aadqq-cai/slow.json
Root canister ID: nb7he-piaaa-aaaaq-aadqq-cai
Governance canister ID: ni4my-zaaaa-aaaaq-aadra-cai
Ledger canister ID: np5km-uyaaa-aaaaq-aadrq-cai
Index canister ID: n535v-yiaaa-aaaaq-aadsq-cai
Swap canister ID: n223b-vqaaa-aaaaq-aadsa-cai
Transaction fee: 50
Minimum neuron stake: 100
Proposal fee: 15000")
checks-pass:
needs:
- formatting
- spelling
- cargo-tests
- svelte-lint
- vitest-shard-1-of-2
- vitest-shard-2-of-2
- shell-checks
- ic-commit-consistency
- release-templating-works
- config-check
- minor-version-bump-works
- migration-test-utils-work
- version-match
- small-tests
if: ${{ always() }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/needs_success
with:
needs: '${{ toJson(needs) }}'