From 27b0b8559613c108962a7c19444e19a3535802a7 Mon Sep 17 00:00:00 2001 From: Christian Winther Date: Wed, 2 Oct 2024 17:58:07 +0200 Subject: [PATCH] feat: expand GitLab evalContext with the HEAD pipeline for the MR (#97) --- pkg/scm/gitlab/context_valuers.go | 5 +++ schema/gitlab.schema.graphqls | 58 +++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/pkg/scm/gitlab/context_valuers.go b/pkg/scm/gitlab/context_valuers.go index 3481494..9b01e61 100644 --- a/pkg/scm/gitlab/context_valuers.go +++ b/pkg/scm/gitlab/context_valuers.go @@ -25,3 +25,8 @@ func (d MergeStatus) AsString() string { func (d DetailedMergeStatus) AsString() string { return d.String() } + +// PipelineStatusEnum is a ENUM type +func (d PipelineStatusEnum) AsString() string { + return d.String() +} diff --git a/schema/gitlab.schema.graphqls b/schema/gitlab.schema.graphqls index 0b4877d..6d94b9c 100644 --- a/schema/gitlab.schema.graphqls +++ b/schema/gitlab.schema.graphqls @@ -156,6 +156,22 @@ enum DetailedMergeStatus { REQUESTED_CHANGES } +enum PipelineStatusEnum { + CANCELED + CANCELING + CREATED + FAILED + MANUAL + PENDING + PREPARING + RUNNING + SCHEDULED + SKIPPED + SUCCESS + WAITING_FOR_CALLBACK + WAITING_FOR_RESOURCE +} + input ListMergeRequestsQueryInput { project_id: ID! state: MergeRequestState! = "opened" @@ -337,6 +353,8 @@ type ContextMergeRequest { DiffStats: [ContextDiffStat!] "Labels available on this merge request" Labels: [ContextLabel!] @generated + "Pipeline running on the branch HEAD of the merge request" + HeadPipeline: ContextPipeline # # scm-engine customs @@ -466,3 +484,43 @@ type ContextDiffStat { "File path, relative to repository root" Path: String! } + +# https://docs.gitlab.com/ee/api/graphql/reference/#pipeline +type ContextPipeline { + "Indicates if the pipeline is active" + Active: Boolean! + "Specifies if a pipeline can be canceled" + Cancelable: Boolean! + "Indicates if a pipeline is complete" + Complete: Boolean! + "Duration of the pipeline in seconds" + Duration: Int + "The reason why the pipeline failed" + FailureReason: String + "Timestamp of the pipeline's completion" + FinishedAt: Time + "ID of the pipeline" + ID: String! + "Internal ID of the pipeline" + IID: String! + "If the pipeline is the latest one or not" + Latest: Boolean! + "Name of the pipeline" + Name: String + "Relative path to the pipeline's page" + Path: String + "Specifies if a pipeline can be retried" + Retryable: Boolean! + "Timestamp when the pipeline was started" + StartedAt: Time + "Status of the pipeline" + Status: PipelineStatusEnum! + "If the pipeline is stuck" + Stuck: Boolean! + "The total number of jobs in the pipeline" + TotalJobs: Int! + "Timestamp of the pipeline's last activity" + UpdatedAt: Time! + "Indicates if a pipeline has warnings" + Warnings: Boolean! +}