Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Optionally disable error on fail behaviour #56

Merged
merged 2 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/tests-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,10 @@ jobs:
assertion: npm://@assertions/is-equal:v1
expected: "failure"
actual: "${{ steps.failed.outcome }}"
- name: Test failed step does not have error when error on fail is disabled
uses: ./
with:
assertion: local://.github/workflows/assertions/is-equal
actual: "Bye bye!"
expected: "Goodbye, World!"
error-on-fail: false
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
| `type` | A supported [data type](#data-types) that `actual` and `expected` will be cast to before performing assertion | `string` | `string` `json` `number` |
| `each` | Parse multi-line `actual` into many values and perform assertion against each | `false` | `true` `false` |
| `local-path` | Path to directory containing `local` assertion | `${{github.workspace}}` | `.github/workflows/assertions` |
| `error-on-fail` | Report error in step when assertion fails | `true` | `false` |

### Data Types

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ inputs:
description: "Path to assertions on the runner's filesystem"
default: "${{ github.workspace }}"
required: true
error-on-fail:
description: "Report error in step when assertion fails"
default: "true"
required: true
outputs:
message:
description: "Human readable result of the assertion"
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async function run(): Promise<void> {
const type: string = core.getInput('type')
const each: boolean = core.getBooleanInput('each')
const localPath: string = core.getInput('local-path')
const errorOnFail: boolean = core.getBooleanInput('error-on-fail')

if (type in types === false) {
throw new Error(
Expand Down Expand Up @@ -59,7 +60,7 @@ async function run(): Promise<void> {

const aggregateResult: AggregateResult = new AggregateResult(results)

if (!aggregateResult.pass) {
if (!aggregateResult.pass && errorOnFail) {
core.setFailed(aggregateResult.message)
}

Expand Down