-
-
Notifications
You must be signed in to change notification settings - Fork 348
331 lines (286 loc) · 10.6 KB
/
ci.yml
File metadata and controls
331 lines (286 loc) · 10.6 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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
# Professional Quality Gate - PPT Contract Tests (Critical)
ppt-contracts:
name: PPT Contract Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-ppt-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run PPT Contract Tests (Critical Path)
run: |
echo "🧪 Running PPT Contract Tests - Critical Quality Gate"
timeout 300s cargo test --lib --features llama ppt -- --test-threads=1 --nocapture
- name: Verify PPT Coverage
run: |
if [ -f "./scripts/verify-ppt-coverage.sh" ]; then
chmod +x ./scripts/verify-ppt-coverage.sh
./scripts/verify-ppt-coverage.sh
else
echo "⚠️ PPT verification script not found - this is optional"
fi
continue-on-error: true
# Comprehensive Test Suite (includes regression tests)
test:
name: Test Suite
runs-on: ubuntu-latest
needs: ppt-contracts # PPT contracts must pass first
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-test-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check if tests should be skipped
id: check-skip-tests
run: |
if [ -f ".skip-ci-tests" ]; then
echo "skip-tests=true" >> $GITHUB_OUTPUT
echo "🚫 Tests skipped by developer flag (.skip-ci-tests file present)"
echo "📋 Developer has indicated local testing is complete"
echo "🚀 Proceeding directly to deployment"
else
echo "skip-tests=false" >> $GITHUB_OUTPUT
echo "🧪 No skip flag found, will run full test suite in CI"
fi
- name: Run Property Tests
if: steps.check-skip-tests.outputs.skip-tests != 'true'
run: |
echo "Running Property Tests"
timeout 600s cargo test property_tests --no-default-features --features huggingface -- --nocapture
- name: Run Unit Tests (HuggingFace)
if: steps.check-skip-tests.outputs.skip-tests != 'true'
run: |
echo "Running Unit Tests - HuggingFace Feature"
timeout 900s cargo test --lib --no-default-features --features huggingface --verbose
- name: Run Unit Tests (All Features)
if: steps.check-skip-tests.outputs.skip-tests != 'true'
run: |
echo "Running Unit Tests - All Features"
timeout 900s cargo test --lib --all-features --verbose
- name: Run Regression Tests
if: steps.check-skip-tests.outputs.skip-tests != 'true'
run: |
echo "🧪 Running Regression Tests - User-reported bug prevention"
timeout 900s cargo test --test regression --features llama --verbose
timeout 900s cargo test --test regression_tests --no-default-features --features huggingface --verbose
- name: Report test status
run: |
if [ "${{ steps.check-skip-tests.outputs.skip-tests }}" = "true" ]; then
echo "✅ Test Suite: SKIPPED (developer flag present)"
else
echo "✅ Test Suite: PASSED (executed in CI)"
fi
# Code Coverage Analysis
coverage:
name: Code Coverage
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install coverage tools
run: |
cargo install cargo-tarpaulin
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-coverage-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Generate coverage report
run: |
echo "Generating coverage report"
timeout 1200s cargo tarpaulin \
--no-default-features \
--features huggingface \
--out xml \
--output-dir coverage \
--timeout 600 \
--lib \
--verbose
- name: Check coverage standards
run: |
if [ -f "coverage/cobertura.xml" ]; then
COVERAGE_PERCENT=$(grep -o 'line-rate="[^"]*"' coverage/cobertura.xml | head -1 | grep -o '[0-9.]*' || echo "0")
COVERAGE_FORMATTED=$(echo "$COVERAGE_PERCENT * 100" | bc -l | xargs printf "%.1f")
echo "📊 Code Coverage: ${COVERAGE_FORMATTED}%"
MEETS_STANDARD=$(echo "$COVERAGE_PERCENT >= 0.95" | bc -l 2>/dev/null || echo "0")
if [ "$MEETS_STANDARD" -eq 1 ]; then
echo "✅ Coverage meets professional standard (≥95%)"
else
echo "⚠️ Coverage below professional standard (${COVERAGE_FORMATTED}% < 95%)"
echo "::warning::Code coverage ${COVERAGE_FORMATTED}% is below the professional standard of 95%"
fi
else
echo "❌ Coverage report generation failed"
exit 1
fi
- name: Upload coverage reports
uses: codecov/codecov-action@v4
with:
file: coverage/cobertura.xml
flags: unittests
name: shimmy-coverage
fail_ci_if_error: false
# Security Scanning
security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install security tools
run: |
cargo install cargo-audit cargo-deny
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-security-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run vulnerability audit
run: |
echo "🔒 Scanning for known vulnerabilities"
cargo audit --color always
- name: Run supply chain security checks
run: |
echo "🛡️ Checking supply chain security"
cargo deny check
# Code Quality and Linting
lint:
name: Code Quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-lint-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check code formatting
run: |
echo "🎨 Checking code formatting"
cargo fmt -- --check
- name: Run clippy lints
run: |
echo "🔍 Running clippy lints with professional standards"
cargo clippy --no-default-features --features huggingface,llama -- -D warnings
# Cross-Platform Build Verification
build:
name: Build Verification
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
features: "huggingface,llama"
- os: windows-latest
target: x86_64-pc-windows-msvc
features: "huggingface,llama"
- os: macos-latest
target: x86_64-apple-darwin
features: "huggingface,llama"
- os: macos-latest
target: aarch64-apple-darwin
features: "huggingface,llama"
runs-on: ${{ matrix.os }}
needs: [ppt-contracts, security, lint] # Must pass quality gates
steps:
- uses: actions/checkout@v4
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake pkg-config
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: |
which cmake || brew install cmake
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-build-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build with professional standards
run: |
echo "🔨 Building ${{ matrix.target }} with features: ${{ matrix.features }}"
cargo build --release --target ${{ matrix.target }} --no-default-features --features ${{ matrix.features }}
- name: Verify binary
shell: bash
run: |
echo "✅ Build verification complete for ${{ matrix.target }}"
ls -la target/${{ matrix.target }}/release/
# Professional Quality Gate Summary
quality-gate:
name: Professional Quality Gate
runs-on: ubuntu-latest
needs: [ppt-contracts, test, coverage, security, lint, build]
if: always()
steps:
- name: Quality Gate Summary
run: |
echo "🎯 Professional Quality Gate Summary"
echo "=================================="
# Check if all critical jobs passed
if [[ "${{ needs.ppt-contracts.result }}" == "success" && \
"${{ needs.test.result }}" == "success" && \
"${{ needs.security.result }}" == "success" && \
"${{ needs.lint.result }}" == "success" && \
"${{ needs.build.result }}" == "success" ]]; then
echo "✅ All critical quality gates PASSED"
echo "🚀 Code meets professional standards and is ready for deployment"
else
echo "❌ Quality gate FAILURES detected:"
echo " - PPT Contracts: ${{ needs.ppt-contracts.result }}"
echo " - Test Suite: ${{ needs.test.result }}"
echo " - Security Audit: ${{ needs.security.result }}"
echo " - Code Quality: ${{ needs.lint.result }}"
echo " - Build Verification: ${{ needs.build.result }}"
echo " - Coverage Analysis: ${{ needs.coverage.result }}"
echo ""
echo "🔧 Please address failing checks before merging"
exit 1
fi