-
-
Notifications
You must be signed in to change notification settings - Fork 21
125 lines (101 loc) · 3.1 KB
/
Copy pathci.yml
File metadata and controls
125 lines (101 loc) · 3.1 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
name: CI
on:
pull_request:
branches: [ main, develop ]
push:
branches: [ main, develop ]
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# Check formatting and linting
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
key: check
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
# Build and test with cargo-chef for optimized caching
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable, beta]
exclude:
# Reduce CI load by testing beta only on Ubuntu
- os: macos-latest
rust: beta
- os: windows-latest
rust: beta
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
# Install cargo-chef for optimized Docker-style dependency caching
- name: Install cargo-chef
uses: taiki-e/install-action@v2
with:
tool: cargo-chef
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
key: test-${{ matrix.os }}-${{ matrix.rust }}
# Prepare the build plan for cargo-chef
- name: Prepare build plan
run: cargo chef prepare --recipe-path recipe.json
# Cook dependencies (this will be cached)
- name: Cook dependencies
run: cargo chef cook --release --recipe-path recipe.json
# Build the project
- name: Build
run: cargo build --release --all-features
# Run tests
- name: Run tests
run: cargo test --release --all-features
# Run doc tests
- name: Run doc tests
run: cargo test --release --doc
# Coverage report (optional, runs only on main branch pushes)
coverage:
name: Coverage
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-tarpaulin
uses: taiki-e/install-action@v2
with:
tool: cargo-tarpaulin
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
key: coverage
- name: Generate coverage report
run: cargo tarpaulin --verbose --all-features --workspace --timeout 120 --out xml --output-dir ./coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
file: ./coverage/cobertura.xml
fail_ci_if_error: false