Skip to content

Commit

Permalink
Hide comment (#19)
Browse files Browse the repository at this point in the history
* eslint update

* add hide comment

* update readme & version
  • Loading branch information
MishaKav authored Jul 26, 2021
1 parent 2cb7a17 commit 21fd3ae
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/live-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

- name: Pytest coverage comment
id: coverageComment
uses: MishaKav/[email protected].5
uses: MishaKav/[email protected].6
with:
pytest-coverage-path: ./data/pytest-coverage_4.txt
junitxml-path: ./data/pytest_1.xml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/multiple-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- uses: actions/checkout@v2

- name: Pytest coverage comment
uses: MishaKav/[email protected].5
uses: MishaKav/[email protected].6
with:
multiple-files: |
My Title 1, ./data/pytest-coverage_3.txt, ./data/pytest_1.xml
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You can add this action to your GitHub workflow for Ubuntu runners (e.g. runs-on

```yaml
- name: Pytest coverage comment
uses: MishaKav/[email protected].5
uses: MishaKav/[email protected].6
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
Expand All @@ -27,6 +27,7 @@ You can add this action to your GitHub workflow for Ubuntu runners (e.g. runs-on
| `junitxml-path` | | '' | The location of the junitxml path |
| `junitxml-title` | | '' | Title for summary for junitxml |
| `create-new-comment` | | false | When false, will update the same comment, otherwise will publish new comment on each run. |
| `hide-comment` | | false | Hide the whole comment (use when you need only the `output`). Useful for auto-update bagdes in readme. See the [workflow](../main/.github/workflows/main.yml) for example |
| `multiple-files` | | '' | You can pass array of titles and files to generate single comment with table of results.<br/>Single line should look like `Title, ./path/to/pytest-coverage.txt, ./path/to/pytest.xml`<br/> example:<br/> `My Title 1, ./data/pytest-coverage_3.txt, ./data/pytest_1.xml`<br/>**Note:** In that mode the `output` for `coverage` and `color` will be for the first file only. |

## Output example
Expand Down Expand Up @@ -71,7 +72,7 @@ jobs:
pytest --junitxml=pytest.xml --cov=app tests/ | tee pytest-coverage.txt
- name: Pytest coverage comment
uses: MishaKav/[email protected].5
uses: MishaKav/[email protected].6
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
Expand All @@ -82,7 +83,7 @@ Example GitHub Action workflow that uses coverage percentage as output (see the
```yaml
- name: Pytest coverage comment
id: coverageComment
uses: MishaKav/[email protected].5
uses: MishaKav/[email protected].6
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
Expand All @@ -97,14 +98,15 @@ Example GitHub Action workflow that passes all params to Pytest Coverage Comment

```yaml
- name: Pytest coverage comment
uses: MishaKav/[email protected].5
uses: MishaKav/[email protected].6
with:
pytest-coverage-path: ./path-to-file/pytest-coverage.txt
title: My Coverage Report Title
badge-title: My Badge Coverage Title
hide-badge: false
hide-report: false
create-new-comment: false
hide-comment: false
junitxml-path: ./path-to-file/pytest.xml
junitxml-title: My JUnit Xml Summary Title
```
Expand All @@ -120,7 +122,7 @@ It will generate `pytest-coverage.txt` and `pytest.xml` in `/tmp` directory insi
docker run -v /tmp:/tmp $IMAGE_TAG python3 -m pytest --cov-report=term-missing:skip-covered --junitxml=/tmp/pytest.xml --cov=src tests/ | tee /tmp/pytest-coverage.txt
- name: Pytest coverage comment
uses: MishaKav/[email protected].5
uses: MishaKav/[email protected].6
with:
pytest-coverage-path: /tmp/pytest-coverage.txt
junitxml-path: /tmp/pytest.xml
Expand All @@ -130,7 +132,7 @@ Example GitHub Action workflow that uses multiple files mode (see the [live work

```yaml
- name: Pytest coverage comment
uses: MishaKav/[email protected].5
uses: MishaKav/[email protected].6
with:
multiple-files: |
My Title 1, ./data/pytest-coverage_3.txt, ./data/pytest_1.xml
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ inputs:
description: 'Hide coverage report'
default: 'false'
required: false
hide-comment:
description: 'Hide the whole comment (use when you need only `output`)'
default: 'false'
required: false
junitxml-path:
description: 'The location of the junitxml path'
default: ''
Expand Down
4 changes: 3 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13278,6 +13278,7 @@ const main = async () => {
const createNewComment = core.getBooleanInput('create-new-comment', {
required: false,
});
const hideComment = core.getBooleanInput('hide-comment', { required: false });
const covFile = core.getInput('pytest-coverage-path', { required: false });
const xmlFile = core.getInput('junitxml-path', { required: false });
const xmlTitle = core.getInput('junitxml-title', { required: false });
Expand All @@ -13299,6 +13300,7 @@ const main = async () => {
hideBadge,
hideReport,
createNewComment,
hideComment,
xmlTitle,
multipleFiles,
};
Expand Down Expand Up @@ -13342,7 +13344,7 @@ const main = async () => {
}
}

if (!finalHtml) {
if (!finalHtml || options.hideComment) {
console.log('Nothing to report');
return;
}
Expand Down
93 changes: 47 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pytest-coverage-comment",
"version": "1.1.5",
"version": "1.1.6",
"description": "Comments a pull request with the pytest code coverage badge, full report and tests summary",
"author": "Misha Kav",
"license": "MIT",
Expand Down Expand Up @@ -29,7 +29,7 @@
},
"devDependencies": {
"@vercel/ncc": "^0.29.0",
"eslint": "^7.30.0",
"eslint": "^7.31.0",
"prettier": "^2.3.2"
},
"prettier": {
Expand Down
3 changes: 2 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const main = async () => {
hideBadge: false,
hideReport: true,
createNewComment: false,
hideComment: false,
xmlTitle: '',
multipleFiles,
};
Expand All @@ -68,7 +69,7 @@ const main = async () => {
finalHtml += finalHtml.length ? `\n\n${summaryReport}` : summaryReport;
}

if (!finalHtml) {
if (!finalHtml || options.hideComment) {
console.log('Nothing to report');
return;
}
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const main = async () => {
const createNewComment = core.getBooleanInput('create-new-comment', {
required: false,
});
const hideComment = core.getBooleanInput('hide-comment', { required: false });
const covFile = core.getInput('pytest-coverage-path', { required: false });
const xmlFile = core.getInput('junitxml-path', { required: false });
const xmlTitle = core.getInput('junitxml-title', { required: false });
Expand All @@ -36,6 +37,7 @@ const main = async () => {
hideBadge,
hideReport,
createNewComment,
hideComment,
xmlTitle,
multipleFiles,
};
Expand Down Expand Up @@ -79,7 +81,7 @@ const main = async () => {
}
}

if (!finalHtml) {
if (!finalHtml || options.hideComment) {
console.log('Nothing to report');
return;
}
Expand Down

0 comments on commit 21fd3ae

Please sign in to comment.