Skip to content

Commit

Permalink
Merge pull request #243 from gdams/fail_on_empty
Browse files Browse the repository at this point in the history
add feature fail-on-empty
  • Loading branch information
j-catania authored Sep 22, 2023
2 parents 62386e9 + 9e78da5 commit 61135b8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ jobs:
# Set action as failed if test report contains any failed test
fail-on-error: 'true'
# Set this action as failed if no test results were found
fail-on-empty: 'true'
# Relative path under $GITHUB_WORKSPACE where the repository was checked out.
working-directory: ''
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ inputs:
description: Set this action as failed if test report contain any failed test
required: true
default: 'true'
fail-on-empty:
description: Set this action as failed if no test results were found
required: true
default: 'true'
working-directory:
description: Relative path under $GITHUB_WORKSPACE where the repository was checked out
required: false
Expand Down
3 changes: 2 additions & 1 deletion dist/index.js

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

3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class TestReporter {
readonly listTests = core.getInput('list-tests', {required: true}) as 'all' | 'failed' | 'none'
readonly maxAnnotations = parseInt(core.getInput('max-annotations', {required: true}))
readonly failOnError = core.getInput('fail-on-error', {required: true}) === 'true'
readonly failOnEmpty = core.getInput('fail-on-empty', {required: true}) === 'true'
readonly workDirInput = core.getInput('working-directory', {required: false})
readonly onlySummary = core.getInput('only-summary', {required: false}) === 'true'
readonly token = core.getInput('token', {required: true})
Expand Down Expand Up @@ -135,7 +136,7 @@ class TestReporter {
return
}

if (results.length === 0) {
if (results.length === 0 && this.failOnEmpty) {
core.setFailed(`No test report files were found`)
return
}
Expand Down

0 comments on commit 61135b8

Please sign in to comment.