Skip to content

Commit

Permalink
fix: Fail step when assertion does not pass (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrink authored Jun 24, 2021
1 parent 4a9dd37 commit afa757f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/tests-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,27 @@ jobs:
compared Goodbye, World! to Hello, World!
compared Hello, World! to Hello, World!
actual: "${{ steps.multiple-failed.outputs.message }}"
test-step-fails:
runs-on: ubuntu-latest
needs:
- upload-dist
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: dist
path: ${{ env.dist-path }}
- name: Expect two different values not to pass an equality test
id: failed
uses: ./
continue-on-error: true
with:
assertion: local://.github/workflows/assertions/is-equal
actual: "Bye bye!"
expected: "Goodbye, World!"
- name: Test step fails when assertion does not pass
uses: ./
with:
assertion: npm://@assertions/is-equal:v1
expected: "failure"
actual: "${{ steps.failed.outcome }}"
8 changes: 6 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,22 @@ async function run(): Promise<void> {
}
})

const results: Result[] = executeTests(tests);
const results: Result[] = executeTests(tests)

results.forEach(result => {
core.info(`${result.pass ? `✅` : `❌`} ${result.message}`)
})

const aggregateResult: AggregateResult = new AggregateResult(results)

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

core.setOutput('message', aggregateResult.message)
core.setOutput('pass', aggregateResult.pass.toString())
core.setOutput('passed', aggregateResult.pass.toString())
core.setOutput('failed', (! aggregateResult.pass).toString())
core.setOutput('failed', (!aggregateResult.pass).toString())
} catch (error) {
core.setFailed(error.message)
}
Expand Down

0 comments on commit afa757f

Please sign in to comment.