-
-
Notifications
You must be signed in to change notification settings - Fork 19
152 lines (124 loc) · 4.4 KB
/
Copy pathtest-and-coverage.yml
File metadata and controls
152 lines (124 loc) · 4.4 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
name: 🦀 CrabCamera CI - Tests & Coverage
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
test-and-coverage:
name: Test Suite & Coverage
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable, beta]
exclude:
- os: macos-latest
rust: beta
- os: windows-latest
rust: beta
steps:
- name: 📦 Checkout code
uses: actions/checkout@v4
- name: 🦀 Setup Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- name: 💾 Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libasound2-dev
- name: Install tarpaulin (Linux only)
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'stable'
run: cargo install cargo-tarpaulin
- name: 🧪 Run tests
run: cargo test --all-features --verbose
- name: 📊 Generate coverage report
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'stable'
run: cargo tarpaulin --all-features --workspace --timeout 300 --out Xml --out Html
- name: 📈 Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'stable'
uses: codecov/codecov-action@v4
with:
file: cobertura.xml
fail_ci_if_error: true
- name: 🔍 Run clippy
run: cargo clippy --all-features -- -D warnings
- name: 🎨 Check formatting
run: cargo fmt -- --check
coverage-enforcement:
name: Coverage Enforcement
runs-on: ubuntu-latest
needs: test-and-coverage
if: github.event_name == 'pull_request'
steps:
- name: 📦 Checkout code
uses: actions/checkout@v4
- name: 🦀 Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libasound2-dev
- name: Install tarpaulin
run: cargo install cargo-tarpaulin
- name: 📊 Check coverage meets minimum (80%)
run: |
coverage=$(cargo tarpaulin --lib --timeout 300 --exclude-files 'target/*' --exclude-files '*/tests/*' | grep -o '[0-9]\+\.[0-9]\+% coverage' | head -1 | cut -d'%' -f1)
echo "Current coverage: ${coverage}%"
if (( $(echo "${coverage} < 80.0" | bc -l) )); then
echo "❌ Coverage ${coverage}% is below required 80%"
exit 1
fi
echo "✅ Coverage ${coverage}% meets requirements"
security-audit:
name: Security Audit
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
checks: write
steps:
- name: 📦 Checkout code
uses: actions/checkout@v4
- name: 🦀 Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: 🔧 Install cargo-audit
run: cargo install cargo-audit
- name: 🔒 Run security audit
run: cargo audit
publish-check:
name: Publish Readiness Check
runs-on: ubuntu-latest
needs: [test-and-coverage, coverage-enforcement]
if: github.ref == 'refs/heads/main'
steps:
- name: 📦 Checkout code
uses: actions/checkout@v4
- name: 🦀 Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: 🎯 Test publish (dry run)
run: cargo publish --dry-run
- name: 📋 Generate release notes
if: success()
run: |
echo "## 🦀 CrabCamera Release Ready" >> $GITHUB_STEP_SUMMARY
echo "✅ All tests passing" >> $GITHUB_STEP_SUMMARY
echo "✅ Coverage ≥ 80%" >> $GITHUB_STEP_SUMMARY
echo "✅ Security audit clean" >> $GITHUB_STEP_SUMMARY
echo "✅ Crate publish ready" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Ready for release to crates.io! 🚀**" >> $GITHUB_STEP_SUMMARY