Commit 5b7127a3 authored by Philip Cunningham's avatar Philip Cunningham Committed by Nick Thomas

Expand scope of GraphQL pipeline resolver

Allow query to retrieve all pipelines rather than CI-only.
parent 8fc5347f
......@@ -10,7 +10,7 @@ module Resolvers
def resolve(iid:)
BatchLoader::GraphQL.for(iid).batch(key: project) do |iids, loader, args|
args[:key].ci_pipelines.for_iid(iids).each { |pl| loader.call(pl.iid.to_s, pl) }
args[:key].all_pipelines.for_iid(iids).each { |pl| loader.call(pl.iid.to_s, pl) }
end
end
end
......
# frozen_string_literal: true
module Types
module Ci
class PipelineConfigSourceEnum < BaseEnum
::Ci::PipelineEnums.config_sources.keys.each do |state_symbol|
value state_symbol.to_s.upcase, value: state_symbol.to_s
end
end
end
end
......@@ -25,6 +25,8 @@ module Types
field :detailed_status, Types::Ci::DetailedStatusType, null: false,
description: 'Detailed status of the pipeline',
resolve: -> (obj, _args, ctx) { obj.detailed_status(ctx[:current_user]) }
field :config_source, PipelineConfigSourceEnum, null: true,
description: "Config source of the pipeline (#{::Ci::PipelineEnums.config_sources.keys.join(', ').upcase})"
field :duration, GraphQL::INT_TYPE, null: true,
description: 'Duration of the pipeline in seconds'
field :coverage, GraphQL::FLOAT_TYPE, null: true,
......
---
title: Allow GraphQL pipeline to resolve non-CI pipelines and expose configSource field
merge_request: 39275
author:
type: added
......@@ -10261,6 +10261,13 @@ type Pipeline {
"""
committedAt: Time
"""
Config source of the pipeline (UNKNOWN_SOURCE, REPOSITORY_SOURCE,
AUTO_DEVOPS_SOURCE, WEBIDE_SOURCE, REMOTE_SOURCE, EXTERNAL_PROJECT_SOURCE,
BRIDGE_SOURCE, PARAMETER_SOURCE)
"""
configSource: PipelineConfigSourceEnum
"""
Coverage percentage
"""
......@@ -10353,6 +10360,17 @@ type Pipeline {
userPermissions: PipelinePermissions!
}
enum PipelineConfigSourceEnum {
AUTO_DEVOPS_SOURCE
BRIDGE_SOURCE
EXTERNAL_PROJECT_SOURCE
PARAMETER_SOURCE
REMOTE_SOURCE
REPOSITORY_SOURCE
UNKNOWN_SOURCE
WEBIDE_SOURCE
}
"""
The connection type for Pipeline.
"""
......
......@@ -30652,6 +30652,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "configSource",
"description": "Config source of the pipeline (UNKNOWN_SOURCE, REPOSITORY_SOURCE, AUTO_DEVOPS_SOURCE, WEBIDE_SOURCE, REMOTE_SOURCE, EXTERNAL_PROJECT_SOURCE, BRIDGE_SOURCE, PARAMETER_SOURCE)",
"args": [
],
"type": {
"kind": "ENUM",
"name": "PipelineConfigSourceEnum",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "coverage",
"description": "Coverage percentage",
......@@ -30927,6 +30941,65 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "PipelineConfigSourceEnum",
"description": null,
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "UNKNOWN_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "REPOSITORY_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "AUTO_DEVOPS_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "WEBIDE_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "REMOTE_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "EXTERNAL_PROJECT_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "BRIDGE_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "PARAMETER_SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "PipelineConnection",
......@@ -1571,6 +1571,7 @@ Information about pagination in a connection.
| --- | ---- | ---------- |
| `beforeSha` | String | Base SHA of the source branch |
| `committedAt` | Time | Timestamp of the pipeline's commit |
| `configSource` | PipelineConfigSourceEnum | Config source of the pipeline (UNKNOWN_SOURCE, REPOSITORY_SOURCE, AUTO_DEVOPS_SOURCE, WEBIDE_SOURCE, REMOTE_SOURCE, EXTERNAL_PROJECT_SOURCE, BRIDGE_SOURCE, PARAMETER_SOURCE) |
| `coverage` | Float | Coverage percentage |
| `createdAt` | Time! | Timestamp of the pipeline's creation |
| `detailedStatus` | DetailedStatus! | Detailed status of the pipeline |
......
......@@ -33,4 +33,21 @@ RSpec.describe Resolvers::ProjectPipelineResolver do
it 'errors when no iid is passed' do
expect { resolve_pipeline(project, {}) }.to raise_error(ArgumentError)
end
context 'when the pipeline is not a ci_config_source' do
let(:pipeline) do
config_source_value = Ci::PipelineEnums.non_ci_config_source_values.first
config_source = Ci::PipelineEnums.config_sources.key(config_source_value)
create(:ci_pipeline, config_source: config_source, project: project)
end
it 'resolves pipeline for the passed iid' do
result = batch_sync do
resolve_pipeline(project, { iid: pipeline.iid.to_s })
end
expect(result).to eq(pipeline)
end
end
end
......@@ -29,4 +29,10 @@ RSpec.describe 'getting pipeline information nested in a project' do
expect(pipeline_graphql_data).not_to be_nil
end
it 'contains configSource' do
post_graphql(query, current_user: current_user)
expect(pipeline_graphql_data.dig('configSource')).to eq('UNKNOWN_SOURCE')
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment