-
Notifications
You must be signed in to change notification settings - Fork 0
221 lines (198 loc) · 8.47 KB
/
Copy pathci.yml
File metadata and controls
221 lines (198 loc) · 8.47 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
# Continuous Integration workflow for iggy-sample
#
# Runs on every push to main and on all pull requests.
# Includes: formatting, linting, testing, coverage, documentation, and security audit.
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
schedule:
# Run every Monday at 2:00 AM UTC to catch dependency issues early
- cron: "0 2 * * 1"
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
# Minimum supported Rust version
MSRV: "1.93.0"
# Cancel in-progress runs for the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ==========================================================================
# Formatting check (fast, run first)
# ==========================================================================
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88 # master
with:
toolchain: nightly
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
# ==========================================================================
# Clippy linting
# ==========================================================================
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88 # master
with:
toolchain: stable
components: clippy
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Run Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
# ==========================================================================
# Test matrix across OS and Rust versions
# ==========================================================================
test:
name: Test (${{ matrix.os }}, ${{ matrix.rust }})
runs-on: ${{ matrix.os }}
needs: [fmt]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable, beta]
include:
# MSRV check on Ubuntu only
- os: ubuntu-latest
rust: "1.93.0"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88 # master
with:
toolchain: ${{ matrix.rust }}
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
key: ${{ matrix.os }}-${{ matrix.rust }}
- name: Build
run: cargo build --all-features
- name: Run unit tests
run: cargo test --lib --all-features
- name: Run doc tests
run: cargo test --doc --all-features
# ==========================================================================
# Integration tests (requires Docker for testcontainers)
# ==========================================================================
integration:
name: Integration Tests
runs-on: ubuntu-latest
needs: [fmt, clippy]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88 # master
with:
toolchain: stable
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Run integration tests
run: cargo test --test '*' --all-features
env:
# Testcontainers will pull and run Iggy server automatically
TESTCONTAINERS: true
# ==========================================================================
# Code coverage
# ==========================================================================
coverage:
name: Code Coverage
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88 # master
with:
toolchain: stable
components: llvm-tools-preview
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@4684b8405694ae9dd42c9f39ba901a70ae83f4a3 # v2.82.9
with:
tool: cargo-llvm-cov
- name: Generate coverage report
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
with:
files: lcov.info
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# ==========================================================================
# Documentation build
# ==========================================================================
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88 # master
with:
toolchain: stable
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Build documentation
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: -D warnings
# ==========================================================================
# Security audit
# ==========================================================================
audit:
name: Security Audit
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
issues: write
steps:
- uses: actions/checkout@v4
- uses: rustsec/audit-check@69366f33c96575abad1ee0dba8212993eecbe998 # v2.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
# ==========================================================================
# Dependency policy check (advisories + licenses, gated by deny.toml)
# ==========================================================================
licenses:
name: Dependency Policy (cargo-deny)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88 # master
with:
toolchain: stable
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Install cargo-deny
uses: taiki-e/install-action@4684b8405694ae9dd42c9f39ba901a70ae83f4a3 # v2.82.9
with:
tool: cargo-deny
- name: Check dependency policy (advisories, bans, licenses, sources)
run: cargo deny check
# ==========================================================================
# Final status check (for branch protection)
# ==========================================================================
ci-success:
name: CI Success
runs-on: ubuntu-latest
needs: [fmt, clippy, test, integration, docs, audit, licenses]
if: always()
steps:
- name: Check all jobs passed
run: |
if [[ "${{ needs.fmt.result }}" != "success" ]] || \
[[ "${{ needs.clippy.result }}" != "success" ]] || \
[[ "${{ needs.test.result }}" != "success" ]] || \
[[ "${{ needs.integration.result }}" != "success" ]] || \
[[ "${{ needs.docs.result }}" != "success" ]] || \
[[ "${{ needs.audit.result }}" != "success" ]] || \
[[ "${{ needs.licenses.result }}" != "success" ]]; then
echo "One or more jobs failed"
exit 1
fi
echo "All CI checks passed!"