Skip to content

Commit

Permalink
feat: Optionally disable error on fail behaviour (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrink committed Jun 24, 2021
1 parent afa757f commit d043329
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
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

0 comments on commit d043329

Please sign in to comment.