Skip to content

Commit

Permalink
Fail (optionally) the action if test report contains any failed test
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Dorner committed Nov 18, 2020
1 parent 1ee2707 commit 94e768f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ description: |
author: 'Michal Dorner <dorner.michal@gmail.com>'
inputs:
fail-on-error:
description: 'Set this action as failed if test report contains any failed test'
required: true
default: 'true'
name:
description: 'Name of the check run'
required: true
Expand Down
4 changes: 4 additions & 0 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ async function run(): Promise<void> {
}

async function main(): Promise<void> {
const failOnError = core.getInput('fail-on-error', {required: true}) === 'true'
const name = core.getInput('name', {required: true})
const path = core.getInput('path', {required: true})
const reporter = core.getInput('reporter', {required: true})
Expand All @@ -37,6 +38,9 @@ async function main(): Promise<void> {
})

core.setOutput('conclusion', conclusion)
if (failOnError && !result.success) {
core.setFailed(`Failed test has been found and 'fail-on-error' option is set to ${failOnError}.`)
}
}

function getParser(reporter: string): ParseTestResult {
Expand Down

0 comments on commit 94e768f

Please sign in to comment.