Repository navigation
340 lines (312 loc) · 11.4 KB
/
Copy pathci.yml
File metadata and controls
340 lines (312 loc) · 11.4 KB
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
on: [push, pull_request]
name: Continuous integration
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
key: check-${{ runner.os }}
- run: |
make check
make check-migrate
make check-dirty-rpc-doc
cargo-shear:
name: Cargo Shear
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
key: shear-${{ runner.os }}
- uses: cargo-bins/cargo-binstall@main
- run: |
cargo binstall --no-confirm cargo-shear --force --locked --version 1.1.9
cargo shear
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
key: test-${{ runner.os }}
- uses: taiki-e/install-action@v2
with:
tool: nextest
- name: Run tests
run: |
RUST_BACKTRACE=full RUST_LOG=trace,fnn=trace,fnn::cch::actor::tracker=off,fnn::fiber::gossip=off,tentacle=off,tokio_yamux=off,tentacle_secio=off cargo nextest run --no-fail-fast
env:
RUST_TEST_THREADS: 2
- name: Run tests (sqlite)
run: |
RUST_BACKTRACE=full RUST_LOG=trace,fnn=trace,fnn::cch::actor::tracker=off,fnn::fiber::gossip=off,tentacle=off,tokio_yamux=off,tentacle_secio=off cargo nextest run --no-fail-fast --no-default-features --features sqlite
env:
RUST_TEST_THREADS: 2
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
key: fmt-${{ runner.os }}
- run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
key: clippy-${{ runner.os }}
- run: |
rustup target add wasm32-unknown-unknown
make clippy
typos:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- name: Check for typos
uses: crate-ci/typos@v1.39.0
- name: Typos info
if: failure()
run: |
echo 'To fix typos, please run `cargo install typos && typos -w`'
echo 'To check for a diff, run `typos`'
echo 'You can find typos here: https://crates.io/crates/typos'
echo 'if you use VSCode, you can also install `Typos Spell Checker'
echo 'You can find the extension here: https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode'
coverage:
name: Code Coverage
needs: [test]
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
steps:
- uses: actions/checkout@v6
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
key: coverage-${{ runner.os }}
- name: Install Grcov
run: make coverage-install-tools
- name: Generate Code Coverage Report of Unit Tests
run: |
make coverage-run-unittests
make coverage-collect-data
- name: Upload Code Coverage Report of Unit Tests
uses: codecov/codecov-action@v4
with:
files: coverage-report.info
env_vars: OS,RUST_TOOLCHAIN
fail_ci_if_error: false
flags: unittests
verbose: false
token: ${{ secrets.CODECOV_TOKEN }}
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
profile: [dev, release]
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
key: build-${{ matrix.os }}-${{ matrix.profile }}
- name: Install Dependencies (Windows)
if: contains(matrix.os, 'windows')
run: |
vcpkg integrate install
vcpkg install openssl:x64-windows-static-md
- name: Build with profile
run: cargo build --locked --verbose --profile ${{ matrix.profile }}
benchmark:
name: Benchmark (Non-Gossip)
runs-on: ubuntu-latest
timeout-minutes: 90
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
- name: Setup Dependencies
uses: ./.github/actions/setup-dependencies
with:
ckb-version: '0.202.0'
cache-prefix: 'benchmark'
- name: Cache build artifacts
uses: actions/cache@v5
with:
path: |
./tests/deploy/udt-init/target
./tests/perf/target
key: build-artifacts-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
build-artifacts-${{ runner.os }}-
- name: Build rust code
run: |
cd ./tests/deploy/udt-init && cargo build --locked && cd -
cd ./tests/perf/ && cargo build --release --locked && cd -
- name: Run baseline benchmark
run: |
echo "Comparing against: origin/${{ github.base_ref }}"
git checkout origin/${{ github.base_ref }}
export ON_GITHUB_ACTION=y
CKB_LOG=warn TEST_ENV=release ./tests/nodes/start.sh > baseline.log 2>&1 &
./tests/nodes/wait.sh
cd ./tests/perf/
cargo run --bin run-test --release integration
cargo run --bin run-test --release benchmark 90 30 base
cd -
mkdir -p ./tests/perf/artifacts
if [ -f "./tests/perf/baseline.json" ] && [ ! -f "./tests/perf/artifacts/baseline.json" ]; then
mv ./tests/perf/baseline.json ./tests/perf/artifacts/baseline.json
fi
git stash
- name: Run current benchmark
run: |
echo "Running benchmark on current PR commit: ${{ github.sha }}"
git checkout ${{ github.sha }}
pkill -f 'fnn|ckb run|npm' || true
rm -rf ./tests/nodes/.ports
export ON_GITHUB_ACTION=y
REMOVE_OLD_STATE=y CKB_LOG=warn TEST_ENV=release ./tests/nodes/start.sh > current.log 2>&1 &
./tests/nodes/wait.sh
cd ./tests/perf/
cargo run --bin run-test --release integration
cargo run --bin run-test --release benchmark 90 30 compare
cd -
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: |
./baseline.log
./current.log
./tests/perf/artifacts/comparison_report.txt
./tests/perf/artifacts/baseline.json
./tests/perf/artifacts/current.json
- name: Check benchmark result
run: |
echo "Check benchmark result on current PR commit: ${{ github.sha }}"
if [ -f "./tests/perf/artifacts/comparison_report.txt" ]; then
if grep -q "Performance regression detected" "./tests/perf/artifacts/comparison_report.txt"; then
echo "❌ Performance regression detected! Failing the workflow."
exit 1
else
echo "✅ No performance regression detected."
fi
else
echo "⚠️ Comparison report not found at ./tests/perf/artifacts/comparison_report.txt"
echo "This might indicate a benchmark execution failure."
exit 1
fi
payment-benchmark:
name: Payment Benchmark
runs-on: ubuntu-latest
timeout-minutes: 60
if: false # temporarily disabled
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
key: payment-bench-${{ runner.os }}
- name: Install jq
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: Run payment benchmarks baseline
run: |
echo "Running payment benchmarks baseline: origin/${{ github.base_ref }}"
git checkout origin/${{ github.base_ref }}
cargo bench -p fnn --features bench --bench payment_benchmarks -- find_path_200n_2000c --save-baseline base
rm -rf /tmp/criterion-baseline
mkdir -p /tmp/criterion-baseline
cp -R target/criterion /tmp/criterion-baseline
- name: Run payment benchmarks current
run: |
echo "Running payment benchmarks on current PR commit: ${{ github.sha }}"
git checkout ${{ github.sha }}
cargo bench -p fnn --features bench --bench payment_benchmarks
rm -rf /tmp/criterion-current
mkdir -p /tmp/criterion-current
cp -R target/criterion /tmp/criterion-current
- name: Check payment benchmark regression
run: |
set -euo pipefail
base_dir=/tmp/criterion-baseline
cur_dir=/tmp/criterion-current
max_reg=0
worst_case=""
while IFS= read -r base; do
rel=${base#"$base_dir"/}
cur=${rel%/base/estimates.json}/new/estimates.json
cur="$cur_dir/$cur"
if [[ ! -f "$cur" ]]; then
echo "Missing current estimate for $rel"
exit 1
fi
base_mean=$(jq -r '.mean.point_estimate' "$base")
cur_mean=$(jq -r '.mean.point_estimate' "$cur")
if [[ "$base_mean" == "0" ]]; then
continue
fi
reg=$(awk -v b="$base_mean" -v c="$cur_mean" 'BEGIN { printf "%.6f", ((c-b)/b)*100 }')
dir="flat"
if awk -v r="$reg" 'BEGIN { exit !(r > 0.5) }'; then
dir="down"
elif awk -v r="$reg" 'BEGIN { exit !(r < -0.5) }'; then
dir="up"
fi
if [[ "$dir" == "down" ]]; then
emoji="🔻"
elif [[ "$dir" == "up" ]]; then
emoji="👍"
else
emoji="🟰"
fi
echo "$emoji Result: $rel baseline=$base_mean current=$cur_mean change=${reg}% ($dir)"
if awk -v r="$reg" 'BEGIN { exit !(r > 5.0) }'; then
echo "🚨 Regression > 5%: $rel (baseline=$base_mean current=$cur_mean, ${reg}% )"
if awk -v r="$reg" -v m="$max_reg" 'BEGIN { exit !(r > m) }'; then
max_reg=$reg
worst_case=$rel
fi
fi
done < <(find "$base_dir" -path "*/base/estimates.json" -type f | sort)
if awk -v m="$max_reg" 'BEGIN { exit !(m > 5.0) }'; then
echo "❌ Payment benchmark regression detected: $worst_case (${max_reg}%)"
exit 1
fi
echo "✅ Payment benchmark regression within 5% threshold"
- name: Upload payment benchmark results
uses: actions/upload-artifact@v4
with:
name: payment-benchmark-results
path: |
/tmp/criterion-baseline
/tmp/criterion-current