Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide flags #361

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/samples/main-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
if-no-files-found: error

- name: Create Code Coverage Badge
uses: dkhunt27/nx-code-coverage@v1
uses: dkhunt27/nx-code-coverage@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
no-coverage-ran: false
Expand All @@ -66,3 +66,5 @@ jobs:
gist-id: SOME_GIST_ID
color: green
named-logo: jest
hide-coverage-reports: false
hide-unchanged: false
4 changes: 3 additions & 1 deletion .github/samples/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
continue-on-error: true

- name: Comment Code Coverage on PR
uses: dkhunt27/nx-code-coverage@v1
uses: dkhunt27/nx-code-coverage@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
no-coverage-ran: false
Expand All @@ -73,4 +73,6 @@ jobs:
gist-id: SOME_GIST_ID
color: green
named-logo: jest
hide-coverage-reports: false
hide-unchanged: false

8 changes: 3 additions & 5 deletions .npmcheckrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"depcheck":
{
"ignoreMatches":
[
"depcheck": {
"ignoreMatches": [
"@types/*",
"npm-check-pr397",
"@jest/globals",
"yorkie"
]
}
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ The report is based on the coverage report generated by your test runner.
cache-seconds:
description: 'The cache lifetime in seconds (must be greater than 300)'
required: false
hide-coverage-reports:
description: true/false to hide the coverage reports
type: boolean
required: true
hide-unchanged:
description: true/false to hide the coverage results that have no diffs
type: boolean
required: true
```

## Setup
Expand All @@ -79,7 +87,7 @@ The report is based on the coverage report generated by your test runner.

```yaml
- name: Comment Code Coverage on PR
uses: dkhunt27/nx-code-coverage@v1
uses: dkhunt27/nx-code-coverage@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
no-coverage-ran: false
Expand All @@ -90,6 +98,8 @@ The report is based on the coverage report generated by your test runner.
gist-id: d7e6b443a01eba615fd2a7c1215aec91
color: green
named-logo: jest
hide-coverage-reports: false
hide-unchanged: false
```

- See sample workflows
Expand Down
33 changes: 33 additions & 0 deletions __tests__/__snapshots__/comment.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`comment tests buildComment when hiding coverage reports when hiding unchanged when all results in one then return as expected 1`] = `"Code Coverage:<p></p><table><tbody><tr><th>app diff -</th><th>50.00%</th><th>❌ ▾ -25.00%</th></tr></tbody></table> <br/><table><tbody><tr><th>app diff +</th><th>50.00%</th><th>✅ ▴ +25.00%</th></tr></tbody></table> <br/><table><tbody><tr><th>app diff null</th><th>unknown%</th></tr></tbody></table> <br/>"`;

exports[`comment tests buildComment when hiding coverage reports when hiding unchanged when result coverage is undefined then unknown diff in code coverage comment 1`] = `"Code Coverage:<p></p><table><tbody><tr><th>app A</th><th>unknown%</th></tr></tbody></table> <br/>"`;

exports[`comment tests buildComment when hiding coverage reports when hiding unchanged when result diff is 0 then no code coverage comment 1`] = `"Code Coverage:<p></p>"`;

exports[`comment tests buildComment when hiding coverage reports when hiding unchanged when result diff is negative then negative diff in code coverage comment 1`] = `"Code Coverage:<p></p><table><tbody><tr><th>app A</th><th>50.00%</th><th>❌ ▾ -25.00%</th></tr></tbody></table> <br/>"`;

exports[`comment tests buildComment when hiding coverage reports when hiding unchanged when result diff is positive then positive diff in code coverage comment 1`] = `"Code Coverage:<p></p><table><tbody><tr><th>app A</th><th>50.00%</th><th>✅ ▴ +25.00%</th></tr></tbody></table> <br/>"`;

exports[`comment tests buildComment when hiding coverage reports when not hiding unchanged when all results in one then return as expected 1`] = `"Code Coverage:<p></p><table><tbody><tr><th>app diff 0</th><th>50.00%</th><th>✅ 0.00%</th></tr></tbody></table> <br/><table><tbody><tr><th>app diff -</th><th>50.00%</th><th>❌ ▾ -25.00%</th></tr></tbody></table> <br/><table><tbody><tr><th>app diff +</th><th>50.00%</th><th>✅ ▴ +25.00%</th></tr></tbody></table> <br/><table><tbody><tr><th>app diff null</th><th>unknown%</th></tr></tbody></table> <br/>"`;

exports[`comment tests buildComment when hiding coverage reports when not hiding unchanged when result coverage is undefined then unknown diff in code coverage comment 1`] = `"Code Coverage:<p></p><table><tbody><tr><th>app A</th><th>unknown%</th></tr></tbody></table> <br/>"`;

exports[`comment tests buildComment when hiding coverage reports when not hiding unchanged when result diff is 0 then 0 diff in code coverage comment 1`] = `"Code Coverage:<p></p><table><tbody><tr><th>app A</th><th>50.00%</th><th>✅ 0.00%</th></tr></tbody></table> <br/>"`;

exports[`comment tests buildComment when hiding coverage reports when not hiding unchanged when result diff is negative then negative diff in code coverage comment 1`] = `"Code Coverage:<p></p><table><tbody><tr><th>app A</th><th>50.00%</th><th>❌ ▾ -25.00%</th></tr></tbody></table> <br/>"`;

exports[`comment tests buildComment when hiding coverage reports when not hiding unchanged when result diff is positive then positive diff in code coverage comment 1`] = `"Code Coverage:<p></p><table><tbody><tr><th>app A</th><th>50.00%</th><th>✅ ▴ +25.00%</th></tr></tbody></table> <br/>"`;

exports[`comment tests buildComment when not hiding coverage reports when all results in one then return as expected 1`] = `
"Code Coverage:<p></p><table><tbody><tr><th>app diff 0</th><th>50.00%</th><th>✅ 0.00%</th></tr></tbody></table>

<details><summary>Coverage Report</summary><table><tbody><tr><th>File </th><th> % Stmts </th><th> % Branch </th><th> % Funcs </th><th> % Lines </th><th> Uncovered Line #s </th></tr><tr><td>All&nbsp;files </td><td>&nbsp; 96.42 </td><td>&nbsp; 60 </td><td>&nbsp; 96.66 </td><td>&nbsp; 96.59 </td><td>&nbsp; </td></tr></tbody></table></details> <br/><table><tbody><tr><th>app diff -</th><th>50.00%</th><th>❌ ▾ -25.00%</th></tr></tbody></table>

<details><summary>Coverage Report</summary><table><tbody><tr><th>File </th><th> % Stmts </th><th> % Branch </th><th> % Funcs </th><th> % Lines </th><th> Uncovered Line #s </th></tr><tr><td>All&nbsp;files </td><td>&nbsp; 96.42 </td><td>&nbsp; 60 </td><td>&nbsp; 96.66 </td><td>&nbsp; 96.59 </td><td>&nbsp; </td></tr></tbody></table></details> <br/><table><tbody><tr><th>app diff +</th><th>50.00%</th><th>✅ ▴ +25.00%</th></tr></tbody></table>

<details><summary>Coverage Report</summary><table><tbody><tr><th>File </th><th> % Stmts </th><th> % Branch </th><th> % Funcs </th><th> % Lines </th><th> Uncovered Line #s </th></tr><tr><td>All&nbsp;files </td><td>&nbsp; 96.42 </td><td>&nbsp; 60 </td><td>&nbsp; 96.66 </td><td>&nbsp; 96.59 </td><td>&nbsp; </td></tr></tbody></table></details> <br/><table><tbody><tr><th>app diff null</th><th>unknown%</th></tr></tbody></table>

<details><summary>Coverage Report</summary><table><tbody><tr><th>File </th><th> % Stmts </th><th> % Branch </th><th> % Funcs </th><th> % Lines </th><th> Uncovered Line #s </th></tr><tr><td>All&nbsp;files </td><td>&nbsp; 96.42 </td><td>&nbsp; 60 </td><td>&nbsp; 96.66 </td><td>&nbsp; 96.59 </td><td>&nbsp; </td></tr></tbody></table></details> <br/>"
`;
Loading
Loading