forked from Timi16/soroban-debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
289 lines (234 loc) · 8.89 KB
/
Copy pathci.yml
File metadata and controls
289 lines (234 loc) · 8.89 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
name: CI
on:
push:
branches: [ main, develop, CI/CD ]
tags-ignore: [ 'v*' ]
pull_request:
branches: [ main, develop ]
env:
CARGO_TERM_COLOR: always
# Treat *all* compiler warnings as errors across CI (tests/build/bench), including deprecated API usage.
# This is intentionally stricter than clippy alone; contributors must keep the codebase warning-free.
RUSTFLAGS: "-D warnings"
jobs:
check:
name: Compile Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Docs guard (single canonical contributor guide)
shell: bash
run: |
set -euo pipefail
test -f CONTRIBUTING.md
if [[ -f CONTRIBUTION.md ]]; then
lines="$(wc -l < CONTRIBUTION.md | tr -d ' ')"
if [[ "$lines" -gt 20 ]]; then
echo "CONTRIBUTION.md must remain a short redirect stub (<= 20 lines)."
exit 1
fi
grep -qi "deprecated" CONTRIBUTION.md
grep -q "CONTRIBUTING.md" CONTRIBUTION.md
fi
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Cargo Check
run: cargo check --workspace --all-features
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: check
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Run Tests
run: cargo test --workspace --all-features
vscode-extension:
name: VS Code Extension (E2E)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build soroban-debug (backend)
run: cargo build --bin soroban-debug
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: extensions/vscode/package-lock.json
- name: Install extension dependencies
run: npm --prefix extensions/vscode ci
- name: Run extension tests (includes DAP E2E)
run: npm --prefix extensions/vscode test
lint:
name: Lint (Clippy & Format)
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Check Formatting
run: cargo fmt --all -- --check
- name: Run Clippy (deny warnings)
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
bench:
name: Benchmark Regression Check
runs-on: ubuntu-latest
needs: check
env:
BENCH_WARN_PCT: 10
BENCH_FAIL_PCT: 20
# Criterion sampling knobs (tune if CI is too noisy/slow)
BENCH_SAMPLE_SIZE: 20
BENCH_MEASUREMENT_TIME: 5
BENCH_WARMUP_TIME: 2
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed to benchmark origin/main in a detached worktree
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Restore benchmark baseline (from default branch)
if: github.event_name == 'pull_request'
uses: actions/cache/restore@v4
with:
path: .bench/baseline.json
key: bench-baseline-${{ runner.os }}-${{ github.sha }}
restore-keys: |
bench-baseline-${{ runner.os }}-
- name: Verify benchmark script isolation behavior
shell: bash
run: bash scripts/test_benchmark_regressions.sh
- name: Run benchmark regression check
shell: bash
run: bash scripts/check_benchmark_regressions.sh
- name: Run benchmarks (current)
run: cargo bench --benches -- --noplot --sample-size $BENCH_SAMPLE_SIZE --measurement-time $BENCH_MEASUREMENT_TIME --warm-up-time $BENCH_WARMUP_TIME
- name: Record current results (JSON)
run: cargo run --quiet --bin bench-regression -- record --criterion target/criterion --out .bench/current.json
- name: Compare against baseline (pass/warn/fail)
if: github.event_name == 'pull_request'
shell: bash
run: |
set -e
report="$(cargo run --quiet --bin bench-regression -- compare \
--baseline .bench/baseline.json \
--current .bench/current.json \
--warn-pct "$BENCH_WARN_PCT" \
--fail-pct "$BENCH_FAIL_PCT" \
--annotate-top 20 \
--max-rows 50 \
--require-baseline false)"
echo "$report"
echo "$report" >> "$GITHUB_STEP_SUMMARY"
- name: Update baseline on main
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
mkdir -p .bench
cp .bench/current.json .bench/baseline.json
- name: Save baseline cache (main only)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/cache/save@v4
with:
path: .bench/baseline.json
key: bench-baseline-${{ runner.os }}-${{ github.sha }}
- name: Upload baseline artifact (main only)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: bench-baseline-${{ runner.os }}
path: .bench/baseline.json
check-manpages:
name: Check man page sync
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-manpages-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-manpages-
- name: Check man pages are up to date
run: make check-man
coverage:
name: Code Coverage
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate coverage report
run: cargo llvm-cov --workspace --all-features --lcov --output-path lcov.info
- name: Check coverage threshold
id: coverage
run: |
# Generate summary and extract coverage percentage
summary=$(cargo llvm-cov --workspace --all-features --summary-only 2>&1)
echo "$summary"
# Extract coverage percentage from the summary (look for "TOTAL" line)
# Column 4 is the line coverage % in cargo llvm-cov --summary-only output
coverage=$(echo "$summary" | grep -iE "^\s*TOTAL" | awk '{print $4}' | sed 's/%//' || echo "0")
if [ -z "$coverage" ] || [ "$coverage" = "0" ]; then
echo "Warning: Could not extract coverage percentage, continuing..."
coverage="0"
fi
echo "Current coverage: ${coverage}%"
echo "Required threshold: 50%"
echo "coverage=${coverage}" >> $GITHUB_OUTPUT
# Compare coverage (using awk for floating point comparison)
meets_threshold=$(awk -v cov="$coverage" -v thresh="50" 'BEGIN {print (cov >= thresh)}')
if [ "$meets_threshold" = "0" ]; then
echo "Coverage ${coverage}% is below the required 50% threshold"
exit 1
else
echo "Coverage ${coverage}% meets the required 50% threshold"
fi
- name: Upload to Codecov
uses: codecov/codecov-action@v4
with:
file: ./lcov.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
- name: Comment PR
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
recreate: true
message: |
## Code Coverage Report
**Coverage: ${{ steps.coverage.outputs.coverage }}%** (Required: 50%)
View the full coverage report on [Codecov](https://codecov.io/gh/${{ github.repository }}/commit/${{ github.sha }}).
Coverage details are available in the [CI logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).