GitLab: show CI checks for MR-only pipelines and fork MRs - #15194
Open
v0id3r wants to merge 2 commits into
Open
Conversation
v0id3r
force-pushed
the
gitlab-mr-pipeline-checks
branch
2 times, most recently
from
August 5, 2026 11:52
8ef2c7b to
cd4749c
Compare
GitLab MR-only pipelines run on refs/merge-requests/* and fork MR pipelines run in the source project, so pipelines/latest?ref= finds neither. Split job pagination out of list_pipeline_jobs_for_ref and add list_pipeline_jobs_for_open_mr: it resolves the branch's open MR, re-fetches it for head_pipeline (absent from list responses), and lists jobs from the project that owns the pipeline (numeric id for forks). Non-success MR responses carry their HTTP status so callers can tell missing access apart from other failures; a branch with no open MR or head pipeline is authoritatively reported as having no checks.
When pipelines/latest?ref= returns nothing, fall back to the open MR's head pipeline. The ref endpoint stays the primary source and the branch name stays the cache key. MR-lookup 403/404 maps to an unresolved ref so cached checks survive; no open MR is an authoritative empty result. head_sha is now populated from the pipeline SHA (previously always empty for GitLab). The checks badge keeps its fork block only where the forge cannot serve fork checks (GitHub); GitLab fork MRs resolve checks through the MR.
v0id3r
force-pushed
the
gitlab-mr-pipeline-checks
branch
from
August 5, 2026 11:54
cd4749c to
e299c00
Compare
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
The CI checks badge shows "No checks" for GitLab MRs in two common setups:
GET /projects/:id/pipelines/latest?ref=<branch>, but detached / merged-results MR pipelines run onrefs/merge-requests/:iid/*and are never found by branch name.enabled = !isFork && !isMerged) — a restriction motivated by the GitHub check-runs API that does not apply to GitLab. Even without the flag, jobs would be requested from the target project while fork pipelines run in the source project.Approach
but-gitlab: split job pagination out oflist_pipeline_jobs_for_ref(behavior unchanged) and addlist_pipeline_jobs_for_open_mr: resolve the branch's open MR, re-fetch it via the single-MR endpoint forhead_pipeline(list responses omit it), and list jobs from the project that owns the pipeline — by numeric id, since a fork'sowner/repopath is unknown.but-forge: when the ref path returns no jobs, fall back to the MR path. No open MR / no head pipeline is an authoritative empty result; MR-lookup 403/404 maps to an unresolved ref (cache preserved, "No checks"); other errors surface on the badge.head_shais now filled from the pipeline SHA (previously always empty for GitLab).forkBlocksChecks = isFork && !isGitLab); GitHub behavior is unchanged.Deliberately unchanged
pipelines/latest?ref=remains the primary source; the MR head pipeline is only a fallback when it is empty. Making it primary would silently change badge contents after force-pushes for branch-pipeline users.warm_ci_checks_cachestale cleanup and cache-onlybut statusdepend on it.Testing
head_shamapping;cargo test -p but-gitlab -p but-forge, clippy-D warnings, desktop vitest and svelte-check all green.read_api) were exercised only via the unit-tested selection/error paths.