|
1 | | -<p align="center"> |
2 | | - <a href="https://github.com/actions/typescript-action/actions"><img alt="typescript-action status" src="https://github.com/actions/typescript-action/workflows/build-test/badge.svg"></a> |
3 | | -</p> |
| 1 | +# Code Coverage Summary |
| 2 | + |
| 3 | +A GitHub Action that reads Clover format code coverage files from your test |
| 4 | +suite and outputs a markdown summary. This summary can be posted as a Pull |
| 5 | +Request comment or included in Release Notes by other actions to give you an |
| 6 | +immediate insight into the health of your code without using a third-party site. |
| 7 | +Code Coverage Summary is designed for use with any test framework that outputs |
| 8 | +coverage in Clover XML format. |
| 9 | +The action has a build in feature to group coverage by package. This currently |
| 10 | +works with composer.json only. |
| 11 | + |
| 12 | +## Inputs |
| 13 | + |
| 14 | +### `filename` |
| 15 | +**Required** |
| 16 | + |
| 17 | +A path to the code coverage file to analyse. Also supports using glob patterns to match multiple files. If there are any spaces in a path or filename this value must be in quotes. |
| 18 | + |
| 19 | + |
| 20 | +## Outputs |
| 21 | + |
| 22 | + |
| 23 | +### Markdown Example |
| 24 | + |
| 25 | +<table> |
| 26 | + <tr> |
| 27 | + <th colspan="8">Code Coverage |
| 28 | + <tr> |
| 29 | + <th colspan="1">Package |
| 30 | + <th colspan="2">Lines |
| 31 | + <th colspan="2">Functions |
| 32 | + <th colspan="2">Classes |
| 33 | + <th colspan="1">Health |
| 34 | + <tr> |
| 35 | + <td>unknown |
| 36 | + <td align="center">96% |
| 37 | + <td align="right">26/27 |
| 38 | + <td align="center">83% |
| 39 | + <td align="right">5/6 |
| 40 | + <td align="center">93% |
| 41 | + <td align="right">31/33 |
| 42 | + <td align="center">✅ |
| 43 | + <tr> |
| 44 | + <td><strong>Summary |
| 45 | + <td align="center"><strong>96% |
| 46 | + <td align="right"><strong>26/27 |
| 47 | + <td align="center"><strong>83% |
| 48 | + <td align="right"><strong>5/6 |
| 49 | + <td align="center"><strong>93% |
| 50 | + <td align="right"><strong>31/33 |
| 51 | + <td align="center"><strong>✅ |
| 52 | + </table> |
| 53 | +<details> |
| 54 | + <summary>Code Coverage details</summary> |
| 55 | + <table> |
| 56 | + <tr> |
| 57 | + <th colspan="8">Code Coverage |
| 58 | + <tr> |
| 59 | + <th colspan="1">Class |
| 60 | + <th colspan="2">Lines |
| 61 | + <th colspan="2">Functions |
| 62 | + <th colspan="2">Classes |
| 63 | + <th colspan="1">Health |
| 64 | + <tr> |
| 65 | + <td colspan="8"><strong>unknown |
| 66 | + <tr> |
| 67 | + <td>Netlogix\Nxdummy\Exception\OptionNotFoundException |
| 68 | + <td align="center">NaN% |
| 69 | + <td align="right">0/0 |
| 70 | + <td align="center">NaN% |
| 71 | + <td align="right">0/0 |
| 72 | + <td align="center">NaN% |
| 73 | + <td align="right">0/0 |
| 74 | + <td align="center">❌ |
| 75 | +<tr> |
| 76 | + <td>Netlogix\Nxdummy\Options\MiddlewareOptions |
| 77 | + <td align="center">90% |
| 78 | + <td align="right">10/11 |
| 79 | + <td align="center">66% |
| 80 | + <td align="right">2/3 |
| 81 | + <td align="center">85% |
| 82 | + <td align="right">12/14 |
| 83 | + <td align="center">✅ |
| 84 | +<tr> |
| 85 | + <td>Netlogix\Nxdummy\Utility\UriUtility |
| 86 | + <td align="center">100% |
| 87 | + <td align="right">16/16 |
| 88 | + <td align="center">100% |
| 89 | + <td align="right">3/3 |
| 90 | + <td align="center">100% |
| 91 | + <td align="right">19/19 |
| 92 | + <td align="center">🚀 |
| 93 | + <tr> |
| 94 | + <td><strong>Summary |
| 95 | + <td align="center"><strong>96% |
| 96 | + <td align="right"><strong>26/27 |
| 97 | + <td align="center"><strong>83% |
| 98 | + <td align="right"><strong>5/6 |
| 99 | + <td align="center"><strong>93% |
| 100 | + <td align="right"><strong>31/33 |
| 101 | + <td align="center"><strong>✅ |
| 102 | + </table> |
| 103 | + </details> |
| 104 | + |
| 105 | +## Usage |
4 | 106 |
|
5 | | -# Create a JavaScript Action using TypeScript |
6 | | - |
7 | | -Use this template to bootstrap the creation of a TypeScript action.:rocket: |
8 | | - |
9 | | -This template includes compilation support, tests, a validation workflow, publishing, and versioning guidance. |
10 | | - |
11 | | -If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action) |
12 | | - |
13 | | -## Create an action from this template |
14 | | - |
15 | | -Click the `Use this Template` and provide the new repo details for your action |
16 | | - |
17 | | -## Code in Main |
18 | | - |
19 | | -> First, you'll need to have a reasonably modern version of `node` handy. This won't work with versions older than 9, for instance. |
20 | | -
|
21 | | -Install the dependencies |
22 | | -```bash |
23 | | -$ npm install |
| 107 | +```yaml |
| 108 | +name: Code Coverage Summary Report |
| 109 | +uses: saschanowak/CloverCodeCoverageSummary@v0.1.0 |
| 110 | +with: |
| 111 | + filename: clover.xml |
24 | 112 | ``` |
25 | 113 |
|
26 | | -Build the typescript and package it for distribution |
27 | | -```bash |
28 | | -$ npm run build && npm run package |
| 114 | +Add the following to your workflow to include the summary in the job summary: |
| 115 | +```yaml |
| 116 | +name: 'Add Code Coverage to Job Summary' |
| 117 | +run: cat code-coverage-results-merged.md >> $GITHUB_STEP_SUMMARY |
29 | 118 | ``` |
30 | 119 |
|
31 | | -Run the tests :heavy_check_mark: |
32 | | -```bash |
33 | | -$ npm test |
34 | | - |
35 | | - PASS ./index.test.js |
36 | | - ✓ throws invalid number (3ms) |
37 | | - ✓ wait 500 ms (504ms) |
38 | | - ✓ test runs (95ms) |
39 | | - |
40 | | -... |
| 120 | +Add the following to your workflow to post the summary as a Pull Request comment: |
| 121 | +```yaml |
| 122 | +name: 'Add Code Coverage as PR Comment' |
| 123 | +uses: marocchino/sticky-pull-request-comment@v2 |
| 124 | +if: github.event_name == 'pull_request' |
| 125 | +with: |
| 126 | + recreate: true |
| 127 | + path: code-coverage-results-merged.md |
41 | 128 | ``` |
42 | 129 |
|
43 | | -## Change action.yml |
| 130 | +## Version Numbers |
44 | 131 |
|
45 | | -The action.yml defines the inputs and output for your action. |
| 132 | +Version numbers will be assigned according to the [Semantic Versioning](https://semver.org/) scheme. |
| 133 | +This means, given a version number MAJOR.MINOR.PATCH, we will increment the: |
46 | 134 |
|
47 | | -Update the action.yml with your name, description, inputs and outputs for your action. |
| 135 | +1. MAJOR version when we make incompatible API changes |
| 136 | +2. MINOR version when we add functionality in a backwards compatible manner |
| 137 | +3. PATCH version when we make backwards compatible bug fixes |
48 | 138 |
|
49 | | -See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions) |
50 | 139 |
|
51 | | -## Change the Code |
| 140 | +## Contributing |
52 | 141 |
|
53 | | -Most toolkit and CI/CD operations involve async operations so the action is run in an async function. |
| 142 | +### Report Bugs |
54 | 143 |
|
55 | | -```javascript |
56 | | -import * as core from '@actions/core'; |
57 | | -... |
| 144 | +Please make sure the bug is not already reported by searching existing [issues]. |
58 | 145 |
|
59 | | -async function run() { |
60 | | - try { |
61 | | - ... |
62 | | - } |
63 | | - catch (error) { |
64 | | - core.setFailed(error.message); |
65 | | - } |
66 | | -} |
| 146 | +If you're unable to find an existing issue addressing the problem please [open a new one][new-issue]. Be sure to include a title and clear description, as much relevant information as possible, a workflow sample and any logs demonstrating the problem. |
67 | 147 |
|
68 | | -run() |
69 | | -``` |
70 | 148 |
|
71 | | -See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages. |
| 149 | +### Suggest an Enhancement |
72 | 150 |
|
73 | | -## Publish to a distribution branch |
| 151 | +Please [open a new issue][new-issue]. |
74 | 152 |
|
75 | | -Actions are run from GitHub repos so we will checkin the packed dist folder. |
76 | 153 |
|
77 | | -Then run [ncc](https://github.com/zeit/ncc) and push the results: |
78 | | -```bash |
79 | | -$ npm run package |
80 | | -$ git add dist |
81 | | -$ git commit -a -m "prod dependencies" |
82 | | -$ git push origin releases/v1 |
83 | | -``` |
| 154 | +### Submit a Pull Request |
84 | 155 |
|
85 | | -Note: We recommend using the `--license` option for ncc, which will create a license file for all of the production node modules used in your project. |
| 156 | +Discuss your idea first, so that your changes have a good chance of being merged in. |
86 | 157 |
|
87 | | -Your action is now published! :rocket: |
| 158 | +Submit your pull request against the `main` branch. |
88 | 159 |
|
89 | | -See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) |
| 160 | +Pull requests that include documentation and relevant updates to README.md are merged faster, because you won't have to wait for somebody else to complete your contribution. |
90 | 161 |
|
91 | | -## Validate |
92 | | - |
93 | | -You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml)) |
94 | | - |
95 | | -```yaml |
96 | | -uses: ./ |
97 | | -with: |
98 | | - milliseconds: 1000 |
99 | | -``` |
100 | 162 |
|
101 | | -See the [actions tab](https://github.com/actions/typescript-action/actions) for runs of this action! :rocket: |
| 163 | +## License |
102 | 164 |
|
103 | | -## Usage: |
| 165 | +Code Coverage Summary is available under the MIT license, see the [LICENSE](LICENSE) file for more info. |
104 | 166 |
|
105 | | -After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action |
| 167 | +[issues]: https://github.com/irongut/CodeCoverageSummary/issues |
| 168 | +[new-issue]: https://github.com/irongut/CodeCoverageSummary/issues/new |
0 commit comments