diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /app/graphql/resolvers/ci | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) | |
download | gitlab-ce-9dc93a4519d9d5d7be48ff274127136236a3adb3.tar.gz |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'app/graphql/resolvers/ci')
-rw-r--r-- | app/graphql/resolvers/ci/config_resolver.rb | 6 | ||||
-rw-r--r-- | app/graphql/resolvers/ci/jobs_resolver.rb | 13 | ||||
-rw-r--r-- | app/graphql/resolvers/ci/pipeline_stages_resolver.rb | 2 | ||||
-rw-r--r-- | app/graphql/resolvers/ci/runner_platforms_resolver.rb | 3 | ||||
-rw-r--r-- | app/graphql/resolvers/ci/runner_setup_resolver.rb | 43 | ||||
-rw-r--r-- | app/graphql/resolvers/ci/test_report_summary_resolver.rb | 17 | ||||
-rw-r--r-- | app/graphql/resolvers/ci/test_suite_resolver.rb | 40 |
7 files changed, 104 insertions, 20 deletions
diff --git a/app/graphql/resolvers/ci/config_resolver.rb b/app/graphql/resolvers/ci/config_resolver.rb index f8670649e48..252c9d3acf0 100644 --- a/app/graphql/resolvers/ci/config_resolver.rb +++ b/app/graphql/resolvers/ci/config_resolver.rb @@ -7,6 +7,10 @@ module Resolvers include ResolvesProject type Types::Ci::Config::ConfigType, null: true + description <<~MD + Linted and processed contents of a CI config. + Should not be requested more than once per request. + MD authorize :read_pipeline @@ -55,7 +59,7 @@ module Resolvers name: job[:name], stage: job[:stage], group_name: CommitStatus.new(name: job[:name]).group_name, - needs: job.dig(:needs) || [], + needs: job[:needs] || [], allow_failure: job[:allow_failure], before_script: job[:before_script], script: job[:script], diff --git a/app/graphql/resolvers/ci/jobs_resolver.rb b/app/graphql/resolvers/ci/jobs_resolver.rb index dd565094017..5ae9e721cc8 100644 --- a/app/graphql/resolvers/ci/jobs_resolver.rb +++ b/app/graphql/resolvers/ci/jobs_resolver.rb @@ -11,7 +11,18 @@ module Resolvers required: false, description: 'Filter jobs by the type of security report they produce.' - def resolve(security_report_types: []) + argument :statuses, [::Types::Ci::JobStatusEnum], + required: false, + description: 'Filter jobs by status.' + + def resolve(statuses: nil, security_report_types: []) + jobs = init_collection(security_report_types) + jobs = jobs.with_status(statuses) if statuses.present? + + jobs + end + + def init_collection(security_report_types) if security_report_types.present? ::Security::SecurityJobsFinder.new( pipeline: pipeline, diff --git a/app/graphql/resolvers/ci/pipeline_stages_resolver.rb b/app/graphql/resolvers/ci/pipeline_stages_resolver.rb index 98170e0cd2e..a458e873935 100644 --- a/app/graphql/resolvers/ci/pipeline_stages_resolver.rb +++ b/app/graphql/resolvers/ci/pipeline_stages_resolver.rb @@ -16,7 +16,7 @@ module Resolvers def preloads { - statuses: [:needs] + jobs: { latest_statuses: [:needs] } } end end diff --git a/app/graphql/resolvers/ci/runner_platforms_resolver.rb b/app/graphql/resolvers/ci/runner_platforms_resolver.rb index 9677c5139b4..f120e94b67b 100644 --- a/app/graphql/resolvers/ci/runner_platforms_resolver.rb +++ b/app/graphql/resolvers/ci/runner_platforms_resolver.rb @@ -3,7 +3,8 @@ module Resolvers module Ci class RunnerPlatformsResolver < BaseResolver - type Types::Ci::RunnerPlatformType, null: false + type Types::Ci::RunnerPlatformType.connection_type, null: true + description 'Supported runner platforms.' def resolve(**args) runner_instructions.map do |platform, data| diff --git a/app/graphql/resolvers/ci/runner_setup_resolver.rb b/app/graphql/resolvers/ci/runner_setup_resolver.rb index ac2a56b89a7..9166999b400 100644 --- a/app/graphql/resolvers/ci/runner_setup_resolver.rb +++ b/app/graphql/resolvers/ci/runner_setup_resolver.rb @@ -3,30 +3,37 @@ module Resolvers module Ci class RunnerSetupResolver < BaseResolver + ACCESS_DENIED = 'User is not authorized to register a runner for the specified resource!' + type Types::Ci::RunnerSetupType, null: true + description 'Runner setup instructions.' - argument :platform, GraphQL::STRING_TYPE, - required: true, - description: 'Platform to generate the instructions for.' + argument :platform, + type: GraphQL::STRING_TYPE, + required: true, + description: 'Platform to generate the instructions for.' - argument :architecture, GraphQL::STRING_TYPE, - required: true, - description: 'Architecture to generate the instructions for.' + argument :architecture, + type: GraphQL::STRING_TYPE, + required: true, + description: 'Architecture to generate the instructions for.' - argument :project_id, ::Types::GlobalIDType[::Project], - required: false, - description: 'Project to register the runner for.' + argument :project_id, + type: ::Types::GlobalIDType[::Project], + required: false, + deprecated: { reason: 'No longer used', milestone: '13.11' }, + description: 'Project to register the runner for.' - argument :group_id, ::Types::GlobalIDType[::Group], - required: false, - description: 'Group to register the runner for.' + argument :group_id, + type: ::Types::GlobalIDType[::Group], + required: false, + deprecated: { reason: 'No longer used', milestone: '13.11' }, + description: 'Group to register the runner for.' def resolve(platform:, architecture:, **args) instructions = Gitlab::Ci::RunnerInstructions.new( - current_user: current_user, os: platform, - arch: architecture, - **target_param(args) + arch: architecture ) { @@ -34,11 +41,15 @@ module Resolvers register_instructions: instructions.register_command } ensure - raise Gitlab::Graphql::Errors::ResourceNotAvailable, 'User is not authorized to register a runner for the specified resource!' if instructions.errors.include?('Gitlab::Access::AccessDeniedError') + raise Gitlab::Graphql::Errors::ResourceNotAvailable, ACCESS_DENIED if access_denied?(instructions) end private + def access_denied?(instructions) + instructions.errors.include?('Gitlab::Access::AccessDeniedError') + end + def other_install_instructions(platform) Gitlab::Ci::RunnerInstructions::OTHER_ENVIRONMENTS[platform.to_sym][:installation_instructions_url] end diff --git a/app/graphql/resolvers/ci/test_report_summary_resolver.rb b/app/graphql/resolvers/ci/test_report_summary_resolver.rb new file mode 100644 index 00000000000..22db70f032a --- /dev/null +++ b/app/graphql/resolvers/ci/test_report_summary_resolver.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Resolvers + module Ci + class TestReportSummaryResolver < BaseResolver + type ::Types::Ci::TestReportSummaryType, null: true + + alias_method :pipeline, :object + + def resolve(**args) + TestReportSummarySerializer + .new(project: pipeline.project, current_user: @current_user) + .represent(pipeline.test_report_summary) + end + end + end +end diff --git a/app/graphql/resolvers/ci/test_suite_resolver.rb b/app/graphql/resolvers/ci/test_suite_resolver.rb new file mode 100644 index 00000000000..90cc30b1281 --- /dev/null +++ b/app/graphql/resolvers/ci/test_suite_resolver.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +module Resolvers + module Ci + class TestSuiteResolver < BaseResolver + include Gitlab::Graphql::Authorize::AuthorizeResource + + type ::Types::Ci::TestSuiteType, null: true + authorize :read_build + authorizes_object! + + alias_method :pipeline, :object + + argument :build_ids, [GraphQL::ID_TYPE], + required: true, + description: 'IDs of the builds used to run the test suite.' + + def resolve(build_ids:) + builds = pipeline.latest_builds.id_in(build_ids).presence + return unless builds + + TestSuiteSerializer + .new(project: pipeline.project, current_user: @current_user) + .represent(load_test_suite_data(builds), details: true) + end + + private + + def load_test_suite_data(builds) + suite = builds.sum do |build| + build.collect_test_reports!(Gitlab::Ci::Reports::TestReports.new) + end + + Gitlab::Ci::Reports::TestFailureHistory.new(suite.failed.values, pipeline.project).load! + + suite + end + end + end +end |