-
Notifications
You must be signed in to change notification settings - Fork 0
495 lines (421 loc) · 16.5 KB
/
ci.yml
File metadata and controls
495 lines (421 loc) · 16.5 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
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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
name: CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
schedule:
# Run daily at 1 AM UTC
- cron: '0 1 * * *'
permissions:
contents: write # Required for gh-pages deployment
issues: write
pull-requests: write
pages: write
id-token: write
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
test:
name: Test Suite
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-latest, macos-latest, windows-latest]
rust: [stable, beta]
include:
# Test on nightly but allow failures
- os: ubuntu-latest
rust: nightly
allow-failure: true
# Use ubuntu-latest for Linux stable builds
- os: ubuntu-latest
rust: stable
allow-failure: false
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.allow-failure || false }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-${{ matrix.rust }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.rust }}-cargo-
${{ runner.os }}-stable-cargo-
${{ runner.os }}-cargo-
- name: Cache Bun dependencies
uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb', '**/package.json') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install Bun for frontend tests
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install frontend dependencies
run: bun install
- name: Install Pagefind CLI
run: npm install -g pagefind
- name: Check formatting
if: matrix.rust == 'stable'
run: cargo fmt --all -- --check
- name: Run Clippy
if: matrix.rust == 'stable'
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run unit tests
run: cargo test --lib --bins
- name: Run integration tests
run: cargo test --test integration --features "tokio,search,syntax-highlighting"
- name: Run end-to-end tests
run: cargo test --test e2e
env:
RUST_LOG: debug
- name: Run frontend tests
run: bun test
- name: Install benchmark dependencies
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y bc jq
- name: Run performance benchmarks
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest'
run: |
chmod +x ./scripts/bench.sh
./scripts/bench.sh --quick
timeout-minutes: 10
continue-on-error: false # Fail CI if significant regressions detected
- name: Test documentation build
if: matrix.rust == 'stable'
run: cargo doc --no-deps --document-private-items
- name: Check example builds
run: |
mkdir -p example_input
echo "# Example\nThis is an example page." > example_input/index.md
cargo run -- -i example_input -o example_output
wasm:
name: WebAssembly Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-wasm-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-wasm-cargo-
${{ runner.os }}-stable-cargo-
${{ runner.os }}-cargo-
- name: Build for WebAssembly
run: cargo build --target wasm32-unknown-unknown --lib --features wasm-core --no-default-features
- name: Run WASM tests
run: |
# WASM compilation already verified by build step above
# Skip running tests since criterion dev dependency doesn't work on WASM
echo "✅ WASM compilation verified by build step"
continue-on-error: true # WASM tests might not work in CI environment
feature-tests:
name: Feature Combination Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
features:
- "default"
- "server,watcher,search,syntax-highlighting"
- "wasm-core"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Set cache key
id: cache-key
run: |
if [ "${{ matrix.features }}" = "" ]; then
echo "key=${{ runner.os }}-feature-none-cargo-${{ hashFiles('**/Cargo.lock') }}" >> $GITHUB_OUTPUT
else
# Replace commas with dashes for cache key
sanitized=$(echo "${{ matrix.features }}" | sed 's/,/-/g')
echo "key=${{ runner.os }}-feature-$sanitized-cargo-${{ hashFiles('**/Cargo.lock') }}" >> $GITHUB_OUTPUT
fi
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ steps.cache-key.outputs.key }}
restore-keys: |
${{ runner.os }}-feature-cargo-
${{ runner.os }}-stable-cargo-
- name: Run tests with features
run: |
if [ "${{ matrix.features }}" = "default" ]; then
cargo test
else
cargo test --no-default-features --features "${{ matrix.features }}"
fi
msrv:
name: Minimum Supported Rust Version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install MSRV Rust toolchain
uses: dtolnay/rust-toolchain@1.70.0 # Adjust based on actual MSRV
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-msrv-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-msrv-cargo-
${{ runner.os }}-stable-cargo-
${{ runner.os }}-cargo-
- name: Check MSRV compilation
run: cargo check --lib
- name: Run MSRV tests
run: cargo test --lib
security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo dependencies and tools
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-audit-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-audit-cargo-
${{ runner.os }}-stable-cargo-
${{ runner.os }}-cargo-
- name: Install cargo-audit
run: |
# Check if cargo-audit is already installed
if ! command -v cargo-audit &> /dev/null; then
cargo install --locked cargo-audit
else
echo "cargo-audit is already installed: $(cargo-audit --version)"
fi
- name: Run security audit
run: cargo audit
coverage:
name: Code Coverage
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Cache Cargo dependencies and tools
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-coverage-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-coverage-cargo-
${{ runner.os }}-stable-cargo-
${{ runner.os }}-cargo-
- name: Install cargo-tarpaulin
run: |
# Check if cargo-tarpaulin is already installed
if ! command -v cargo-tarpaulin &> /dev/null; then
cargo install --locked cargo-tarpaulin
else
echo "cargo-tarpaulin is already installed: $(cargo-tarpaulin --version)"
fi
- name: Generate coverage report
run: |
cargo tarpaulin --out Xml --skip-clean
continue-on-error: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: cobertura.xml
fail_ci_if_error: false
performance:
name: Performance Regression
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-bench-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-bench-cargo-
${{ runner.os }}-stable-cargo-
${{ runner.os }}-cargo-
- name: Install benchmark dependencies
run: sudo apt-get update && sudo apt-get install -y bc jq
- name: Cache benchmark results
uses: actions/cache@v4
with:
path: benchmark-results/
key: ${{ runner.os }}-benchmarks-${{ github.base_ref || github.ref_name }}
restore-keys: |
${{ runner.os }}-benchmarks-main
${{ runner.os }}-benchmarks-
- name: Run performance benchmarks
run: |
chmod +x ./scripts/bench.sh
./scripts/bench.sh --quick
timeout-minutes: 10
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results-${{ github.sha }}
path: benchmark-results/
retention-days: 30
- name: Comment benchmark results on PR
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = 'benchmark-results/current.json';
try {
let body;
if (fs.existsSync(path)) {
const results = fs.readFileSync(path, 'utf8');
const truncatedResults = results.slice(0, 2000);
const wasTruncated = results.length > 2000;
// Parse JSON results and create a nice table
let parsed;
try {
parsed = JSON.parse(results);
} catch (e) {
parsed = null;
}
if (parsed && parsed.benchmarks && parsed.benchmarks.length > 0) {
let tableRows = '';
parsed.benchmarks.forEach(bench => {
if (bench.benchmark_name && bench.mean && bench.mean.estimate) {
const timeMs = (bench.mean.estimate / 1000000).toFixed(3);
tableRows += `| ${bench.benchmark_name} | ${timeMs} ms |\n`;
}
});
if (tableRows) {
body = `## 📊 Performance Benchmark Results\n\n| Benchmark | Time |\n|-----------|------|\n${tableRows}\n\n<details>\n<summary>Raw Results ${wasTruncated ? '(truncated)' : ''}</summary>\n\n\`\`\`json\n${truncatedResults}${wasTruncated ? '\n...\n[Results truncated - see artifacts for full output]' : ''}\n\`\`\`\n\n</details>`;
} else {
body = `## 📊 Performance Benchmark Results\n\nBenchmark completed successfully.\n\n<details>\n<summary>Raw Results ${wasTruncated ? '(truncated)' : ''}</summary>\n\n\`\`\`json\n${truncatedResults}${wasTruncated ? '\n...\n[Results truncated - see artifacts for full output]' : ''}\n\`\`\`\n\n</details>`;
}
} else {
body = `## 📊 Performance Benchmark Results\n\nBenchmark completed successfully. Check the uploaded artifacts for detailed results.\n\n<details>\n<summary>Raw Results ${wasTruncated ? '(truncated)' : ''}</summary>\n\n\`\`\`json\n${truncatedResults}${wasTruncated ? '\n...\n[Results truncated - see artifacts for full output]' : ''}\n\`\`\`\n\n</details>`;
}
} else {
body = '## ⚠️ Performance Benchmark Results\n\nBenchmark completed but no results file was generated. Please check the workflow logs and uploaded artifacts.';
}
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
} catch (error) {
console.error('Failed to post benchmark comment:', error);
// Try to post a simple error message
try {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '## ❌ Performance Benchmark Failed\n\nFailed to post benchmark results. Check workflow logs for details.'
});
} catch (commentError) {
console.error('Failed to post error comment:', commentError);
// Don't fail the workflow if we can't post comments
}
}
docs:
name: Documentation
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-doc-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-doc-cargo-
${{ runner.os }}-stable-cargo-
${{ runner.os }}-cargo-
- name: Build documentation
run: |
cargo doc --no-deps --document-private-items --all-features
echo '<meta http-equiv="refresh" content="0; url=md_book">' > target/doc/index.html
- name: Deploy documentation
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./target/doc
destination_dir: docs