Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-09-27 21:09:27 +00:00
parent 223359576d
commit d48053f82e
30 changed files with 57 additions and 164 deletions

View file

@ -2,6 +2,8 @@
module Resolvers
class ProjectPipelineResolver < BaseResolver
include LooksAhead
type ::Types::Ci::PipelineType, null: true
alias_method :project, :object
@ -14,7 +16,7 @@ module Resolvers
required: false,
description: 'SHA of the Pipeline. For example, "dyd0f15ay83993f5ab66k927w28673882x99100b".'
def ready?(iid: nil, sha: nil)
def ready?(iid: nil, sha: nil, **args)
unless iid.present? ^ sha.present?
raise Gitlab::Graphql::Errors::ArgumentError, 'Provide one of an IID or SHA'
end
@ -22,18 +24,21 @@ module Resolvers
super
end
def resolve(iid: nil, sha: nil)
# the preloads are defined on ee/app/graphql/ee/resolvers/project_pipeline_resolver.rb
def resolve(iid: nil, sha: nil, **args)
self.lookahead = args.delete(:lookahead)
if iid
BatchLoader::GraphQL.for(iid).batch(key: project) do |iids, loader, args|
BatchLoader::GraphQL.for(iid).batch(key: project) do |iids, loader|
finder = ::Ci::PipelinesFinder.new(project, current_user, iids: iids)
finder.execute.each { |pipeline| loader.call(pipeline.iid.to_s, pipeline) }
apply_lookahead(finder.execute).each { |pipeline| loader.call(pipeline.iid.to_s, pipeline) }
end
else
BatchLoader::GraphQL.for(sha).batch(key: project) do |shas, loader, args|
BatchLoader::GraphQL.for(sha).batch(key: project) do |shas, loader|
finder = ::Ci::PipelinesFinder.new(project, current_user, sha: shas)
finder.execute.each { |pipeline| loader.call(pipeline.sha.to_s, pipeline) }
apply_lookahead(finder.execute).each { |pipeline| loader.call(pipeline.sha.to_s, pipeline) }
end
end
end

View file

@ -208,6 +208,7 @@ module Types
Types::Ci::PipelineType,
null: true,
description: 'Build pipeline of the project.',
extras: [:lookahead],
resolver: Resolvers::ProjectPipelineResolver
field :ci_cd_settings,

View file

@ -45,7 +45,6 @@ module Integrations
included do
has_one :issue_tracker_data, autosave: true, inverse_of: :integration, foreign_key: :service_id, class_name: 'Integrations::IssueTrackerData'
has_one :jira_tracker_data, autosave: true, inverse_of: :integration, foreign_key: :service_id, class_name: 'Integrations::JiraTrackerData'
has_one :open_project_tracker_data, autosave: true, inverse_of: :integration, foreign_key: :service_id, class_name: 'Integrations::OpenProjectTrackerData'
has_one :zentao_tracker_data, autosave: true, inverse_of: :integration, foreign_key: :integration_id, class_name: 'Integrations::ZentaoTrackerData'
def data_fields

View file

@ -1,20 +0,0 @@
# frozen_string_literal: true
module Integrations
class OpenProject < BaseIssueTracker
validates :url, public_url: true, presence: true, if: :activated?
validates :api_url, public_url: true, allow_blank: true, if: :activated?
validates :token, presence: true, if: :activated?
validates :project_identifier_code, presence: true, if: :activated?
data_field :url, :api_url, :token, :closed_status_id, :project_identifier_code
def data_fields
open_project_tracker_data || self.build_open_project_tracker_data
end
def self.to_param
'open_project'
end
end
end

View file

@ -1,18 +0,0 @@
# frozen_string_literal: true
module Integrations
class OpenProjectTrackerData < ApplicationRecord
include BaseDataFields
# When the Open Project is fresh installed, the default closed status id is "13" based on current version: v8.
DEFAULT_CLOSED_STATUS_ID = "13"
attr_encrypted :url, encryption_options
attr_encrypted :api_url, encryption_options
attr_encrypted :token, encryption_options
def closed_status_id
super || DEFAULT_CLOSED_STATUS_ID
end
end
end

