diff --git a/.github/workflows/tests-integration.yml b/.github/workflows/tests-integration.yml index 19722e3..a855228 100644 --- a/.github/workflows/tests-integration.yml +++ b/.github/workflows/tests-integration.yml @@ -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 diff --git a/README.md b/README.md index 284b664..ad63f2b 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index e5536de..bc71480 100644 --- a/action.yml +++ b/action.yml @@ -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" diff --git a/src/main.ts b/src/main.ts index 13e2de5..2c3e077 100644 --- a/src/main.ts +++ b/src/main.ts @@ -22,6 +22,7 @@ async function run(): Promise { 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( @@ -59,7 +60,7 @@ async function run(): Promise { const aggregateResult: AggregateResult = new AggregateResult(results) - if (!aggregateResult.pass) { + if (!aggregateResult.pass && errorOnFail) { core.setFailed(aggregateResult.message) }