Repository navigation
fix(gitlab): ignore non-push pipelines when waiting for the main pipeline - #121
Merged
Merged
Conversation
…line A pipeline schedule on the target branch runs on the same HEAD SHA as the last merge. ListPipelines returned the newest pipeline for ref+SHA, so a fast scheduled pipeline shadowed the merge pipeline and the train reported "Main pipeline success" while the real pipeline was still running. Filter by source=push so only the pipeline created by the merge counts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After the last merge,
Runner.waitForMainPipelinepollsListPipelines(ref, sha)and readspipelines[0](newest by ID). When the target branch has a pipeline schedule, the scheduled pipeline runs on the same HEAD SHA, gets a higher ID and usually finishes much faster. The train then reportedMain pipeline successfrom the scheduled pipeline, while the TUI still linked the merge pipeline, which was still running (in one case it had not even started).Fix
APIClient.ListPipelinesnow filters bysource=push, so only the pipeline created by the merge counts. This also covers the race where a scheduled pipeline is created before the push pipeline, and it excludesweb/api/triggerpipelines on the same SHA. The method has a single production caller, so the interface signature, mocks, runner and TUI are unchanged.Behaviour change
If the target branch never gets a push pipeline (e.g.
workflow:rulesskip push), the train now waits untilmain_pipeline_timeout_mand logs an error instead of reporting another pipeline's status.Testing
TestListPipelines_OnlyPushPipelines: the httptest server returns a newer scheduled pipeline unlesssource=pushis set. It fails without the fix and passes with it.go build,golangci-lint run ./...,go test ./...,govulncheck ./...all pass.source=pushreturns exactly the merge pipeline for the affected SHAs.Not in this PR
skipped/manualare not terminal statuses inwaitForMainPipeline, so such a merge pipeline waits for the timeout.statusparameter ofListPipelines.