Skip to content

Commit

Permalink
Merge pull request #864 from mikepenz/featue/require_passed_tests
Browse files Browse the repository at this point in the history
Offer configuration `require_passed_tests`
  • Loading branch information
mikepenz authored May 23, 2023
2 parents 62e3580 + 6fe2c81 commit 16f9a74
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ jobs:
| `commit` | Optional. The commit SHA to update the status. This is useful when you run it with `workflow_run`. |
| `fail_on_failure` | Optional. Fail the build in case of a test failure. |
| `require_tests` | Optional. Fail if no test are found. |
| `require_passed_tests` | Optional. Fail if no passed test are found. (This is stricter than `require_tests`, which accepts skipped tests). |
| `include_passed` | Optional. By default the action will skip passed items for the annotations. Enable this flag to include them. |
| `check_retries` | Optional. If a testcase is retried, ignore the original failure. |
| `check_title_template` | Optional. Template to configure the title format. Placeholders: {{FILE_NAME}}, {{SUITE_NAME}}, {{TEST_NAME}}. |
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ inputs:
description: 'Fail if no test are found.'
required: false
default: 'false'
require_passed_tests:
description: 'Fail if no passed test are found.'
required: false
default: 'false'
include_passed:
description: 'Include passed tests in the report'
required: false
Expand Down
8 changes: 6 additions & 2 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.

7 changes: 5 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export async function run(): Promise<void> {
const commit = core.getInput('commit')
const failOnFailure = core.getInput('fail_on_failure') === 'true'
const requireTests = core.getInput('require_tests') === 'true'
const requirePassedTests = core.getInput('require_passed_tests') === 'true'
const includePassed = core.getInput('include_passed') === 'true'
const checkRetries = core.getInput('check_retries') === 'true'
const annotateNotice = core.getInput('annotate_notice') === 'true'
Expand Down Expand Up @@ -87,10 +88,12 @@ export async function run(): Promise<void> {
core.setOutput('skipped', mergedResult.skipped)
core.setOutput('failed', mergedResult.failed)

const foundResults = mergedResult.totalCount > 0 || mergedResult.skipped > 0
if (!foundResults && requireTests) {
if (!(mergedResult.totalCount > 0 || mergedResult.skipped > 0) && requireTests) {
core.setFailed(`❌ No test results found for ${checkName}`)
return // end if we failed due to no tests, but configured to require tests
} else if (!(mergedResult.passed > 0) && requirePassedTests) {
core.setFailed(`❌ No passed test results found for ${checkName}`)
return // end if we failed due to no passed tests, but configured to require passed tests
}

const pullRequest = github.context.payload.pull_request
Expand Down

0 comments on commit 16f9a74

Please sign in to comment.