Skip to content

Commit cf70156

Browse files
authored
Merge pull request #1333 from mikepenz/feature/1319
Add option to disable commenting if no tests are detected
2 parents 6906ff8 + 49c307b commit cf70156

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ jobs:
113113
| `skip_annotations` | Optional. Setting this flag will result in no annotations being added to the run. Defaults to `false`. |
114114
| `truncate_stack_traces` | Optional. Truncate stack traces from test output to 2 lines in annotations. Defaults to `true`. |
115115
| `resolve_ignore_classname` | Optional. Force ignore test case classname from the xml report (This can help fix issues with some tools/languages). Defaults to `false`. |
116+
| `skip_comment_without_tests` | Optional. Disable commenting if no tests are detected. Defaults to `false`. |
116117

117118
### Common Configurations
118119

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ inputs:
156156
description: 'Force ignore test case classname from the xml report (This can help fix issues with some tools/languages)'
157157
required: false
158158
default: 'false'
159+
skip_comment_without_tests:
160+
description: 'Disable commenting if no tests are detected'
161+
required: false
162+
default: 'false'
159163
outputs:
160164
total:
161165
description: 'The total count of all checks'

dist/index.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export async function run(): Promise<void> {
4040
const comment = core.getInput('comment') === 'true'
4141
const updateComment = core.getInput('updateComment') === 'true'
4242
const jobName = core.getInput('job_name')
43+
const skipCommentWithoutTests = core.getInput('skip_comment_without_tests') === 'true'
4344

4445
const reportPaths = core.getMultilineInput('report_paths')
4546
const summary = core.getMultilineInput('summary')
@@ -201,7 +202,7 @@ export async function run(): Promise<void> {
201202
core.info('⏩ Skipped creation of job summary')
202203
}
203204

204-
if (comment) {
205+
if (comment && (!skipCommentWithoutTests || mergedResult.totalCount > 0)) {
205206
const octokit: InstanceType<typeof GitHub> = github.getOctokit(token)
206207
await attachComment(octokit, checkName, updateComment, table, detailTable, flakyTable)
207208
}

0 commit comments

Comments
 (0)