Skip to content

Commit

Permalink
Return error when step.conclusion has any cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
marocchino committed Feb 16, 2023
1 parent c5cebfe commit 5a9adde
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/test_post.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ jobs:
- uses: ./
with:
matrix_name: ${{ matrix.node_group }}
- run: exit 0
- run:
sleep 10
exit 0
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

post-test-matrix-failure:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ runs:
using: 'node16'
main: 'dist/index.js'
post: 'dist/index.js'
post-if: 'always()'
8 changes: 6 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ function cleanup() {
});
}
function job2status(job, isCleanUp) {
var _a;
var _a, _b;
if (!isCleanUp) {
return 'pending';
}
Expand All @@ -1208,7 +1208,11 @@ function job2status(job, isCleanUp) {
if (failedStep) {
return 'failure';
}
return job.conclusion === 'success' ? 'success' : 'error';
const cancelledStep = (_b = job.steps) === null || _b === void 0 ? void 0 : _b.find(step => step.conclusion === 'cancelled');
if (cancelledStep) {
return 'error';
}
return 'success';
}
function postStatus(isCleanUp) {
var _a;
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ function job2status(
if (failedStep) {
return 'failure'
}
return job.conclusion === 'success' ? 'success' : 'error'

const cancelledStep = job.steps?.find(step => step.conclusion === 'cancelled')
if (cancelledStep) {
return 'error'
}

return 'success'
}

async function postStatus(isCleanUp: boolean): Promise<void> {
Expand Down

0 comments on commit 5a9adde

Please sign in to comment.