Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on:
pull_request:
branches: [prd, dev, stg]

jobs:
checkMeds:
name: Check Meds (merge every day)
runs-on: ubuntu-latest
steps:
- name: Check Meds
uses: byuawsfhtl/MedsAction@v1.0.0

checkStandard:
name: Python Standard Check
runs-on: ubuntu-latest
steps:
- name: Check Standard
uses: byuawsfhtl/PythonStandardAction@v1.2.0

checkTestCoverage:
name: Test Coverage Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check Test Coverage
uses: ./
1 change: 1 addition & 0 deletions .standardignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/tests
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"python.testing.unittestArgs": [
"-v",
"-s",
".",
"-p",
"test_*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
}
90 changes: 88 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,88 @@
# RLL_Template
This is a template repository for future computer vision projects
# Test Coverage Action

A GitHub Action that scans repositories for tests, calculates test coverage, and reports coverage percentage.

## Features

- **🔍 Auto-discovery**: Finds test files using configurable patterns
- **📊 Coverage calculation**: Uses Python's `coverage.py` tool for accurate metrics
- **⚙️ Flexible configuration**: Customizable coverage thresholds and paths
- **📈 Multiple report formats**: Terminal, HTML, XML, and JSON output
- **🚫 Smart exclusions**: Excludes test files and specified paths from coverage
- **✅ CI integration**: Seamless GitHub Actions workflow integration

## Usage

Add this step to your GitHub Actions workflow:

```yaml
- name: Check Test Coverage
uses: ./
with:
minimum_coverage: '80' # Required coverage percentage
test_paths: 'tests/,**/test_*.py' # Where to find tests
source_paths: '.' # Source code to analyze
exclude_paths: 'tests/,setup.py' # Paths to exclude
fail_on_low_coverage: 'true' # Fail if below threshold. For older repos that are building coverage, change this to false
report_format: 'term' # Report format (term/html/xml/json)
```

## Inputs

| Input | Description | Required | Default |
|-------|-------------|----------|---------|
| `minimum_coverage` | Minimum coverage percentage (0-100) | No | `80` |
| `test_paths` | Comma-separated test directories/files | No | `tests/,test/,**/test_*.py,**/tests.py` |
| `source_paths` | Comma-separated source directories | No | `.` |
| `exclude_paths` | Comma-separated paths to exclude | No | `tests/,test/,**/test_*.py,**/tests.py,setup.py,conftest.py` |
| `fail_on_low_coverage` | Fail action if coverage below minimum | No | `true` |
| `report_format` | Coverage report format | No | `term` |

## Outputs

| Output | Description |
|--------|-------------|
| `coverage_percentage` | Calculated test coverage percentage |
| `coverage_report` | Path to generated coverage report |
| `tests_found` | Number of test files discovered |

## Examples

### Basic Usage
```yaml
- name: Test Coverage Check
uses: ./
```

### Custom Configuration
```yaml
- name: Test Coverage Check
uses: ./
with:
minimum_coverage: '90'
test_paths: 'my_tests/,unit_tests/'
source_paths: 'src/,lib/'
exclude_paths: 'tests/,migrations/'
report_format: 'html'
```

### Generate HTML Report
```yaml
- name: Test Coverage Check
uses: ./
with:
report_format: 'html'

- name: Upload Coverage Report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: htmlcov/
```

## Development

The action consists of:
- `action.yml` - Action metadata and interface
- `TestChecker.py` - Main coverage checking logic
- `requirements.txt` - Python dependencies
Loading