Commit de8222fd authored by Kerri Miller's avatar Kerri Miller

Merge branch...

Merge branch '282520-follow-up-enable-and-disable-merge-train-checkbox-based-on-pipelines-for-merged-results' into 'master'

Add Merge Train Settings to the graphql api

See merge request gitlab-org/gitlab!49402
parents 4a5817e3 60c6e255
# frozen_string_literal: true
module Types
module Ci
class CiCdSettingType < BaseObject
graphql_name 'ProjectCiCdSetting'
authorize :admin_project
field :merge_pipelines_enabled, GraphQL::BOOLEAN_TYPE, null: true,
description: 'Whether merge pipelines are enabled.',
method: :merge_pipelines_enabled?
field :merge_trains_enabled, GraphQL::BOOLEAN_TYPE, null: true,
description: 'Whether merge trains are enabled.',
method: :merge_trains_enabled?
field :project, Types::ProjectType, null: true,
description: 'Project the CI/CD settings belong to.'
end
end
end
......@@ -191,6 +191,11 @@ module Types
description: 'Build pipeline of the project',
resolver: Resolvers::ProjectPipelineResolver
field :ci_cd_settings,
Types::Ci::CiCdSettingType,
null: true,
description: 'CI/CD settings for the project'
field :sentry_detailed_error,
Types::ErrorTracking::SentryDetailedErrorType,
null: true,
......
# frozen_string_literal: true
class ProjectCiCdSettingPolicy < BasePolicy
delegate { @subject.project }
end
---
title: Add Merge Train Setting to the graphql api
merge_request: 49402
author:
type: changed
......@@ -16229,6 +16229,11 @@ type Project {
last: Int
): BoardConnection
"""
CI/CD settings for the project
"""
ciCdSettings: ProjectCiCdSetting
"""
Find a single cluster agent by name
"""
......@@ -17906,6 +17911,23 @@ type Project {
wikiEnabled: Boolean
}
type ProjectCiCdSetting {
"""
Whether merge pipelines are enabled.
"""
mergePipelinesEnabled: Boolean
"""
Whether merge trains are enabled.
"""
mergeTrainsEnabled: Boolean
"""
Project the CI/CD settings belong to.
"""
project: Project
}
"""
The connection type for Project.
"""
......
......@@ -48281,6 +48281,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "ciCdSettings",
"description": "CI/CD settings for the project",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "ProjectCiCdSetting",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "clusterAgent",
"description": "Find a single cluster agent by name",
......@@ -52337,6 +52351,61 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "ProjectCiCdSetting",
"description": null,
"fields": [
{
"name": "mergePipelinesEnabled",
"description": "Whether merge pipelines are enabled.",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "mergeTrainsEnabled",
"description": "Whether merge trains are enabled.",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "project",
"description": "Project the CI/CD settings belong to.",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "Project",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "ProjectConnection",
......@@ -2521,6 +2521,7 @@ Autogenerated return type of PipelineRetry.
| `avatarUrl` | String | URL to avatar image file of the project |
| `board` | Board | A single board of the project |
| `boards` | BoardConnection | Boards of the project |
| `ciCdSettings` | ProjectCiCdSetting | CI/CD settings for the project |
| `clusterAgent` | ClusterAgent | Find a single cluster agent by name |
| `clusterAgents` | ClusterAgentConnection | Cluster agents associated with the project |
| `codeCoverageSummary` | CodeCoverageSummary | Code coverage summary associated with the project |
......@@ -2615,6 +2616,14 @@ Autogenerated return type of PipelineRetry.
| `webUrl` | String | Web URL of the project |
| `wikiEnabled` | Boolean | Indicates if Wikis are enabled for the current user |
### ProjectCiCdSetting
| Field | Type | Description |
| ----- | ---- | ----------- |
| `mergePipelinesEnabled` | Boolean | Whether merge pipelines are enabled. |
| `mergeTrainsEnabled` | Boolean | Whether merge trains are enabled. |
| `project` | Project | Project the CI/CD settings belong to. |
### ProjectMember
Represents a Project Membership.
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Getting Ci Cd Setting' do
include GraphqlHelpers
let_it_be_with_reload(:project) { create(:project, :repository) }
let_it_be(:current_user) { project.owner }
let(:fields) do
<<~QUERY
#{all_graphql_fields_for('ProjectCiCdSetting')}
QUERY
end
let(:query) do
graphql_query_for(
'project',
{ 'fullPath' => project.full_path },
query_graphql_field('ciCdSettings', {}, fields)
)
end
let(:settings_data) { graphql_data['project']['ciCdSettings'] }
context 'without permissions' do
let(:user) { create(:user) }
before do
project.add_reporter(user)
post_graphql(query, current_user: user)
end
it_behaves_like 'a working graphql query'
specify { expect(settings_data).to be nil }
end
context 'with project permissions' do
before do
post_graphql(query, current_user: current_user)
end
it_behaves_like 'a working graphql query'
specify { expect(settings_data['mergePipelinesEnabled']).to eql project.ci_cd_settings.merge_pipelines_enabled? }
specify { expect(settings_data['mergeTrainsEnabled']).to eql project.ci_cd_settings.merge_trains_enabled? }
specify { expect(settings_data['project']['id']).to eql "gid://gitlab/Project/#{project.id}" }
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