diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /app/graphql/types/ci | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) | |
download | gitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'app/graphql/types/ci')
-rw-r--r-- | app/graphql/types/ci/code_quality_degradation_severity_enum.rb | 15 | ||||
-rw-r--r-- | app/graphql/types/ci/job_type.rb | 30 | ||||
-rw-r--r-- | app/graphql/types/ci/pipeline_status_enum.rb | 2 | ||||
-rw-r--r-- | app/graphql/types/ci/pipeline_type.rb | 24 | ||||
-rw-r--r-- | app/graphql/types/ci/runner_access_level_enum.rb | 15 | ||||
-rw-r--r-- | app/graphql/types/ci/runner_sort_enum.rb | 13 | ||||
-rw-r--r-- | app/graphql/types/ci/runner_status_enum.rb | 15 | ||||
-rw-r--r-- | app/graphql/types/ci/runner_type.rb | 42 | ||||
-rw-r--r-- | app/graphql/types/ci/runner_type_enum.rb | 15 | ||||
-rw-r--r-- | app/graphql/types/ci/stage_type.rb | 55 | ||||
-rw-r--r-- | app/graphql/types/ci/template_type.rb | 16 |
11 files changed, 198 insertions, 44 deletions
diff --git a/app/graphql/types/ci/code_quality_degradation_severity_enum.rb b/app/graphql/types/ci/code_quality_degradation_severity_enum.rb new file mode 100644 index 00000000000..742ac922198 --- /dev/null +++ b/app/graphql/types/ci/code_quality_degradation_severity_enum.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Types + module Ci + class CodeQualityDegradationSeverityEnum < BaseEnum + graphql_name 'CodeQualityDegradationSeverity' + + ::Gitlab::Ci::Reports::CodequalityReports::SEVERITY_PRIORITIES.keys.each do |status| + value status.upcase, + description: "Code Quality degradation has a status of #{status}.", + value: status + end + end + end +end diff --git a/app/graphql/types/ci/job_type.rb b/app/graphql/types/ci/job_type.rb index 94a256fed3d..5ed4d823aee 100644 --- a/app/graphql/types/ci/job_type.rb +++ b/app/graphql/types/ci/job_type.rb @@ -8,6 +8,8 @@ module Types connection_type_class(Types::CountableConnectionType) + expose_permissions Types::PermissionTypes::Ci::Job + field :id, ::Types::GlobalIDType[::CommitStatus].as('JobID'), null: true, description: 'ID of the job.' field :pipeline, Types::Ci::PipelineType, null: true, @@ -23,7 +25,7 @@ module Types field :stage, Types::Ci::StageType, null: true, description: 'Stage of the job.' field :allow_failure, ::GraphQL::BOOLEAN_TYPE, null: false, - description: 'Whether this job is allowed to fail.' + description: 'Whether the job is allowed to fail.' field :duration, GraphQL::INT_TYPE, null: true, description: 'Duration of the job in seconds.' field :tags, [GraphQL::STRING_TYPE], null: true, @@ -41,6 +43,12 @@ module Types field :scheduled_at, Types::TimeType, null: true, description: 'Schedule for the build.' + # Life-cycle durations: + field :queued_duration, + type: Types::DurationType, + null: true, + description: 'How long the job was enqueued before starting.' + field :detailed_status, Types::Ci::DetailedStatusType, null: true, description: 'Detailed status of the job.' field :artifacts, Types::Ci::JobArtifactType.connection_type, null: true, @@ -63,8 +71,16 @@ module Types description: 'Indicates the job can be canceled.' field :active, GraphQL::BOOLEAN_TYPE, null: false, method: :active?, description: 'Indicates the job is active.' + field :stuck, GraphQL::BOOLEAN_TYPE, null: false, method: :stuck?, + description: 'Indicates the job is stuck.' field :coverage, GraphQL::FLOAT_TYPE, null: true, description: 'Coverage level of the job.' + field :created_by_tag, GraphQL::BOOLEAN_TYPE, null: false, + description: 'Whether the job was created by a tag.' + field :manual_job, GraphQL::BOOLEAN_TYPE, null: true, + description: 'Whether the job has a manual action.' + field :triggered, GraphQL::BOOLEAN_TYPE, null: true, + description: 'Whether the job was triggered.' def pipeline Gitlab::Graphql::Loaders::BatchModelLoader.new(::Ci::Pipeline, object.pipeline_id).find @@ -123,6 +139,18 @@ module Types def coverage object&.coverage end + + def created_by_tag + object.tag? + end + + def manual_job + object.try(:action?) + end + + def triggered + object.try(:trigger_request) + end end end end diff --git a/app/graphql/types/ci/pipeline_status_enum.rb b/app/graphql/types/ci/pipeline_status_enum.rb index e0b2020dcc1..2800454a999 100644 --- a/app/graphql/types/ci/pipeline_status_enum.rb +++ b/app/graphql/types/ci/pipeline_status_enum.rb @@ -5,7 +5,7 @@ module Types class PipelineStatusEnum < BaseEnum ::Ci::Pipeline.all_state_names.each do |state_symbol| value state_symbol.to_s.upcase, - description: ::Ci::Pipeline::STATUSES_DESCRIPTION[state_symbol], + description: "#{::Ci::Pipeline::STATUSES_DESCRIPTION[state_symbol]}.", value: state_symbol.to_s end end diff --git a/app/graphql/types/ci/pipeline_type.rb b/app/graphql/types/ci/pipeline_type.rb index 2e83f6c1f5a..2eeddaca6ba 100644 --- a/app/graphql/types/ci/pipeline_type.rb +++ b/app/graphql/types/ci/pipeline_type.rb @@ -24,6 +24,9 @@ module Types field :before_sha, GraphQL::STRING_TYPE, null: true, description: 'Base SHA of the source branch.' + field :complete, GraphQL::BOOLEAN_TYPE, null: false, method: :complete?, + description: 'Indicates if a pipeline is complete.' + field :status, PipelineStatusEnum, null: false, description: "Status of the pipeline (#{::Ci::Pipeline.all_state_names.compact.join(', ').upcase})" @@ -39,6 +42,9 @@ module Types field :duration, GraphQL::INT_TYPE, null: true, description: 'Duration of the pipeline in seconds.' + field :queued_duration, Types::DurationType, null: true, + description: 'How long the pipeline was queued before starting.' + field :coverage, GraphQL::FLOAT_TYPE, null: true, description: 'Coverage percentage.' @@ -57,12 +63,17 @@ module Types field :committed_at, Types::TimeType, null: true, description: "Timestamp of the pipeline's commit." - field :stages, Types::Ci::StageType.connection_type, null: true, + field :stages, + type: Types::Ci::StageType.connection_type, + null: true, + authorize: :read_commit_status, description: 'Stages of the pipeline.', extras: [:lookahead], resolver: Resolvers::Ci::PipelineStagesResolver - field :user, Types::UserType, null: true, + field :user, + type: Types::UserType, + null: true, description: 'Pipeline user.' field :retryable, GraphQL::BOOLEAN_TYPE, @@ -78,12 +89,14 @@ module Types field :jobs, ::Types::Ci::JobType.connection_type, null: true, + authorize: :read_commit_status, description: 'Jobs belonging to the pipeline.', resolver: ::Resolvers::Ci::JobsResolver field :job, type: ::Types::Ci::JobType, null: true, + authorize: :read_commit_status, description: 'A specific job in this pipeline, either by name or ID.' do argument :id, type: ::Types::GlobalIDType[::CommitStatus], @@ -95,7 +108,10 @@ module Types description: 'Name of the job.' end - field :source_job, Types::Ci::JobType, null: true, + field :source_job, + type: Types::Ci::JobType, + null: true, + authorize: :read_commit_status, description: 'Job where pipeline was triggered from.' field :downstream, Types::Ci::PipelineType.connection_type, null: true, @@ -166,4 +182,4 @@ module Types end end -Types::Ci::PipelineType.prepend_if_ee('::EE::Types::Ci::PipelineType') +Types::Ci::PipelineType.prepend_mod_with('Types::Ci::PipelineType') diff --git a/app/graphql/types/ci/runner_access_level_enum.rb b/app/graphql/types/ci/runner_access_level_enum.rb new file mode 100644 index 00000000000..e98f80336f1 --- /dev/null +++ b/app/graphql/types/ci/runner_access_level_enum.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Types + module Ci + class RunnerAccessLevelEnum < BaseEnum + graphql_name 'CiRunnerAccessLevel' + + ::Ci::Runner.access_levels.keys.each do |type| + value type.upcase, + description: "A runner that is #{type.tr('_', ' ')}.", + value: type + end + end + end +end diff --git a/app/graphql/types/ci/runner_sort_enum.rb b/app/graphql/types/ci/runner_sort_enum.rb new file mode 100644 index 00000000000..550e870316a --- /dev/null +++ b/app/graphql/types/ci/runner_sort_enum.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Types + module Ci + class RunnerSortEnum < BaseEnum + graphql_name 'CiRunnerSort' + description 'Values for sorting runners' + + value 'CONTACTED_ASC', 'Ordered by contacted_at in ascending order.', value: :contacted_asc + value 'CREATED_DESC', 'Ordered by created_date in descending order.', value: :created_date + end + end +end diff --git a/app/graphql/types/ci/runner_status_enum.rb b/app/graphql/types/ci/runner_status_enum.rb new file mode 100644 index 00000000000..ad69175e44a --- /dev/null +++ b/app/graphql/types/ci/runner_status_enum.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Types + module Ci + class RunnerStatusEnum < BaseEnum + graphql_name 'CiRunnerStatus' + + ::Ci::Runner::AVAILABLE_STATUSES.each do |status| + value status.to_s.upcase, + description: "A runner that is #{status.to_s.tr('_', ' ')}.", + value: status.to_sym + end + end + end +end diff --git a/app/graphql/types/ci/runner_type.rb b/app/graphql/types/ci/runner_type.rb new file mode 100644 index 00000000000..3abed7289d5 --- /dev/null +++ b/app/graphql/types/ci/runner_type.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +module Types + module Ci + class RunnerType < BaseObject + graphql_name 'CiRunner' + authorize :read_runner + + field :id, ::Types::GlobalIDType[::Ci::Runner], null: false, + description: 'ID of the runner.' + field :description, GraphQL::STRING_TYPE, null: true, + description: 'Description of the runner.' + field :contacted_at, Types::TimeType, null: true, + description: 'Last contact from the runner.', + method: :contacted_at + field :maximum_timeout, GraphQL::INT_TYPE, null: true, + description: 'Maximum timeout (in seconds) for jobs processed by the runner.' + field :access_level, ::Types::Ci::RunnerAccessLevelEnum, null: false, + description: 'Access level of the runner.' + field :active, GraphQL::BOOLEAN_TYPE, null: false, + description: 'Indicates the runner is allowed to receive jobs.' + field :status, ::Types::Ci::RunnerStatusEnum, null: false, + description: 'Status of the runner.' + field :version, GraphQL::STRING_TYPE, null: false, + description: 'Version of the runner.' + field :short_sha, GraphQL::STRING_TYPE, null: true, + description: %q(First eight characters of the runner's token used to authenticate new job requests. Used as the runner's unique ID.) + field :revision, GraphQL::STRING_TYPE, null: false, + description: 'Revision of the runner.' + field :locked, GraphQL::BOOLEAN_TYPE, null: true, + description: 'Indicates the runner is locked.' + field :run_untagged, GraphQL::BOOLEAN_TYPE, null: false, + description: 'Indicates the runner is able to run untagged jobs.' + field :ip_address, GraphQL::STRING_TYPE, null: false, + description: 'IP address of the runner.' + field :runner_type, ::Types::Ci::RunnerTypeEnum, null: false, + description: 'Type of the runner.' + field :tag_list, [GraphQL::STRING_TYPE], null: true, + description: 'Tags associated with the runner.' + end + end +end diff --git a/app/graphql/types/ci/runner_type_enum.rb b/app/graphql/types/ci/runner_type_enum.rb new file mode 100644 index 00000000000..f771635f4ed --- /dev/null +++ b/app/graphql/types/ci/runner_type_enum.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Types + module Ci + class RunnerTypeEnum < BaseEnum + graphql_name 'CiRunnerType' + + ::Ci::Runner.runner_types.keys.each do |type| + value type.upcase, + description: "A runner that is #{type.tr('_', ' ')}.", + value: type + end + end + end +end diff --git a/app/graphql/types/ci/stage_type.rb b/app/graphql/types/ci/stage_type.rb index 56b4f248697..1be9e3192a9 100644 --- a/app/graphql/types/ci/stage_type.rb +++ b/app/graphql/types/ci/stage_type.rb @@ -2,20 +2,26 @@ module Types module Ci - # rubocop: disable Graphql/AuthorizeTypes class StageType < BaseObject graphql_name 'CiStage' + authorize :read_commit_status - field :name, GraphQL::STRING_TYPE, null: true, - description: 'Name of the stage.' - field :groups, Ci::GroupType.connection_type, null: true, - extras: [:lookahead], - description: 'Group of jobs for the stage.' - field :detailed_status, Types::Ci::DetailedStatusType, null: true, - description: 'Detailed status of the stage.' - field :jobs, Ci::JobType.connection_type, null: true, - description: 'Jobs for the stage.', - method: 'latest_statuses' + field :name, + type: GraphQL::STRING_TYPE, + null: true, + description: 'Name of the stage.' + field :groups, + type: Ci::GroupType.connection_type, + null: true, + extras: [:lookahead], + description: 'Group of jobs for the stage.' + field :detailed_status, Types::Ci::DetailedStatusType, + null: true, + description: 'Detailed status of the stage.' + field :jobs, Ci::JobType.connection_type, + null: true, + description: 'Jobs for the stage.', + method: 'latest_statuses' def detailed_status object.detailed_status(current_user) @@ -37,33 +43,6 @@ module Types key = indexed[stage_id] groups = ::Ci::Group.fabricate(project, key.stage, statuses) - if Feature.enabled?(:ci_no_empty_groups, project) - groups.each do |group| - rejected = group.jobs.reject { |job| Ability.allowed?(current_user, :read_commit_status, job) } - group.jobs.select! { |job| Ability.allowed?(current_user, :read_commit_status, job) } - next unless group.jobs.empty? - - exc = StandardError.new('Empty Ci::Group') - traces = rejected.map do |job| - trace = [] - policy = Ability.policy_for(current_user, job) - policy.debug(:read_commit_status, trace) - trace - end - extra = { - current_user_id: current_user&.id, - project_id: project.id, - pipeline_id: pl.id, - stage_id: stage_id, - group_name: group.name, - rejected_job_ids: rejected.map(&:id), - rejected_traces: traces - } - Gitlab::ErrorTracking.track_exception(exc, extra) - end - groups.reject! { |group| group.jobs.empty? } - end - loader.call(key, groups) end end diff --git a/app/graphql/types/ci/template_type.rb b/app/graphql/types/ci/template_type.rb new file mode 100644 index 00000000000..5f07fa16928 --- /dev/null +++ b/app/graphql/types/ci/template_type.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Types + module Ci + # rubocop: disable Graphql/AuthorizeTypes + class TemplateType < BaseObject + graphql_name 'CiTemplate' + description 'GitLab CI/CD configuration template.' + + field :name, GraphQL::STRING_TYPE, null: false, + description: 'Name of the CI template.' + field :content, GraphQL::STRING_TYPE, null: false, + description: 'Contents of the CI template.' + end + end +end |