name: ๐ฆ FeedMe CI - Tests & Coverage
on:
push:
branches: [ master, main, develop ]
pull_request:
branches: [ master, 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 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 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/master'
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