Skip to content

Commit 09ebaa7

Browse files
committed
ci: github: Propagate test run outcome to commit status
The change allows to block failed PRs. I noticed something to improve is that the change can be mergeable until the test finish, this can be prevented by setting the commit to failed in build workflow and then marked as successful after test workflow. This sound a bit hackish, let me search for a better (KISS) solution. Origin: #102 Relate-to: https://github.com/actions/github-script Relate-to: https://octokit.github.io/rest.js/v21/#repos Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#22 Signed-off-by: Philippe Coval <[email protected]>
1 parent 6b552d4 commit 09ebaa7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

.github/workflows/test.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
---
55

66
name: test
7+
8+
# yamllint disable-line rule:line-length
79
run-name: "test: ${{ github.event.workflow_run.head_branch }}#${{ github.event.workflow_run.head_commit.id }}"
810

911
on: # yamllint disable-line rule:truthy
1012
workflow_run:
1113
workflows: ["build"]
1214
types:
1315
- completed
16+
1417
jobs:
1518
test:
1619
env:
@@ -57,6 +60,7 @@ jobs:
5760
&& date -u
5861
5962
- name: Run
63+
id: run
6064
run: |
6165
set -x
6266
export ZPC_RUN_MODE="docker"
@@ -67,3 +71,20 @@ jobs:
6771
cd z-wave-stack-binaries/bin && file -E *_x86_REALTIME.elf && cd -
6872
export ZPC_ARGS="--log.level=d"
6973
./scripts/tests/z-wave-stack-binaries-test.sh
74+
continue-on-error: true
75+
76+
- name: Propagate run status to commit status
77+
uses: actions/github-script@v7
78+
if: always()
79+
env:
80+
status: ${{ steps.run.outcome }}
81+
sha: ${{ github.event.workflow_run.head_commit.id }}
82+
with:
83+
script: |
84+
await github.rest.repos.createCommitStatus({
85+
owner: context.repo.owner,
86+
repo: context.repo.repo,
87+
sha: context.sha,
88+
state: process.env.status
89+
})
90+
process.exit(process.env.status == 'success' ? 0 : 1);

0 commit comments

Comments
 (0)