-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Research and POC using required checks in gh workflows #12139
Comments
Description of github workflows behaviour when set as required check. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
Prevent skip job when parent job failed Docs about required checks advice to use on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
failed-job:
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.step1.outputs.test }}
steps:
- name: failed-step-with-output
run: |
echo "This job will always fail"
echo "test=hello" >> "$GITHUB_OUTPUT"
exit 1
dependent-job:
runs-on: ubuntu-latest
needs: failed-job
if: ${{ always() }}
steps:
- name: dependent-step
run: echo "This job is dependent on failed-job"
dependent-job-2:
runs-on: ubuntu-latest
needs: failed-job
if: ${{ always() }}
steps:
- name: dependent-step
if: ${{ needs.failed-job.outputs.output1 == 'hello' }}
run: echo "This job is dependent on failed-job"
dependent-job-3:
runs-on: ubuntu-latest
needs: failed-job
if: ${{ always() && needs.failed-job.outputs.output1 == 'hello' }}
steps:
- name: dependent-step
run: echo "This job is dependent on failed-job"
dependent-job-4:
runs-on: ubuntu-latest
needs: failed-job
if: ${{ (always() && needs.failed-job.outputs.output1 == 'hello') || failure() }}
steps:
- name: dependent-step
if: ${{ failure() }}
run: |
echo "This job should fail"
exit 1
- name: this-not-fail
run: echo "do not fail" Conclusion The most secure is option 3, however it requires most complex additional process interacting with checks statuses. |
A github action we could use to solve the problem. https://github.com/wechuli/allcheckspassed It's already used in telemetry-manager repository. |
We agreed to use solution number 2 as it require less work and changes in our existing workflows. In the future we might consider investing more time to implement option 3 which is more secure and possible to extend. |
The required checks in github actions works different than required prowjobs in prow. Because we are moving out of Prow we must understand consequences and decide on our approach.
The text was updated successfully, but these errors were encountered: