@@ -9,6 +9,7 @@ A GitHub Action that automatically creates beautiful coverage reports in pull re
99- 📁 ** File-level Details** : Option to show individual file coverage breakdowns
1010- 🔄 ** Smart Updates** : Updates existing comments instead of creating duplicates
1111- 🎨 ** Visual Indicators** : Uses emojis to quickly identify coverage status
12+ - 🏷️ ** Coverage Badges** : Generates shields.io compatible badges for GitHub Pages
1213- ⚡ ** Lightweight** : Fast execution with minimal dependencies
1314
1415## Usage
@@ -80,17 +81,19 @@ jobs:
8081 title : " 🧪 Test Coverage Report"
8182 show-files : " true"
8283 coverage-threshold : " 90"
84+ make-badges : " true"
8385` ` `
8486
8587## Inputs
8688
87- | Input | Description | Required | Default |
88- | -------------------- | ------------------------------------------------------- | -------- | -------------------------------- |
89- | ` coverage-file` | Path to the coverage summary JSON file | No | `coverage/coverage-summary.json` |
90- | `token` | GitHub token for creating comments | No | `${{ github.token }}` |
91- | `title` | Title for the coverage report comment | No | `📊 Coverage Report` |
92- | `show-files` | Whether to show individual file coverage details | No | `true` |
93- | `coverage-threshold` | Minimum coverage percentage to consider as good (0-100) | No | `80` |
89+ | Input | Description | Required | Default |
90+ | -------------------- | --------------------------------------------------------- | -------- | -------------------------------- |
91+ | ` coverage-file` | Path to the coverage summary JSON file | No | `coverage/coverage-summary.json` |
92+ | `token` | GitHub token for creating comments | No | `${{ github.token }}` |
93+ | `title` | Title for the coverage report comment | No | `📊 Coverage Report` |
94+ | `show-files` | Whether to show individual file coverage details | No | `true` |
95+ | `coverage-threshold` | Minimum coverage percentage to consider as good (0-100) | No | `80` |
96+ | `make-badges` | Whether to generate coverage badges in a badges directory | No | `true` |
9497
9598# # Coverage File Format
9699
@@ -182,3 +185,49 @@ Contributions are welcome! Please feel free to submit a Pull Request.
182185## License
183186
184187MIT License - see the [ LICENSE] ( LICENSE ) file for details.
188+
189+ ## Coverage Badges
190+
191+ When ` make-badges ` is enabled (default: ` true ` ), the action creates a ` badges ` directory with shields.io compatible JSON files:
192+
193+ ### Generated Badges
194+
195+ - ` badges/coverage.json ` - Overall coverage percentage
196+ - ` badges/statements.json ` - Statement coverage
197+ - ` badges/branches.json ` - Branch coverage
198+ - ` badges/functions.json ` - Function coverage
199+ - ` badges/lines.json ` - Line coverage
200+
201+ ### Badge Colors
202+
203+ - 🟢 ** Bright Green** : 90% or higher
204+ - 🟢 ** Green** : 80-89%
205+ - 🟡 ** Yellow** : 70-79%
206+ - 🟠 ** Orange** : 60-69%
207+ - 🔴 ** Red** : Below 60%
208+
209+ ### Using Badges with GitHub Pages
210+
211+ 1 . Enable GitHub Pages in your repository settings
212+ 2 . Set the source to "Deploy from a branch" and select your main branch
213+ 3 . The badges will be available at:
214+
215+ ```
216+ https://yourusername.github.io/yourrepo/badges/coverage.json
217+ ```
218+
219+ 4 . Use in your README.md:
220+ ``` markdown
221+ 
222+ ```
223+
224+ ### Example Badge JSON
225+
226+ ``` json
227+ {
228+ "schemaVersion" : 1 ,
229+ "label" : " coverage" ,
230+ "message" : " 89.8%" ,
231+ "color" : " green"
232+ }
233+ ```
0 commit comments