Commit 3cd63883 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'null-pipeline-in-graphql-response-224687' into 'master'

Allow GraphQL pipeline resolver to look up non-CI pipeline

See merge request gitlab-org/gitlab!39275
parents 655e25b7 5b7127a3
...@@ -10,7 +10,7 @@ module Resolvers ...@@ -10,7 +10,7 @@ module Resolvers
def resolve(iid:) def resolve(iid:)
BatchLoader::GraphQL.for(iid).batch(key: project) do |iids, loader, args| 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 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 ...@@ -25,6 +25,8 @@ module Types
field :detailed_status, Types::Ci::DetailedStatusType, null: false, field :detailed_status, Types::Ci::DetailedStatusType, null: false,
description: 'Detailed status of the pipeline', description: 'Detailed status of the pipeline',
resolve: -> (obj, _args, ctx) { obj.detailed_status(ctx[:current_user]) } 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, field :duration, GraphQL::INT_TYPE, null: true,
description: 'Duration of the pipeline in seconds' description: 'Duration of the pipeline in seconds'
field :coverage, GraphQL::FLOAT_TYPE, null: true, 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 { ...@@ -10261,6 +10261,13 @@ type Pipeline {
""" """
committedAt: Time 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 Coverage percentage
""" """
...@@ -10353,6 +10360,17 @@ type Pipeline { ...@@ -10353,6 +10360,17 @@ type Pipeline {
userPermissions: PipelinePermissions! 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. The connection type for Pipeline.
""" """
......
...@@ -30652,6 +30652,20 @@ ...@@ -30652,6 +30652,20 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "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", "name": "coverage",
"description": "Coverage percentage", "description": "Coverage percentage",
...@@ -30927,6 +30941,65 @@ ...@@ -30927,6 +30941,65 @@
"enumValues": null, "enumValues": null,
"possibleTypes": 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", "kind": "OBJECT",
"name": "PipelineConnection", "name": "PipelineConnection",
...@@ -1571,6 +1571,7 @@ Information about pagination in a connection. ...@@ -1571,6 +1571,7 @@ Information about pagination in a connection.
| --- | ---- | ---------- | | --- | ---- | ---------- |
| `beforeSha` | String | Base SHA of the source branch | | `beforeSha` | String | Base SHA of the source branch |
| `committedAt` | Time | Timestamp of the pipeline's commit | | `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 | | `coverage` | Float | Coverage percentage |
| `createdAt` | Time! | Timestamp of the pipeline's creation | | `createdAt` | Time! | Timestamp of the pipeline's creation |
| `detailedStatus` | DetailedStatus! | Detailed status of the pipeline | | `detailedStatus` | DetailedStatus! | Detailed status of the pipeline |
......
...@@ -33,4 +33,21 @@ RSpec.describe Resolvers::ProjectPipelineResolver do ...@@ -33,4 +33,21 @@ RSpec.describe Resolvers::ProjectPipelineResolver do
it 'errors when no iid is passed' do it 'errors when no iid is passed' do
expect { resolve_pipeline(project, {}) }.to raise_error(ArgumentError) expect { resolve_pipeline(project, {}) }.to raise_error(ArgumentError)
end 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 end
...@@ -29,4 +29,10 @@ RSpec.describe 'getting pipeline information nested in a project' do ...@@ -29,4 +29,10 @@ RSpec.describe 'getting pipeline information nested in a project' do
expect(pipeline_graphql_data).not_to be_nil expect(pipeline_graphql_data).not_to be_nil
end end
it 'contains configSource' do
post_graphql(query, current_user: current_user)
expect(pipeline_graphql_data.dig('configSource')).to eq('UNKNOWN_SOURCE')
end
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