Skip to content
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

feat: gitlab - ensure lastpipeline ref is the same as head branch #5259

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

rhariady
Copy link

what

This MR will change the behaviour of GitlabClient UpdateStatus to use previous lastPipeline only if it has a same Ref (branch).

why

This is to fix #5228 where a commit is referenced as head of two different branch (in case someone duplicate a branch and create separate MR)

tests

  • I have tested my changes by returning commit status with lastpipeline of different Ref

references

@rhariady rhariady requested review from a team as code owners January 21, 2025 04:21
@rhariady rhariady requested review from GenPage, lukemassa and X-Guardian and removed request for a team January 21, 2025 04:21
@github-actions github-actions bot added go Pull requests that update Go code provider/gitlab labels Jan 21, 2025
@rhariady rhariady force-pushed the fix-5228-gitlab-pipeline-status branch from 4cd2848 to 807c10f Compare January 21, 2025 04:34
@jamengual jamengual added the waiting-on-review Waiting for a review from a maintainer label Jan 21, 2025
@rhariady rhariady force-pushed the fix-5228-gitlab-pipeline-status branch from 0daeea2 to fd84a2b Compare January 21, 2025 11:52
@X-Guardian
Copy link
Contributor

Hi @rhariady, I don't think this is going to totally fix the issue, as if the ref does not match, it is going to retry then fall back to using pull.Headbranch as the reference for the commit status. This may not choose the right pipeline if for example there are both GitLab and External pipelines running on an MR.

I think this can be resolved by adding some more code when the ref does not match to then use the list-the-status-of-a-commit API to find the correct status to update.

@X-Guardian X-Guardian added waiting-on-response Waiting for a response from the user and removed waiting-on-review Waiting for a review from a maintainer labels Jan 21, 2025
@rhariady rhariady force-pushed the fix-5228-gitlab-pipeline-status branch from 9648c1d to 4636a84 Compare January 22, 2025 10:05
@rhariady
Copy link
Author

rhariady commented Jan 22, 2025

Hi @X-Guardian! I have pushed another commit that implement your suggestion, but instead of calling list-the-status-of-a-commit only when the ref doesn't match, I end up using it to replace call to get-a-single-commit API in the first place.

I think it will be more effective, because we will have 1 less API call for every retry (in case there are another pipeline running). Also, i think list-the-status-of-a-commit is more aligned with the subsequent call, which is to set-the-status-of-a-commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code provider/gitlab waiting-on-response Waiting for a response from the user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gitlab MR pipeline status is not updated
3 participants