|
2 | 2 |
|
3 | 3 | A GitHub action to comment on a commit on GitHub with a simple test coverage summary from Karma. |
4 | 4 |
|
5 | | -Repurposed from Commit Comment by Peter Evans |
6 | | - |
7 | | - |
8 | | -## Usage |
| 5 | +## Usage with Karma + Angular |
| 6 | +1. Add `"codeCoverage": true,` under test > options in angular.json |
| 7 | +2. In your karma.conf.js set coverageIstanbulReporter.reports to include `json-summary` and save it to the /coverage directory if using the sample setup below |
| 8 | +3. Use in your workflow as illustrated below: |
9 | 9 |
|
10 | 10 | ```yml |
11 | | - - name: Create commit comment |
12 | | - uses: jacobbowdoin/comment-test-coverage@v1 |
| 11 | +name: test-pull-request |
| 12 | +on: [pull_request] |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout Code |
| 18 | + uses: actions/checkout@v1 |
| 19 | + |
| 20 | + - name: Run Jasmine tests |
| 21 | + run: npm run test -- --no-watch --no-progress --browsers=ChromeHeadlessCI |
| 22 | + |
| 23 | + - name: Comment Test Coverage on Commit |
| 24 | + uses: jacobbowdoin/comment-test-coverage@1 |
13 | 25 | with: |
14 | 26 | token: ${{ secrets.GITHUB_TOKEN }} |
15 | | - body: | |
16 | | - This is a multi-line test comment |
17 | | - - With GitHub **Markdown** |
18 | | - - Created by [comment-test-coverage][1] |
19 | | -
|
20 | | - [1]: https://github.com/jacobbowdoin/comment-test-coverage |
| 27 | + path: coverage/coverage-summary.json |
21 | 28 | ``` |
22 | 29 |
|
23 | 30 | ## Parameters |
24 | 31 |
|
25 | | -- `token` (**required**) - The GitHub authentication token |
26 | | -- `body` (**required**) - The contents of the comment. |
27 | | - |
28 | | - |
29 | | -## Evaluating environment variables |
30 | | - |
31 | | -Environment variables can be evaluated in the `body` input as follows. |
| 32 | +- `token` (**required**) - The GitHub authentication token (workflows automatically set this for you, nothing needed here) |
| 33 | +- `path` (**required**) - Path to your coverage-summary.json file |
32 | 34 |
|
33 | | -```yml |
34 | | - - name: Create commit comment |
35 | | - uses: jacobbowdoin/comment-test-coverage@v1 |
36 | | - with: |
37 | | - token: ${{ secrets.GITHUB_TOKEN }} |
38 | | - body: | |
39 | | - My env var: ${process.env.MY_ENV_VAR} |
40 | | -``` |
41 | 35 |
|
42 | 36 | ## License |
43 | 37 |
|
|
0 commit comments