-
Notifications
You must be signed in to change notification settings - Fork 2
338 lines (280 loc) · 8.81 KB
/
ci.yml
File metadata and controls
338 lines (280 loc) · 8.81 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
name: CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
jobs:
# Python tests
python-tests:
name: Python Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"
- name: Run pytest with coverage
run: |
source .venv/bin/activate
pytest tests/unit/python tests/integration/python tests/property \
--cov=src \
--cov-report=xml \
--cov-report=html \
--cov-report=term-missing \
--junitxml=junit/test-results-${{ matrix.python-version }}.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: python
name: python-${{ matrix.python-version }}
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: pytest-results-${{ matrix.python-version }}
path: junit/test-results-${{ matrix.python-version }}.xml
# Rust tests
rust-tests:
name: Rust Tests
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, beta]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt, clippy
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v4
with:
path: rust/target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Run cargo test
working-directory: ./rust
run: cargo test --all-features --workspace --verbose
- name: Run cargo test with coverage
working-directory: ./rust
run: |
cargo install cargo-tarpaulin
cargo tarpaulin --all-features --workspace --timeout 120 --out Xml --output-dir ./coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./rust/coverage/cobertura.xml
flags: rust
name: rust-${{ matrix.rust }}
# Code quality
code-quality:
name: Code Quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv and dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"
- name: Run black (code formatting)
run: |
source .venv/bin/activate
black --check src tests
- name: Run flake8 (linting)
run: |
source .venv/bin/activate
flake8 src tests --max-line-length=100
- name: Run mypy (type checking)
run: |
source .venv/bin/activate
mypy src tests --ignore-missing-imports
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- name: Run rustfmt
working-directory: ./rust
run: cargo fmt -- --check
- name: Run clippy
working-directory: ./rust
run: cargo clippy --all-targets --all-features -- -D warnings
# Benchmark tests
benchmarks:
name: Performance Benchmarks
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Run Rust benchmarks
working-directory: ./rust
run: cargo bench --workspace
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"
- name: Run Python benchmarks
run: |
source .venv/bin/activate
pytest tests/benchmarks --benchmark-only --benchmark-json=benchmark-results.json
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: benchmark-results.json
# Security audit
security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Run cargo audit
working-directory: ./rust
run: |
cargo install cargo-audit
cargo audit
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"
- name: Run safety (Python dependency audit)
run: |
source .venv/bin/activate
pip install safety
safety check
- name: Run bandit (Python security linter)
run: |
source .venv/bin/activate
pip install bandit
bandit -r src -f json -o bandit-report.json
- name: Upload security reports
uses: actions/upload-artifact@v4
if: always()
with:
name: security-reports
path: bandit-report.json
# Integration tests (requires running services)
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Install ZeroMQ
run: |
sudo apt-get update
sudo apt-get install -y libzmq3-dev
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Build Rust components
working-directory: ./rust
run: cargo build --release
- name: Run integration tests
run: |
source .venv/bin/activate
pytest tests/integration tests/e2e -v --tb=short
# Coverage report
coverage-report:
name: Coverage Report
needs: [python-tests, rust-tests]
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Download coverage reports
uses: actions/download-artifact@v4
- name: Display coverage summary
run: |
echo "## Coverage Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Coverage reports have been uploaded to Codecov" >> $GITHUB_STEP_SUMMARY
echo "View detailed reports at: https://codecov.io/${{ github.repository }}" >> $GITHUB_STEP_SUMMARY