Skip to content

Commit 0f51a6f

Browse files
authored
Merge pull request #21 from adhocteam/copilot/add-coverage-threshold-ci
Enforce minimum test coverage threshold in CI
2 parents 183d283 + 45188e0 commit 0f51a6f

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,14 @@ jobs:
5858
run: |
5959
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
6060
echo "Total coverage: ${COVERAGE}%"
61-
# Optionally fail if coverage is below threshold
62-
# if (( $(echo "$COVERAGE < 25.0" | bc -l) )); then
63-
# echo "Coverage ${COVERAGE}% is below minimum 25%"
64-
# exit 1
65-
# fi
61+
# Enforce minimum coverage threshold
62+
# Current: 25% (to prevent regression)
63+
# Target: 70% (see README.md for roadmap)
64+
if (( $(echo "$COVERAGE < 25.0" | bc -l) )); then
65+
echo "❌ Coverage ${COVERAGE}% is below minimum 25%"
66+
exit 1
67+
fi
68+
echo "✓ Coverage check passed"
6669
6770
lint:
6871
name: Lint

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,22 @@ make test-coverage
302302
go test -coverprofile=coverage.out ./...
303303
go tool cover -html=coverage.out -o coverage.html
304304

305+
# Check coverage percentage
306+
go tool cover -func=coverage.out | grep total
307+
305308
# Run specific package tests
306309
go test -v ./internal/api/...
307310

308311
# Run with verbose output
309312
go test -v -run TestSearchParks ./internal/api/
310313
```
311314

315+
**Coverage Requirements:**
316+
- **Minimum threshold**: 25% (enforced in CI to prevent regression)
317+
- **Target coverage**: 70% (see Contributing section for roadmap)
318+
- CI will fail if coverage drops below the minimum threshold
319+
- Always check coverage locally before pushing: `make test-coverage`
320+
312321
### Run Locally (without Docker)
313322

314323
```bash
@@ -664,12 +673,37 @@ Contributions are welcome! Here's how you can help:
664673

665674
### Development Guidelines
666675
- Follow Go best practices and idioms
667-
- Maintain test coverage above 70%
676+
- Maintain test coverage above minimum threshold (see coverage requirements below)
668677
- Document exported functions and packages
669678
- Update README for user-facing changes
670679
- Keep commits atomic and well-described
671680
- Review `AGENTS.md` for project conventions and patterns
672681

682+
### Test Coverage Requirements
683+
684+
**Current Status:**
685+
- **Overall coverage**: ~25%
686+
- **Minimum threshold**: 25% (enforced in CI)
687+
- **Target coverage**: 70%
688+
689+
**Coverage by Package:**
690+
- `internal/config`: 94.3% ✅
691+
- `internal/cache`: 45.7%
692+
- `internal/api`: 27.2%
693+
- `internal/mcp`: 0.0% ⚠️
694+
- `pkg/util`: 0.0% ⚠️
695+
696+
**Roadmap to 70% Coverage:**
697+
1. **Phase 1** (Target: ~50-60%): Add comprehensive handler tests for `internal/mcp`
698+
2. **Phase 2** (Target: ~60-70%): Add utility package tests for `pkg/util`
699+
3. **Phase 3** (Target: 70%+): Add integration tests and improve API client coverage
700+
701+
**Before Submitting PRs:**
702+
- Check coverage locally: `make test-coverage`
703+
- Ensure your changes don't decrease overall coverage
704+
- Add tests for new features and bug fixes
705+
- Aim for 70%+ coverage on new code
706+
673707
### Code Review Process
674708
- All PRs require review before merging
675709
- CI checks must pass (automated via GitHub Actions)

0 commit comments

Comments
 (0)