Skip to content

chore: Apply Hard Mode audit fixes (clippy, docs, tests) #59

chore: Apply Hard Mode audit fixes (clippy, docs, tests)

chore: Apply Hard Mode audit fixes (clippy, docs, tests) #59

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