-
Notifications
You must be signed in to change notification settings - Fork 13
238 lines (208 loc) · 7.96 KB
/
_rust_tests.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
name: Rust tests
on:
workflow_call:
inputs:
changedCrates:
type: string
required: false
concurrency:
group: rust-tests-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/develop' }}
env:
CARGO_TERM_COLOR: always
RUST_LOG: "error"
# Don't emit giant backtraces in the CI logs.
RUST_BACKTRACE: short
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
# RUSTFLAGS: -D warnings
RUSTDOCFLAGS: -D warnings
jobs:
test:
name: Test rust crates
if: (!cancelled())
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.
IOTA_SKIP_SIMTESTS: 1
runs-on: [self-hosted]
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: taiki-e/install-action@375e0c7f08a66b8c2ba7e7eef31a6f91043a81b0 # v2.44.38
with:
tool: nextest
- name: cargo test
run: |
array=(${{ inputs.changedCrates }})
result=""
for item in "${array[@]}"; do
mapped_item="-E 'rdeps(${item})'"
if [ -z "$result" ]; then
result="$mapped_item"
else
result="$result $mapped_item"
fi
done
command="cargo nextest run --profile ci $result"
echo "$command"
eval ${command}
check-unused-deps:
name: Check Unused Dependencies (${{ matrix.flags }})
if: (!cancelled())
strategy:
matrix:
flags: ["--all-features", "--no-default-features"]
fail-fast: false
runs-on: [self-hosted]
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Run Cargo Udeps
run: cargo +nightly ci-udeps ${{ matrix.flags }}
test-extra:
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.
IOTA_SKIP_SIMTESTS: 1
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- [self-hosted]
fail-fast: false
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: taiki-e/install-action@375e0c7f08a66b8c2ba7e7eef31a6f91043a81b0 # v2.44.38
with:
tool: nextest
- name: benchmark (smoke)
run: |
cargo run --package iota-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 --all-features --workspace --no-deps
- name: Install cargo-hakari, and cache the binary
uses: baptiste0928/cargo-install@904927dbe77864e0f2281519fe9d5bd097a220b3 # v3.1.1
with:
crate: cargo-hakari
locked: true
- name: Install nightly rustfmt
run: rustup toolchain install nightly --component rustfmt --allow-downgrade
- name: iota-execution
run: |
./scripts/execution_layer.py generate-lib
# Ensure there are no uncommitted changes in the repo after running tests
- run: scripts/changed-files.sh
shell: bash
simtest:
name: Simtest rust
timeout-minutes: 45
runs-on: [self-hosted]
env:
MSIM_WATCHDOG_TIMEOUT_MS: 60000
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: taiki-e/install-action@375e0c7f08a66b8c2ba7e7eef31a6f91043a81b0 # v2.44.38
with:
tool: nextest
- name: setup filter
run: |
array=(${{ inputs.changedCrates }})
result=""
for item in "${array[@]}"; do
mapped_item="-E 'rdeps(${item})'"
if [ -z "$result" ]; then
result="$mapped_item"
else
result="$result $mapped_item"
fi
done
echo "filters=$result" >> "$GITHUB_ENV"
- name: cargo simtest
run: |
command="scripts/simtest/cargo-simtest simtest --profile ci $filters"
echo "$command"
eval ${command}
- name: check new tests for flakiness
run: |
command="scripts/simtest/stress-new-tests.sh $filters"
echo "$command"
eval ${command}
rosetta-validation:
timeout-minutes: 45
runs-on: [self-hosted]
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Setup environment
run: .github/scripts/rosetta/setup.sh
shell: bash
- name: Start local IOTA network
run: |
iota 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
graphql-rpc:
name: graphql-rpc
timeout-minutes: 45
runs-on: [self-hosted]
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgrespw
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: postgrespw
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--name postgres_container
ports:
- 5432:5432
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: taiki-e/install-action@375e0c7f08a66b8c2ba7e7eef31a6f91043a81b0 # v2.44.38
with:
tool: nextest
- name: Install postgresql-client
run: sudo apt-get install -y postgresql-client
- name: Setup db
run: |
PGPASSWORD=$POSTGRES_PASSWORD psql -h localhost -U $POSTGRES_USER -c 'CREATE DATABASE iota_indexer;' -c 'ALTER SYSTEM SET max_connections = 500;'
- run: docker restart --time 0 postgres_container
- run: sleep 5
- name: tests-requiring-postgres
run: |
cargo nextest run --no-fail-fast --test-threads 1 --package iota-graphql-rpc --test e2e_tests --test examples_validation_tests --features pg_integration
cargo nextest run --no-fail-fast --test-threads 1 --package iota-graphql-rpc --lib --features pg_integration -- test_query_cost
cargo nextest run --no-fail-fast --test-threads 8 --package iota-graphql-e2e-tests --features pg_integration
cargo nextest run --no-fail-fast --test-threads 1 --package iota-cluster-test --test local_cluster_test --features pg_integration
cargo nextest run --no-fail-fast --test-threads 1 --package iota-indexer --test ingestion_tests --features pg_integration
# Iota-indexer's RPC tests, which depend on a shared runtime, are incompatible with nextest due to its process-per-test execution model.
# cargo test, on the other hand, allows tests to share state and resources by default.
cargo test --profile simulator --package iota-indexer --test rpc-tests --features shared_test_runtime