Skip to content

Commit a1423d3

Browse files
committed
Add option to disable commenting if no tests are detected
Fixes #1319 Add the ability to disable commenting if no tests are detected. * **action.yml** - Add a new input `skip_comment_without_tests` to the inputs section. * **src/main.ts** - Add a new constant `disableCommentIfNoTests` to read the input value. - Add a condition to check if tests are detected before calling `attachComment`. * **README.md** - Update the documentation to include the new input option `skip_comment_without_tests`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/mikepenz/action-junit-report/issues/1319?shareId=XXXX-XXXX-XXXX-XXXX).
1 parent 6906ff8 commit a1423d3

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
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'

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 disableCommentIfNoTests = 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 && (!disableCommentIfNoTests || 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)