-
Notifications
You must be signed in to change notification settings - Fork 11.2k
418 lines (390 loc) · 14.9 KB
/
rust.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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
name: Rust
on:
push:
branches:
- 'main'
- 'devnet'
- 'testnet'
- 'mainnet'
- 'releases/sui-*-release'
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
workflow_dispatch:
inputs:
sui_repo_ref:
description: "Branch / commit to test"
type: string
required: false
default: ''
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
CARGO_TERM_COLOR: always
# Disable incremental compilation.
#
# Incremental compilation is useful as part of an edit-build-test-edit cycle,
# as it lets the compiler avoid recompiling code that hasn't changed. However,
# on CI, we're not making small edits; we're almost always building the entire
# project from scratch. Thus, incremental compilation on CI actually
# introduces *additional* overhead to support making future builds
# faster...but no future builds will ever occur in any given CI environment.
#
# See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
# for details.
CARGO_INCREMENTAL: 0
# Allow more retries for network requests in cargo (downloading crates) and
# rustup (installing toolchains). This should help to reduce flaky CI failures
# from transient network timeouts or other issues.
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
# Don't emit giant backtraces in the CI logs.
RUST_BACKTRACE: short
# RUSTFLAGS: -D warnings
RUSTDOCFLAGS: -D warnings
jobs:
diff:
runs-on: [ ubuntu-latest ]
outputs:
isRust: ${{ steps.diff.outputs.isRust }}
isMove: ${{ steps.diff.outputs.isMove }}
isMoveAutoFormatter: ${{ steps.diff.outputs.isMoveAutoFormatter }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
with:
ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
- name: Detect Changes
uses: './.github/actions/diffs'
id: diff
license-check:
name: license-check
runs-on: [ ubuntu-latest ]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
with:
ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
- uses: bmwill/rust-cache@v1 # Fork of 'Swatinem/rust-cache' which allows caching additional paths
- name: Install cargo-hakari, and cache the binary
uses: baptiste0928/cargo-install@1cd874a5478fdca35d868ccc74640c5aabbb8f1b # [email protected]
with:
crate: cargo-hakari
locked: true
- run: cargo xlint
move-auto-formatter-ci-test:
needs: diff
if: needs.diff.outputs.isMoveAutoFormatter == 'true'
runs-on: [ ubuntu-latest ]
strategy:
matrix:
node-version: [ 20 ]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
with:
ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # [email protected]
with:
version: 9.1.1
- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # [email protected]
with:
node-version: '20.x'
cache: 'pnpm'
- name: Install dependencies
working-directory: ./external-crates/move/crates/move-analyzer/prettier-plugin
run: npm install && npm i web-tree-sitter
- name: Run npm test
working-directory: ./external-crates/move/crates/move-analyzer/prettier-plugin
shell: bash
run: npm run test
test:
needs: diff
if: needs.diff.outputs.isRust == 'true'
timeout-minutes: 45
env:
# Tests written with #[sim_test] are often flaky if run as #[tokio::test] - this var
# causes #[sim_test] to only run under the deterministic `simtest` job, and not the
# non-deterministic `test` job.
SUI_SKIP_SIMTESTS: 1
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- [ ubuntu-ghcloud ]
fail-fast: false
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
with:
ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
- uses: taiki-e/install-action@nextest
- name: Add postgres to PATH
run: echo "/usr/lib/postgresql/14/bin" >> $GITHUB_PATH
- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 256
- name: cargo test
run: |
cargo nextest run --profile ci -E '!package(sui-bridge)'
- name: cargo test (sui-graphql staging)
run: |
cargo nextest run --profile ci --features staging -E 'package(sui-graphql-rpc)' -E 'package(sui-graphql-e2e-tests)'
# Ensure there are no uncommitted changes in the repo after running tests
- run: scripts/changed-files.sh
shell: bash
test-extra:
needs: diff
if: needs.diff.outputs.isRust == 'true'
timeout-minutes: 45
env:
# Tests written with #[sim_test] are often flaky if run as #[tokio::test] - this var
# causes #[sim_test] to only run under the deterministic `simtest` job, and not the
# non-deterministic `test` job.
SUI_SKIP_SIMTESTS: 1
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- [ ubuntu-ghcloud ]
fail-fast: false
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
with:
ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
- uses: taiki-e/install-action@nextest
- name: Add postgres to PATH
run: echo "/usr/lib/postgresql/14/bin" >> $GITHUB_PATH
- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 256
- name: benchmark (smoke)
run: |
cargo run --package sui-benchmark --bin stress -- --log-path /tmp/stress.log --num-client-threads 10 --num-server-threads 24 --num-transfer-accounts 2 bench --target-qps 100 --num-workers 10 --transfer-object 50 --shared-counter 50 --run-duration 10s --stress-stat-collection
- name: doctests
run: |
cargo test --doc
- name: rustdoc
run: |
cargo doc --workspace --no-deps
- name: Install cargo-hakari, and cache the binary
uses: baptiste0928/cargo-install@1cd874a5478fdca35d868ccc74640c5aabbb8f1b # [email protected]
with:
crate: cargo-hakari
locked: true
- name: Install rustfmt
run: rustup component add rustfmt
- name: sui-execution
run: |
./scripts/execution_layer.py generate-lib
- name: Install diesel CLI, and cache the binary
uses: baptiste0928/cargo-install@1cd874a5478fdca35d868ccc74640c5aabbb8f1b # [email protected]
with:
crate: diesel_cli
locked: true
- name: Indexer schema
run: |
./scripts/generate_indexer_schema.sh
# Ensure there are no uncommitted changes in the repo after running tests
- run: scripts/changed-files.sh
shell: bash
windows-build:
needs: diff
if: needs.diff.outputs.isRust == 'true'
timeout-minutes: 45
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- [ windows-ghcloud ]
fail-fast: false
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
with:
ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
- uses: taiki-e/install-action@nextest
- name: Install postgres (Windows)
shell: bash
run: |
choco install postgresql12 --force --params '/Password:root'
echo "C:\Program Files\PostgreSQL\12\bin" >> $GITHUB_PATH
echo "C:\Program Files\PostgreSQL\12\lib" >> $GITHUB_PATH
echo "PQ_LIB_DIR=C:\Program Files\PostgreSQL\12\lib" >> $GITHUB_ENV
echo "PG_DATABASE_URL=postgres://postgres:root@localhost/" >> $GITHUB_ENV
echo "PG_EXAMPLE_DATABASE_URL=postgres://postgres:root@localhost/diesel_example" >> $GITHUB_ENV
- name: cargo build
shell: bash
run: |
cargo build --all-features
simtest:
needs: diff
if: needs.diff.outputs.isRust == 'true' || needs.diff.outputs.isSolidity == 'true'
timeout-minutes: 45
runs-on: [ ubuntu-ghcloud ]
env:
MSIM_WATCHDOG_TIMEOUT_MS: 60000
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
with:
ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
- uses: taiki-e/install-action@nextest
- name: Add postgres to PATH
run: echo "/usr/lib/postgresql/14/bin" >> $GITHUB_PATH
- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 256
- name: cargo simtest
run: |
MSIM_TEST_SEED="$(printf "%lu\n" 0x$(git rev-parse HEAD | cut -c1-16))" scripts/simtest/cargo-simtest simtest --no-fail-fast
- name: check new tests for flakiness
run: |
scripts/simtest/stress-new-tests.sh
# This job ensures that Move unit tests are run if there are changes
# to Move code but not Rust code (If there are Rust changes, they
# will be run as part of a larger test suite).
move-test:
needs: diff
if: needs.diff.outputs.isRust == 'false' && needs.diff.outputs.isMove == 'true'
timeout-minutes: 10
runs-on: [ ubuntu-ghcloud ]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
with:
ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
- uses: taiki-e/install-action@nextest
- name: Run move tests
run: |
cargo nextest run -p sui-framework-tests --test move_tests
# # Disabled
# rosetta-validation:
# needs: diff
# if: needs.diff.outputs.isRust == 'true'
# timeout-minutes: 45
# runs-on: [ubuntu-ghcloud]
# steps:
# - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
# with:
# ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
# - name: Setup environment
# run: .github/scripts/rosetta/setup.sh
# shell: bash
# - name: Start local Sui network
# run: |
# sui start --no-full-node &
# shell: bash
# - name: Start Rosetta servers
# run: .github/scripts/rosetta/start_rosetta.sh
# shell: bash
# - name: Sleep for 20 seconds
# run: sleep 20s
# shell: bash
# - name: Run check:construction test
# run: |
# ./bin/rosetta-cli --configuration-file rosetta_cli.json check:construction
# shell: bash
# - name: Run check:data test
# run: |
# ./bin/rosetta-cli --configuration-file rosetta_cli.json check:data
# shell: bash
# This is a no-op job that allows the resulting action names to line up when
# there are no rust changes in a given PR/commit. This ensures that we can
# continue to block on the rust tests passing in the case of rust changes and
# otherwise not block pushes to main.
# Note that this no-op job is only when there is a strategy matrix.
# Other required jobs without strategy matrix do not need a no-op counterpart.
test-notrust:
name: test
needs: diff
if: needs.diff.outputs.isRust == 'false'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- [ ubuntu-ghcloud ]
- [ windows-ghcloud ]
fail-fast: false
steps:
- run: 'echo "No build required" '
# This is a no-op job that allows the resulting action names to line up when
# there are no rust changes in a given PR/commit. This ensures that we can
# continue to block on the rust tests passing in the case of rust changes and
# otherwise not block pushes to main.
# Note that this no-op job is needed when there is a strategy matrix.
# Other required jobs without strategy matrix do not need a no-op counterpart.
test-extra-notrust:
name: test-extra
needs: diff
if: needs.diff.outputs.isRust == 'false'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- [ ubuntu-ghcloud ]
- [ windows-ghcloud ]
fail-fast: false
steps:
- run: 'echo "No build required" '
clippy:
needs: diff
if: needs.diff.outputs.isRust == 'true'
runs-on: [ ubuntu-ghcloud ]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
with:
ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
- run: rustup component add clippy
# TODO(bradh): debug and re-enable this; the caching is breaking the clippy build
# Enable caching of the 'librocksdb-sys' crate by additionally caching the
# 'librocksdb-sys' src directory which is managed by cargo
# - uses: bmwill/rust-cache@v1 # Fork of 'Swatinem/rust-cache' which allows caching additional paths
# with:
# path: ~/.cargo/registry/src/**/librocksdb-sys-*
# See '.cargo/config' for list of enabled/disappled clippy lints
- name: cargo clippy
run: cargo xclippy -D warnings
rustfmt:
needs: diff
if: needs.diff.outputs.isRust == 'true'
runs-on: [ ubuntu-latest ]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
with:
ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
- run: rustup component add rustfmt
- name: rustfmt
uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # [email protected]
with:
command: fmt
args: --check
cargo-deny:
name: cargo-deny (advisories, licenses, bans, ...)
needs: diff
if: needs.diff.outputs.isRust == 'true'
runs-on: [ ubuntu-latest ]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
with:
ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
- uses: taiki-e/install-action@cargo-deny
- run: cargo deny check
sui-excution-cut:
name: cutting a new execution layer
needs: diff
if: needs.diff.outputs.isRust == 'true'
runs-on: [ ubuntu-ghcloud ]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
with:
ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
- name: Install cargo-hakari, and cache the binary
uses: baptiste0928/cargo-install@1cd874a5478fdca35d868ccc74640c5aabbb8f1b # [email protected]
with:
crate: cargo-hakari
locked: true
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
with:
ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
- name: Make cut
run: ./scripts/execution_layer.py cut for_ci_test
- name: Check execution builds
run: cargo build -p sui-execution