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
ci: only report status after matrix jobs are done #23865
Conversation
The solution is found at https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow. Currently I only update one CI workflow. If this one is accepted, I will update the remain workflows in this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spacewander thank you for these changes. Does this work? I'm only asking because as far as I know the if: ${{ success() }}
, if: ${{ failure() }}
and if: ${{ cancelled() }}
only refer to the steps from the same job, not from previous jobs.
Yes. GitHub documents this behavior at https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! Unfortunately, I don't think this works as intended, as per the documentation: https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions
The status check functions only work for steps in the same job, as André was mentioning. Snippet from the doc (and same for other functions):
success
Returns true when none of the previous steps have failed or been canceled.
The failure one works with ancestor jobs, but I don't think it works for the others.
I think for checking against previous jobs, we should instead use |
Although GitHub's doc may not make it clear, the We can see the "Set commit status to success" job is run after the matrix job "build" is successful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice then! In this case we need for the reporting job to have access to the SHA, otherwise the commit status API step itself will fail (as is the case right now in the examples provided).
The following step needs to be added prior to calling the commit status API to retrieve the SHA:
- name: Set up job variables
id: vars
run: |
if [ ${{ github.event.issue.pull_request || github.event.pull_request }} ]; then
PR_API_JSON=$(curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
${{ github.event.issue.pull_request.url || github.event.pull_request.url }})
SHA=$(echo "$PR_API_JSON" | jq -r ".head.sha")
else
SHA=${{ github.sha }}
fi
@spacewander 👋 Are you still on this PR? |
Commit b93da8ff449381b2611f0d1b6b03981332a3f819 does not contain "Signed-off-by". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
@spacewander Thanks! Could you squash your commits into a single one? |
Signed-off-by: spacewander <spacewanderlzx@gmail.com>
Done |
Thanks a lot, LGTM. |
This commit applies the same changes introduced in cilium#23865 to the ci-multicluster workflow, moving the status reporting after all matrix jobs are done. This prevents that the status reported by one job is later overwritten by a subsequent one. Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
This commit applies the same changes introduced in #23865 to the ci-multicluster workflow, moving the status reporting after all matrix jobs are done. This prevents that the status reported by one job is later overwritten by a subsequent one. Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Before this commit, the ci-datapath workflow would update the PR status for each `setup-and-test` matrix job. That however lead to the PR being marked as green as soon as the first matrix job succeeded, even though later tests might fail. Worse, if an earlier matrix job failed, and a later one succeeded, the latter job masked the failure of the earlier job and marked the PR as green as well. This commit fixes the issue by only updating the commit status once all jobs have run. This technique is taken from #23865 and has been used for the BPF verifier workflow for a while. Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
Before this commit, the ci-datapath workflow would update the PR status for each `setup-and-test` matrix job. That however lead to the PR being marked as green as soon as the first matrix job succeeded, even though later tests might fail. Worse, if an earlier matrix job failed, and a later one succeeded, the latter job masked the failure of the earlier job and marked the PR as green as well. This commit fixes the issue by only updating the commit status once all jobs have run. This technique is taken from #23865 and has been used for the BPF verifier workflow for a while. Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
This commit applies the same changes introduced in #23865 to the ci-multicluster workflow, moving the status reporting after all matrix jobs are done. This prevents that the status reported by one job is later overwritten by a subsequent one. Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Please ensure your pull request adheres to the following guidelines:
description and a
Fixes: #XXX
line if the commit addresses a particularGitHub issue.
Fixes: <commit-id>
tag, thenplease add the commit author[s] as reviewer[s] to this issue.
Fixes: #23729