Skip to content

Commit 72693aa

Browse files
feat: document barecheck application usage (#78)
* add barecheck app token input * use github application token * build new version * fix sinfle line text * add input test * impove input args coverage * update images and add docs about uncovered lines * comment one test * revert
1 parent d20aa5e commit 72693aa

File tree

12 files changed

+60
-27
lines changed

12 files changed

+60
-27
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@ jobs:
5353
id: code-coverage
5454
uses: ./
5555
with:
56-
github-token: ${{ secrets.GITHUB_TOKEN }}
56+
barecheck-github-app-token: ${{ secrets.BARECHECK_GITHUB_APP_TOKEN }}
5757
lcov-file: "./coverage/lcov.info"
5858
base-lcov-file: "./lcov.info"
5959
minimum-ratio: 0
6060
send-summary-comment: true
6161
show-annotations: "warning"
62-
env:
63-
BARECHECK_GITHUB_APP_TOKEN: ${{ secrets.BARECHECK_GITHUB_APP_TOKEN }}

README.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,29 @@
22

33
GitHub Action that generates coverage reports
44

5-
![code coverage report](./docs/img/barecheck-comment.png)
5+
![code coverage report success](./docs/img/barecheck-comment-success.png)
66

77
## Show annotations
88

99
As a part of code coverage report action also enable an ability to show annotations along with changed lines to keep control what is covered with tests without interapting review process
1010

1111
![show annotations](./docs/img/show-annotations.png)
1212

13+
## Show uncovered files
14+
15+
In the rea; world, it's hard to get 100% code coverage and keep it all the time. Instead of showing you all uncovered files Barecheck show only the ones you have changed.
16+
![code coverage report](./docs/img/barecheck-comment-fail.png)
17+
1318
## Usage
1419

1520
To integrate with this Github Action, you can just use following configuration in your already created workflow. As a result you will get Github Pull request comment with total code coverage
1621

1722
```yml
1823
- name: Generate Code Coverage report
1924
id: code-coverage
20-
uses: barecheck/code-coverage-action@v0.3.3
25+
uses: barecheck/code-coverage-action@v0.4.0
2126
with:
22-
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
barecheck-github-app-token: ${{ secrets.BARECHECK_GITHUB_APP_TOKEN }}
2328
lcov-file: "./coverage/lcov.info"
2429
base-lcov-file: "./coverage/base-lcov.info"
2530
send-summary-comment: true
@@ -30,14 +35,15 @@ To integrate with this Github Action, you can just use following configuration i
3035
3136
## Inputs
3237
33-
| Key | Required | Default | Description |
34-
| ---------------------- | -------- | --------- | ----------------------------------------------------------------------------------------------------------------- |
35-
| `github-token` | **yes** | - | Your Github token that would be used to send summary comment |
36-
| `lcov-file` | **yes** | - | Lcov.info file that was generated after your test coverage command |
37-
| `base-lcov-file` | **yes** | - | Lcov.info file that would be used for code coverage |
38-
| `send-summary-comment` | **no** | true | Option to send Github code coverage comment based on the changes that were made in PR |
39-
| `show-annotations` | **no** | 'warning' | Option to enable Github anotation that would show uncovered files in review tab. Options: ' ' \| warning \| error |
40-
| `minimum-ratio` | **no** | '' | Percantage of uncovered lines that is allowed for new changes |
38+
| Key | Required | Default | Description |
39+
| ---------------------------- | -------- | --------- | ----------------------------------------------------------------------------------------------------------------- |
40+
| `github-token` | **no** | - | **DEPRECATED\*** Install application and use `barecheck-github-app-token` instead |
41+
| `barecheck-github-app-token` | **yes** | - | Barecheck application token, received after application installation comment |
42+
| `lcov-file` | **yes** | - | Lcov.info file that was generated after your test coverage command |
43+
| `base-lcov-file` | **yes** | - | Lcov.info file that would be used for code coverage |
44+
| `send-summary-comment` | **no** | true | Option to send Github code coverage comment based on the changes that were made in PR |
45+
| `show-annotations` | **no** | 'warning' | Option to enable Github anotation that would show uncovered files in review tab. Options: ' ' \| warning \| error |
46+
| `minimum-ratio` | **no** | '' | Percantage of uncovered lines that is allowed for new changes |
4147

4248
## Workflow Example
4349

@@ -96,9 +102,9 @@ jobs:
96102
# Compares two code coverage files and generates report as a comment
97103
- name: Generate Code Coverage report
98104
id: code-coverage
99-
uses: barecheck/code-coverage-action@v0.3.3
105+
uses: barecheck/code-coverage-action@v0.4.0
100106
with:
101-
github-token: ${{ secrets.GITHUB_TOKEN }}
107+
barecheck-github-app-token: ${{ secrets.BARECHECK_GITHUB_APP_TOKEN }}
102108
lcov-file: "./coverage/lcov.info"
103109
base-lcov-file: "./lcov.info"
104110
minimum-ratio: 0 # Fails Github action once code coverage is decreasing

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ branding:
66
inputs:
77
github-token:
88
description: Your GitHub secret token
9+
deprecationMessage: The token will be deprecated in the next versions, please install app and use `barecheck-github-app-token` instead
10+
required: false
11+
barecheck-github-app-token:
12+
description: Barecheck application token, received after application installation
913
required: true
1014
lcov-file:
1115
description: "Compare code coverage report"

dist/index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10024,11 +10024,15 @@ const showAnnotations = async (compareFileData) => {
1002410024
);
1002510025

1002610026
fileLinesWithChangedFiles.forEach(({ file, lines }) => {
10027-
const formattedLines = lines
10028-
.map((line) => (Array.isArray(line) ? line.join("-") : line))
10029-
.join(", ");
10027+
const linesToDisplay = lines.map((line) =>
10028+
Array.isArray(line) ? line.join("-") : line
10029+
);
10030+
10031+
const linesWord = linesToDisplay.length === 1 ? "line is" : "lines are";
10032+
10033+
const formattedLines = linesToDisplay.join(", ");
1003010034

10031-
const message = `file=${file}::${formattedLines} lines are not covered with tests`;
10035+
const message = `file=${file}::${formattedLines} ${linesWord} not covered with tests`;
1003210036

1003310037
// NOTE: consider an option to show lines directly by attaching 'line' param
1003410038
// Need to fix the issue where we consider 'empty line' as covered line
@@ -10351,7 +10355,8 @@ const getShowAnnotations = () => {
1035110355

1035210356
const getGithubToken = () => core.getInput("github-token");
1035310357

10354-
const getBarecheckGithubAppToken = () => process.env.BARECHECK_GITHUB_APP_TOKEN;
10358+
const getBarecheckGithubAppToken = () =>
10359+
core.getInput("barecheck-github-app-token");
1035510360

1035610361
module.exports = {
1035710362
getShowAnnotations,
90.5 KB
Loading
92.4 KB
Loading

docs/img/barecheck-comment.png

-85 KB
Binary file not shown.

docs/img/show-annotations.png

-56.2 KB
Loading

src/features/showAnnotations.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ const showAnnotations = async (compareFileData) => {
2222
);
2323

2424
fileLinesWithChangedFiles.forEach(({ file, lines }) => {
25-
const formattedLines = lines
26-
.map((line) => (Array.isArray(line) ? line.join("-") : line))
27-
.join(", ");
25+
const linesToDisplay = lines.map((line) =>
26+
Array.isArray(line) ? line.join("-") : line
27+
);
2828

29-
const message = `file=${file}::${formattedLines} lines are not covered with tests`;
29+
const linesWord = linesToDisplay.length === 1 ? "line is" : "lines are";
30+
31+
const formattedLines = linesToDisplay.join(", ");
32+
33+
const message = `file=${file}::${formattedLines} ${linesWord} not covered with tests`;
3034

3135
// NOTE: consider an option to show lines directly by attaching 'line' param
3236
// Need to fix the issue where we consider 'empty line' as covered line

src/input.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ const getShowAnnotations = () => {
2020

2121
const getGithubToken = () => core.getInput("github-token");
2222

23-
const getBarecheckGithubAppToken = () => process.env.BARECHECK_GITHUB_APP_TOKEN;
23+
const getBarecheckGithubAppToken = () =>
24+
core.getInput("barecheck-github-app-token");
2425

2526
module.exports = {
2627
getShowAnnotations,

0 commit comments

Comments
 (0)