View file

@ -1,8 +0,0 @@
---
name: ci_minutes_track_live_consumption
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/59263
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/329197
milestone: '13.12'
type: development
group: group::pipeline execution
default_enabled: false

View file

@ -1,8 +0,0 @@
---
name: usage_data_i_testing_group_code_coverage_visit_total
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51382
rollout_issue_url:
milestone: '13.8'
type: development
group: group::testing
default_enabled: true

View file

@ -0,0 +1,9 @@
# frozen_string_literal: true
class DropInt4ColumnForPushEventPayloads < Gitlab::Database::Migration[1.0]
enable_lock_retries!
def change
remove_column :push_event_payloads, :event_id_convert_to_bigint, :integer, null: false, default: 0
end
end

View file

@ -0,0 +1 @@
4f3a1dbf39f1955122f94616952bfe04836c43e97268035b2daec3bc16e55e66

View file

@ -18446,7 +18446,6 @@ ALTER SEQUENCE protected_tags_id_seq OWNED BY protected_tags.id;
CREATE TABLE push_event_payloads (
commit_count bigint NOT NULL,
event_id_convert_to_bigint integer DEFAULT 0 NOT NULL,
action smallint NOT NULL,
ref_type smallint NOT NULL,
commit_from bytea,

View file

@ -133,7 +133,6 @@ The following metrics are available:
| `pipeline_graph_links_total` | Histogram | 13.9 | Number of links per graph | |
| `pipeline_graph_links_per_job_ratio` | Histogram | 13.9 | Ratio of links to job per graph | |
| `gitlab_ci_pipeline_security_orchestration_policy_processing_duration_seconds` | Histogram | 13.12 | Time in seconds it takes to process Security Policies in CI/CD pipeline | |
| `gitlab_ci_difference_live_vs_actual_minutes` | Histogram | 13.12 | Difference between CI minute consumption counted while jobs were running (live) vs when jobs are complete (actual). Used to enforce CI minute consumption limits on long running jobs. | `plan` |
| `gitlab_spamcheck_request_duration_seconds` | Histogram | 13.12 | The duration for requests between Rails and the anti-spam engine | |
| `service_desk_thank_you_email` | Counter | 14.0 | Total number of email responses to new service desk emails | |
| `service_desk_new_note_email` | Counter | 14.0 | Total number of email notifications on new service desk comment | |

View file

@ -12189,6 +12189,7 @@ Represents a file or directory in the project repository that has been locked.
| <a id="pipelineconfigsource"></a>`configSource` | [`PipelineConfigSourceEnum`](#pipelineconfigsourceenum) | Configuration source of the pipeline (UNKNOWN_SOURCE, REPOSITORY_SOURCE, AUTO_DEVOPS_SOURCE, WEBIDE_SOURCE, REMOTE_SOURCE, EXTERNAL_PROJECT_SOURCE, BRIDGE_SOURCE, PARAMETER_SOURCE, COMPLIANCE_SOURCE). |
| <a id="pipelinecoverage"></a>`coverage` | [`Float`](#float) | Coverage percentage. |
| <a id="pipelinecreatedat"></a>`createdAt` | [`Time!`](#time) | Timestamp of the pipeline's creation. |
| <a id="pipelinedastprofile"></a>`dastProfile` | [`DastProfile`](#dastprofile) | DAST profile associated with the pipeline. Returns `null`if `dast_view_scans` feature flag is disabled. |
| <a id="pipelinedetailedstatus"></a>`detailedStatus` | [`DetailedStatus!`](#detailedstatus) | Detailed status of the pipeline. |
| <a id="pipelinedownstream"></a>`downstream` | [`PipelineConnection`](#pipelineconnection) | Pipelines this pipeline will trigger. (see [Connections](#connections)) |
| <a id="pipelineduration"></a>`duration` | [`Int`](#int) | Duration of the pipeline in seconds. |

View file

@ -171,9 +171,9 @@ module API
mount ::API::DeployTokens
mount ::API::Deployments
mount ::API::Environments
mount ::API::ErrorTracking
mount ::API::ErrorTrackingClientKeys
mount ::API::ErrorTrackingCollector
mount ::API::ErrorTracking::ClientKeys
mount ::API::ErrorTracking::Collector
mount ::API::ErrorTracking::ProjectSettings
mount ::API::Events
mount ::API::FeatureFlags
mount ::API::FeatureFlagsUserLists

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
module API
class ErrorTrackingClientKeys < ::API::Base
class ErrorTracking::ClientKeys < ::API::Base
before { authenticate! }
feature_category :error_tracking

View file

@ -4,7 +4,7 @@ module API
# This API is responsible for collecting error tracking information
# from sentry client. It allows us to use GitLab as an alternative to
# sentry backend. For more details see https://gitlab.com/gitlab-org/gitlab/-/issues/329596.
class ErrorTrackingCollector < ::API::Base
class ErrorTracking::Collector < ::API::Base
feature_category :error_tracking
content_type :envelope, 'application/x-sentry-envelope'

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
module API
class ErrorTracking < ::API::Base
class ErrorTracking::ProjectSettings < ::API::Base
before { authenticate! }
feature_category :error_tracking

View file

@ -92,14 +92,6 @@ module Gitlab
Gitlab::Metrics.counter(name, comment)
end
def self.gitlab_ci_difference_live_vs_actual_minutes
name = :gitlab_ci_difference_live_vs_actual_minutes
comment = 'Comparison between CI minutes consumption from live tracking vs actual consumption'
labels = {}
buckets = [-120.0, -60.0, -30.0, -10.0, -5.0, -3.0, -1.0, 0.0, 1.0, 3.0, 5.0, 10.0, 30.0, 60.0, 120.0]
::Gitlab::Metrics.histogram(name, comment, labels, buckets)
end
end
end
end

View file

@ -35,12 +35,12 @@ module Gitlab
# connection.load_balancer.primary_write_location
# end
#
job['wal_locations'] = { Gitlab::Database::MAIN_DATABASE_NAME.to_sym => wal_location } if wal_location
job['wal_locations'] = { ::Gitlab::Database::MAIN_DATABASE_NAME.to_sym => wal_location } if wal_location
end
def wal_location
strong_memoize(:wal_location) do
if Session.current.use_primary?
if ::Gitlab::Database::LoadBalancing::Session.current.use_primary?
load_balancer.primary_write_location
else
load_balancer.host.database_replica_location
@ -49,7 +49,7 @@ module Gitlab
end
def load_balancer
LoadBalancing.proxy.load_balancer
::Gitlab::Database::LoadBalancing.proxy.load_balancer
end
end
end

View file

@ -158,7 +158,6 @@
category: testing
redis_slot: testing
aggregation: weekly
feature_flag: usage_data_i_testing_group_code_coverage_visit_total
- name: i_testing_full_code_quality_report_total
category: testing
redis_slot: testing

View file

@ -18,12 +18,4 @@ FactoryBot.define do
factory :issue_tracker_data, class: 'Integrations::IssueTrackerData' do
integration
end
factory :open_project_tracker_data, class: 'Integrations::OpenProjectTrackerData' do
integration factory: :open_project_service
url { 'http://openproject.example.com' }
token { 'supersecret' }
project_identifier_code { 'PRJ-1' }
closed_status_id { '15' }
end
end

View file

@ -166,26 +166,6 @@ FactoryBot.define do
external_wiki_url { 'http://external-wiki-url.com' }
end
factory :open_project_service, class: 'Integrations::OpenProject' do
project
active { true }
transient do
url { 'http://openproject.example.com' }
api_url { 'http://openproject.example.com/issues/:id' }
token { 'supersecret' }
closed_status_id { '15' }
project_identifier_code { 'PRJ-1' }
end
after(:build) do |integration, evaluator|
integration.open_project_tracker_data = build(:open_project_tracker_data,
integration: integration, url: evaluator.url, api_url: evaluator.api_url, token: evaluator.token,
closed_status_id: evaluator.closed_status_id, project_identifier_code: evaluator.project_identifier_code
)
end
end
trait :jira_cloud_service do
url { 'https://mysite.atlassian.net' }
username { 'jira_user' }

View file

@ -18,7 +18,7 @@ RSpec.describe Types::Ci::PipelineType do
]
if Gitlab.ee?
expected_fields += %w[security_report_summary security_report_findings code_quality_reports]
expected_fields += %w[security_report_summary security_report_findings code_quality_reports dast_profile]
end
expect(described_class).to have_graphql_fields(*expected_fields)

View file

@ -324,7 +324,6 @@ integrations:
- jira_tracker_data
- zentao_tracker_data
- issue_tracker_data
- open_project_tracker_data
hooks:
- project
- web_hook_logs

View file

@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'spec_helper'
require_migration!('drop_int4_column_for_push_event_payloads')
RSpec.describe DropInt4ColumnForPushEventPayloads do
let(:push_event_payloads) { table(:push_event_payloads) }
it 'correctly migrates up and down' do
reversible_migration do |migration|
migration.before -> {
expect(push_event_payloads.column_names).to include('event_id_convert_to_bigint')
}
migration.after -> {
push_event_payloads.reset_column_information
expect(push_event_payloads.column_names).not_to include('event_id_convert_to_bigint')
}
end
end
end

View file

@ -14,7 +14,6 @@ RSpec.describe Integration do
it { is_expected.to have_one(:service_hook).inverse_of(:integration).with_foreign_key(:service_id) }
it { is_expected.to have_one(:issue_tracker_data).autosave(true).inverse_of(:integration).with_foreign_key(:service_id).class_name('Integrations::IssueTrackerData') }
it { is_expected.to have_one(:jira_tracker_data).autosave(true).inverse_of(:integration).with_foreign_key(:service_id).class_name('Integrations::JiraTrackerData') }
it { is_expected.to have_one(:open_project_tracker_data).autosave(true).inverse_of(:integration).with_foreign_key(:service_id).class_name('Integrations::OpenProjectTrackerData') }
end
describe 'validations' do

View file

@ -1,30 +0,0 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Integrations::OpenProject do
describe 'Validations' do
context 'when integration is active' do
before do
subject.active = true
end
it { is_expected.to validate_presence_of(:url) }
it { is_expected.to validate_presence_of(:token) }
it { is_expected.to validate_presence_of(:project_identifier_code) }
it_behaves_like 'issue tracker integration URL attribute', :url
it_behaves_like 'issue tracker integration URL attribute', :api_url
end
context 'when integration is inactive' do
before do
subject.active = false
end
it { is_expected.not_to validate_presence_of(:url) }
it { is_expected.not_to validate_presence_of(:token) }
it { is_expected.not_to validate_presence_of(:project_identifier_code) }
end
end
end

View file

@ -1,19 +0,0 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Integrations::OpenProjectTrackerData do
describe 'associations' do
it { is_expected.to belong_to(:integration) }
end
describe 'closed_status_id' do
it 'returns the set value' do
expect(build(:open_project_tracker_data).closed_status_id).to eq('15')
end
it 'returns the default value if not set' do
expect(build(:open_project_tracker_data, closed_status_id: nil).closed_status_id).to eq('13')
end
end
end

View file

@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe API::ErrorTrackingClientKeys do
RSpec.describe API::ErrorTracking::ClientKeys do
let_it_be(:guest) { create(:user) }
let_it_be(:maintainer) { create(:user) }
let_it_be(:setting) { create(:project_error_tracking_setting) }

View file

@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe API::ErrorTrackingCollector do
RSpec.describe API::ErrorTracking::Collector do
let_it_be(:project) { create(:project, :private) }
let_it_be(:setting) { create(:project_error_tracking_setting, :integrated, project: project) }
let_it_be(:client_key) { create(:error_tracking_client_key, project: project) }

View file

@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe API::ErrorTracking do
RSpec.describe API::ErrorTracking::ProjectSettings do
let_it_be(:user) { create(:user) }
let(:setting) { create(:project_error_tracking_setting) }