The Store Coverage Enforcer is a GitHub Actions workflow that automatically ensures store test coverage reaches 100%. It monitors the CI Pipeline, analyzes coverage data, and creates pull requests with additional tests when coverage is insufficient.
- Monitors CI Pipeline completion
- Downloads and parses coverage artifacts
- Analyzes lcov.info coverage data
- Tracks lines, functions, and branches coverage
- Identifies uncovered code paths
- Generates additional test files automatically
- Uses AI assistance for test creation
- Ensures all generated tests pass
- Creates pull requests only when needed
- Prevents duplicate coverage PRs
- Updates existing PRs with coverage status
- Includes detailed coverage reports
- Verifies tests pass before creating PRs
- Ensures no breaking changes
- Maintains code quality standards
- Provides comprehensive test coverage
The workflow triggers automatically when:
- CI Pipeline completes successfully
- Coverage artifacts are available
- Store test coverage is below 100%
- Parses lcov.info coverage data
- Extracts coverage percentages (lines, functions, branches)
- Identifies specific uncovered lines
- Generates detailed coverage reports- Analyzes uncovered code paths
- Creates test templates for missing coverage
- Generates actual test implementations
- Validates test functionality- Creates new branch for coverage improvements
- Commits generated tests
- Creates pull request with detailed description
- Includes coverage improvement metricsLocated at: .github/workflows/coverage-enforcer.yml
CURSOR_API_KEY: For AI-powered test generationGITHUB_TOKEN: Automatically provided by GitHub Actions
The workflow uses the existing coverage setup:
{
"scripts": {
"test:stores:coverage": "vitest --coverage --run src/tests/stores/ --coverage.include='src/stores/**/*Store.js'"
}
}The workflow enforces 100% coverage for:
- Lines: All executable lines must be covered
- Functions: All functions must be called in tests
- Branches: All conditional branches must be tested
🎉 Store test coverage is at 100%!
No action needed - all tests are fully covered.
📊 Coverage Update
Current store test coverage status:
- Lines: 85%
- Functions: 92%
- Branches: 78%
⚠️ Coverage is still below 100%. Additional tests may be needed.
## Coverage Improvement
This PR automatically improves store test coverage to reach 100%.
### Current Coverage Status
- **Lines**: 85% → 100%
- **Functions**: 92% → 100%
- **Branches**: 78% → 100%
### Changes Made
- Added additional unit tests for uncovered code paths
- Generated tests based on coverage analysis
- Ensured all tests pass before creating this PRThe workflow creates several artifacts:
coverage-analysis-report: Detailed coverage analysistest-suggestions.json: Test generation suggestions- Coverage reports in HTML and LCOV formats
- Review Generated Tests: Always review automatically generated tests before merging
- Maintain Test Quality: Ensure generated tests follow project standards
- Monitor Coverage Trends: Track coverage improvements over time
- Monitor Workflow Runs: Check GitHub Actions tab for workflow status
- Review PRs: Ensure generated tests are appropriate
- Update Configuration: Adjust coverage requirements as needed
Coverage Not Generated
- Verify CI Pipeline runs coverage step
- Check that artifacts are uploaded correctly
- Ensure vitest configuration is correct
Permission Errors
- Verify GitHub token has required permissions
- Check repository settings for Actions permissions
Test Generation Fails
- Ensure CURSOR_API_KEY is properly configured
- Check API key has sufficient credits
- Verify network connectivity
Duplicate PRs
- The workflow prevents duplicate coverage PRs automatically
- Check for existing open PRs with "coverage" label
The workflow includes extensive logging:
- Coverage percentages at each step
- Test generation progress tracking
- PR creation status reporting
- Error handling and recovery
- Downloads artifacts from CI Pipeline
- Uses existing coverage configuration
- Leverages existing test infrastructure
- Works alongside auto-fix workflow
- Different triggers and purposes
- Complementary functionality
Potential improvements:
- Custom coverage thresholds per file
- Integration with code quality tools
- Enhanced test generation algorithms
- Project management tool integration
- Custom coverage reporting formats
- Coverage improvement percentage
- Number of tests generated
- Time to reach 100% coverage
- PR creation and merge rates
- Coverage trends over time
- Test generation effectiveness
- Workflow performance metrics
- Quality of generated tests
The workflow requires minimal permissions:
contents: write- Create branches and commitspull-requests: write- Create and manage PRsactions: write- Trigger workflowschecks: write- Create check runs
- CURSOR_API_KEY is used securely via GitHub Secrets
- No sensitive data is logged or exposed
- All API calls are made from secure GitHub Actions environment
For issues or questions:
- Check the GitHub Actions logs
- Review the workflow configuration
- Verify required secrets are set
- Check coverage configuration in package.json
- Review vitest configuration