name: Coverage 'on': push: branches: [ main ] pull_request: branches: [ main ] workflow_dispatch: inputs: fail_threshold: description: 'Minimum coverage percentage (0 to disable)' required: false default: '80' jobs: rust-coverage: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Rust toolchain uses: dtolnay/rust-toolchain@stable with: toolchain: stable components: llvm-tools-preview - name: Install cargo-llvm-cov run: cargo install cargo-llvm-cov --locked - name: Generate coverage working-directory: ./red run: | # Determine threshold: use input for workflow_dispatch, otherwise default to 80 if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then THRESHOLD="${{ github.event.inputs.fail_threshold }}" else THRESHOLD="80" fi echo "========================================" echo " Coverage threshold: ${THRESHOLD}%" echo "========================================" # Run coverage with threshold if [ "$THRESHOLD" != "0" ] && [ -n "$THRESHOLD" ]; then bash scripts/coverage.sh --fail-under "$THRESHOLD" else bash scripts/coverage.sh fi - name: Show coverage summary if: always() working-directory: ./red run: | echo "" echo "========================================" echo " COVERAGE STATISTICS" echo "========================================" echo "" cargo llvm-cov report --ignore-filename-regex ".*/\.cargo/registry/.*|.*/rustc/.*|.*/target/.*" echo "" echo "========================================" - name: Upload lcov artifact if: always() uses: actions/upload-artifact@v4 with: name: lcov.info path: red/coverage/lcov.info