|
| 1 | +# CodeAnt AI Coverage Upload Action |
| 2 | + |
| 3 | +[](https://github.com/marketplace/actions/codeant-ai-coverage-upload) |
| 4 | +[](LICENSE) |
| 5 | + |
| 6 | +Upload test coverage reports to CodeAnt AI for comprehensive analysis, visualization, and tracking of your code coverage metrics. |
| 7 | + |
| 8 | +## Features |
| 9 | + |
| 10 | +- 📊 Upload coverage reports in multiple formats (XML, JSON, LCOV, etc.) |
| 11 | +- 🔍 Automatic coverage analysis and insights |
| 12 | +- 📈 Track coverage trends over time |
| 13 | +- 🎯 Integration with pull requests |
| 14 | +- 🚀 Easy setup with minimal configuration |
| 15 | + |
| 16 | +## Usage |
| 17 | + |
| 18 | +### Basic Example |
| 19 | + |
| 20 | +```yaml |
| 21 | +name: Test Coverage |
| 22 | + |
| 23 | +on: |
| 24 | + push: |
| 25 | + branches: [main] |
| 26 | + pull_request: |
| 27 | + branches: [main] |
| 28 | + |
| 29 | +jobs: |
| 30 | + coverage: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Run tests with coverage |
| 37 | + run: | |
| 38 | + # Your test command that generates coverage report |
| 39 | + pytest --cov --cov-report=xml |
| 40 | +
|
| 41 | + - name: Upload coverage to CodeAnt AI |
| 42 | + uses: CodeAnt-AI/[email protected] |
| 43 | + with: |
| 44 | + access_token: ${{ secrets.CODEANT_ACCESS_TOKEN }} |
| 45 | + coverage_file: coverage.xml |
| 46 | +``` |
| 47 | +
|
| 48 | +### Advanced Example |
| 49 | +
|
| 50 | +```yaml |
| 51 | +- name: Upload coverage to CodeAnt AI |
| 52 | + uses: CodeAnt-AI/[email protected] |
| 53 | + with: |
| 54 | + access_token: ${{ secrets.CODEANT_ACCESS_TOKEN }} |
| 55 | + coverage_file: coverage.json |
| 56 | + api_base: https://api.codeant.ai |
| 57 | + platform: github |
| 58 | + base_url: https://github.com |
| 59 | +``` |
| 60 | +
|
| 61 | +## Inputs |
| 62 | +
|
| 63 | +| Input | Description | Required | Default | |
| 64 | +|-------|-------------|----------|---------| |
| 65 | +| `access_token` | GitHub Access Token for authentication | Yes | - | |
| 66 | +| `coverage_file` | Path to the coverage file (e.g., coverage.xml, coverage.json) | Yes | `coverage.xml` | |
| 67 | +| `api_base` | CodeAnt AI API base URL | No | `https://api.codeant.ai` | |
| 68 | +| `platform` | Git platform (github, gitlab, bitbucket) | No | `github` | |
| 69 | +| `base_url` | Base URL of the git platform | No | `https://github.com` | |
| 70 | + |
| 71 | +## Supported Coverage Formats |
| 72 | + |
| 73 | +- Cobertura XML (`.xml`) |
| 74 | +- JaCoCo XML |
| 75 | +- LCOV (`.lcov`) |
| 76 | +- JSON coverage reports |
| 77 | +- And more... |
| 78 | + |
| 79 | +## Setup |
| 80 | + |
| 81 | +### 1. Generate Coverage Report |
| 82 | + |
| 83 | +First, ensure your test suite generates a coverage report. Here are examples for common languages: |
| 84 | + |
| 85 | +#### Python (pytest) |
| 86 | +```bash |
| 87 | +pytest --cov --cov-report=xml |
| 88 | +``` |
| 89 | + |
| 90 | +#### JavaScript/TypeScript (Jest) |
| 91 | +```bash |
| 92 | +jest --coverage --coverageReporters=cobertura |
| 93 | +``` |
| 94 | + |
| 95 | +#### Java (Maven) |
| 96 | +```bash |
| 97 | +mvn test jacoco:report |
| 98 | +``` |
| 99 | + |
| 100 | +#### Go |
| 101 | +```bash |
| 102 | +go test -coverprofile=coverage.out ./... |
| 103 | +gocov convert coverage.out | gocov-xml > coverage.xml |
| 104 | +``` |
| 105 | + |
| 106 | +### 2. Add Secrets |
| 107 | + |
| 108 | +Add your CodeAnt AI access token to your repository secrets: |
| 109 | +1. Go to your repository Settings |
| 110 | +2. Navigate to Secrets and variables → Actions |
| 111 | +3. Click "New repository secret" |
| 112 | +4. Name: `CODEANT_ACCESS_TOKEN` |
| 113 | +5. Value: Your CodeAnt AI access token |
| 114 | + |
| 115 | +### 3. Configure Workflow |
| 116 | + |
| 117 | +Add the action to your GitHub Actions workflow as shown in the usage examples above. |
| 118 | + |
| 119 | +## How It Works |
| 120 | + |
| 121 | +1. The action fetches the latest coverage upload script from CodeAnt AI |
| 122 | +2. Decodes and prepares the script for execution |
| 123 | +3. Uploads your coverage report along with commit and branch information |
| 124 | +4. CodeAnt AI processes the report and provides analysis |
| 125 | + |
| 126 | +## Troubleshooting |
| 127 | + |
| 128 | +### Coverage file not found |
| 129 | +Ensure the `coverage_file` path is correct and the file exists before running this action. |
| 130 | + |
| 131 | +### Authentication failed |
| 132 | +Verify that your `CODEANT_ACCESS_TOKEN` is valid and has the necessary permissions. |
| 133 | + |
| 134 | +### Script execution failed |
| 135 | +Check that the CodeAnt AI API is accessible from your runner environment. |
| 136 | + |
| 137 | +## Contributing |
| 138 | + |
| 139 | +Contributions are welcome! Please feel free to submit a Pull Request. |
| 140 | + |
| 141 | +## License |
| 142 | + |
| 143 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 144 | + |
| 145 | +## Support |
| 146 | + |
| 147 | + |
| 148 | +- 📚 Documentation: https://docs.codeant.ai |
| 149 | +- 🐛 Issues: https://github.com/CodeAnt-AI/codeant-coverage-action/issues |
| 150 | + |
| 151 | +## Related |
| 152 | + |
| 153 | +- [CodeAnt AI](https://codeant.ai) - AI-powered code analysis platform |
| 154 | +- [GitHub Actions Documentation](https://docs.github.com/en/actions) |
0 commit comments