-
-
Notifications
You must be signed in to change notification settings - Fork 0
639 lines (572 loc) · 20.3 KB
/
ci.yaml
File metadata and controls
639 lines (572 loc) · 20.3 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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
# =============================================================================
# Forge CI Pipeline
# =============================================================================
# Main continuous integration pipeline for the Forge code migration engine.
# Runs on every push and pull request to ensure code quality and correctness.
#
# Features:
# - Multi-platform testing (Linux, macOS, Windows)
# - Rust toolchain setup with caching
# - Code formatting checks (rustfmt)
# - Linting (clippy)
# - Comprehensive test suite
# - Release and debug builds
# - Code coverage reporting
# - Artifact uploads
# - Dependency caching for fast builds
# =============================================================================
name: CI
on:
push:
branches:
- main
- develop
- 'feature/**'
- 'release/**'
- 'hotfix/**'
paths-ignore:
- '**.md'
- 'docs/**'
- '.github/ISSUE_TEMPLATE/**'
- '.github/PULL_REQUEST_TEMPLATE/**'
- 'LICENSE*'
pull_request:
branches:
- main
- develop
paths-ignore:
- '**.md'
- 'docs/**'
- '.github/ISSUE_TEMPLATE/**'
- '.github/PULL_REQUEST_TEMPLATE/**'
- 'LICENSE*'
workflow_dispatch:
inputs:
run_extended_tests:
description: 'Run extended test suite'
required: false
default: 'false'
type: boolean
skip_cache:
description: 'Skip dependency cache'
required: false
default: 'false'
type: boolean
# Cancel in-progress runs for the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUST_BACKTRACE: short
RUSTFLAGS: -D warnings -W rust-2021-compatibility
RUSTDOCFLAGS: -D warnings
FORGE_CI: true
# Minimum supported Rust version
MSRV: "1.75.0"
jobs:
# ===========================================================================
# Pre-flight checks - Fast checks that should pass before running full CI
# ===========================================================================
preflight:
name: Preflight Checks
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
paths_result: ${{ steps.skip_check.outputs.paths_result }}
steps:
- name: Check for skip conditions
id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: 'same_content_newer'
skip_after_successful_duplicate: 'true'
paths_ignore: '["**/README.md", "**/docs/**", "**/*.txt"]'
do_not_skip: '["workflow_dispatch", "schedule"]'
# ===========================================================================
# Format Check - Verify code formatting with rustfmt
# ===========================================================================
format:
name: Format Check
runs-on: ubuntu-latest
needs: preflight
if: needs.preflight.outputs.should_skip != 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Rust toolchain
uses: dtolnay/rust-action@stable
with:
components: rustfmt
- name: Check formatting
run: |
echo "::group::Checking code formatting"
cargo fmt --all -- --check
echo "::endgroup::"
- name: Check TOML formatting
uses: taiki-e/install-action@v2
with:
tool: taplo-cli
- name: Verify Cargo.toml formatting
run: taplo fmt --check
# ===========================================================================
# Lint - Run clippy for comprehensive linting
# ===========================================================================
lint:
name: Lint (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: preflight
if: needs.preflight.outputs.should_skip != 'true'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Rust toolchain
uses: dtolnay/rust-action@stable
with:
components: clippy
targets: ${{ matrix.target }}
- name: Cache cargo registry
uses: actions/cache@v4
if: ${{ github.event.inputs.skip_cache != 'true' }}
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-lint-
${{ runner.os }}-cargo-
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev pkg-config
- name: Run clippy (all features)
run: |
echo "::group::Running clippy with all features"
cargo clippy --workspace --all-features --all-targets -- \
-D warnings \
-D clippy::all \
-D clippy::pedantic \
-A clippy::module_name_repetitions \
-A clippy::too_many_lines \
-A clippy::must_use_candidate \
-A clippy::missing_errors_doc \
-A clippy::missing_panics_doc
echo "::endgroup::"
- name: Run clippy (no default features)
run: |
echo "::group::Running clippy without default features"
cargo clippy --workspace --no-default-features -- -D warnings
echo "::endgroup::"
# ===========================================================================
# MSRV Check - Verify minimum supported Rust version
# ===========================================================================
msrv:
name: MSRV Check (Rust ${{ matrix.rust }})
runs-on: ubuntu-latest
needs: preflight
if: needs.preflight.outputs.should_skip != 'true'
strategy:
matrix:
rust: ["1.75.0"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-action@master
with:
toolchain: ${{ matrix.rust }}
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-msrv-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-msrv-${{ matrix.rust }}-
- name: Check MSRV compatibility
run: cargo check --workspace --all-features
# ===========================================================================
# Test - Run comprehensive test suite
# ===========================================================================
test:
name: Test (${{ matrix.os }}, ${{ matrix.rust }})
runs-on: ${{ matrix.os }}
needs: [format, lint]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable, beta]
exclude:
# Only test stable on Windows and macOS to save CI time
- os: windows-latest
rust: beta
- os: macos-latest
rust: beta
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-action@master
with:
toolchain: ${{ matrix.rust }}
- name: Cache cargo registry
uses: actions/cache@v4
if: ${{ github.event.inputs.skip_cache != 'true' }}
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.rust }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.rust }}-cargo-test-
${{ runner.os }}-${{ matrix.rust }}-cargo-
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev pkg-config
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install openssl@3
- name: Run tests (all features)
run: |
echo "::group::Running tests with all features"
cargo test --workspace --all-features --no-fail-fast
echo "::endgroup::"
env:
RUST_LOG: debug
- name: Run tests (no default features)
run: |
echo "::group::Running tests without default features"
cargo test --workspace --no-default-features --no-fail-fast
echo "::endgroup::"
- name: Run doc tests
run: |
echo "::group::Running documentation tests"
cargo test --workspace --doc
echo "::endgroup::"
- name: Run extended tests
if: ${{ github.event.inputs.run_extended_tests == 'true' || github.ref == 'refs/heads/main' }}
run: |
echo "::group::Running extended tests"
cargo test --workspace --all-features -- --ignored
echo "::endgroup::"
env:
FORGE_EXTENDED_TESTS: true
# ===========================================================================
# Coverage - Generate code coverage reports
# ===========================================================================
coverage:
name: Code Coverage
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-action@stable
with:
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-coverage-
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev pkg-config
- name: Generate coverage report
run: |
echo "::group::Generating code coverage"
cargo llvm-cov --workspace --all-features --lcov --output-path lcov.info
echo "::endgroup::"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: lcov.info
fail_ci_if_error: false
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: lcov.info
retention-days: 30
# ===========================================================================
# Build - Build release binaries
# ===========================================================================
build:
name: Build (${{ matrix.os }}, ${{ matrix.target }})
runs-on: ${{ matrix.os }}
needs: [format, lint]
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: forge-linux-x86_64
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: forge-linux-x86_64-musl
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact_name: forge-linux-aarch64
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: forge-macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: forge-macos-aarch64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: forge-windows-x86_64
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Rust toolchain
uses: dtolnay/rust-action@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo registry
uses: actions/cache@v4
if: ${{ github.event.inputs.skip_cache != 'true' }}
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-build-
${{ runner.os }}-${{ matrix.target }}-cargo-
- name: Install cross-compilation tools (Linux aarch64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Install musl tools (Linux musl)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev pkg-config
- name: Build release binary
run: |
echo "::group::Building release binary for ${{ matrix.target }}"
cargo build --release --target ${{ matrix.target }} --workspace
echo "::endgroup::"
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Strip binary (Linux/macOS)
if: runner.os != 'Windows'
run: |
strip target/${{ matrix.target }}/release/forge || true
strip target/${{ matrix.target }}/release/forge-cli || true
- name: Create artifact directory
shell: bash
run: |
mkdir -p artifacts
if [ "${{ runner.os }}" == "Windows" ]; then
cp target/${{ matrix.target }}/release/forge.exe artifacts/ || true
cp target/${{ matrix.target }}/release/forge-cli.exe artifacts/ || true
else
cp target/${{ matrix.target }}/release/forge artifacts/ || true
cp target/${{ matrix.target }}/release/forge-cli artifacts/ || true
fi
cp README.md artifacts/ || true
cp LICENSE* artifacts/ || true
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: artifacts/
retention-days: 7
# ===========================================================================
# Documentation - Build and verify documentation
# ===========================================================================
docs:
name: Documentation
runs-on: ubuntu-latest
needs: preflight
if: needs.preflight.outputs.should_skip != 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-action@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-docs-
- name: Build documentation
run: |
echo "::group::Building documentation"
cargo doc --workspace --all-features --no-deps --document-private-items
echo "::endgroup::"
env:
RUSTDOCFLAGS: -D warnings --cfg docsrs
- name: Check for broken intra-doc links
run: |
echo "::group::Checking documentation links"
cargo doc --workspace --all-features --no-deps 2>&1 | tee doc-output.txt
if grep -q "warning: unresolved link" doc-output.txt; then
echo "::error::Found broken documentation links"
grep "warning: unresolved link" doc-output.txt
exit 1
fi
echo "::endgroup::"
- name: Upload documentation artifact
uses: actions/upload-artifact@v4
with:
name: documentation
path: target/doc
retention-days: 7
# ===========================================================================
# Benchmarks - Run performance benchmarks (on main only)
# ===========================================================================
benchmarks:
name: Benchmarks
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-action@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-bench-
- name: Install critcmp
run: cargo install critcmp
- name: Run benchmarks
run: |
echo "::group::Running benchmarks"
cargo bench --workspace -- --save-baseline current
echo "::endgroup::"
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: target/criterion
retention-days: 30
# ===========================================================================
# Final Status - Aggregate all job results
# ===========================================================================
ci-success:
name: CI Success
runs-on: ubuntu-latest
needs: [format, lint, test, build, docs, coverage]
if: always()
steps:
- name: Check all jobs passed
run: |
if [ "${{ needs.format.result }}" != "success" ] || \
[ "${{ needs.lint.result }}" != "success" ] || \
[ "${{ needs.test.result }}" != "success" ] || \
[ "${{ needs.build.result }}" != "success" ] || \
[ "${{ needs.docs.result }}" != "success" ]; then
echo "::error::One or more CI jobs failed"
echo "Format: ${{ needs.format.result }}"
echo "Lint: ${{ needs.lint.result }}"
echo "Test: ${{ needs.test.result }}"
echo "Build: ${{ needs.build.result }}"
echo "Docs: ${{ needs.docs.result }}"
exit 1
fi
echo "::notice::All CI checks passed successfully!"
- name: Post success comment on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('CI Status')
);
const body = `## ✅ CI Status
All checks passed successfully!
| Check | Status |
|-------|--------|
| Format | ✅ |
| Lint | ✅ |
| Tests | ✅ |
| Build | ✅ |
| Docs | ✅ |
| Coverage | ✅ |
_Updated: ${new Date().toISOString()}_`;
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}