Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-06-03 06:10:04 +00:00
parent 531a68a424
commit b646822e52
41 changed files with 100 additions and 132 deletions

View File

@ -780,7 +780,6 @@ Layout/ArgumentAlignment:
- 'spec/lib/gitlab/usage/metrics/query_spec.rb'
- 'spec/lib/gitlab/usage_data_counters/designs_counter_spec.rb'
- 'spec/lib/gitlab/usage_data_counters/snippet_counter_spec.rb'
- 'spec/lib/gitlab/usage_data_counters/static_site_editor_counter_spec.rb'
- 'spec/lib/gitlab/usage_data_counters/wiki_page_counter_spec.rb'
- 'spec/lib/gitlab/usage_data_queries_spec.rb'
- 'spec/lib/mattermost/session_spec.rb'

View File

@ -1 +1 @@
4181f9518f5a56298d6875a0fd4da1e72dabcb9f
7c2fcde23bd4a962409897adbbb71da11c6db99a

View File

@ -219,7 +219,7 @@ gem 'ruby-progressbar', '~> 1.10'
gem 'settingslogic', '~> 2.0.9'
# Linear-time regex library for untrusted regular expressions
gem 're2', '~> 1.2.0'
gem 're2', '~> 1.4.0'
# Misc

View File

@ -1025,7 +1025,7 @@ GEM
rbtree (0.4.4)
rchardet (1.8.0)
rdoc (6.3.2)
re2 (1.2.0)
re2 (1.4.0)
recaptcha (4.13.1)
json
recursive-open-struct (1.1.3)
@ -1620,7 +1620,7 @@ DEPENDENCIES
rainbow (~> 3.0)
rbtrace (~> 0.4)
rdoc (~> 6.3.2)
re2 (~> 1.2.0)
re2 (~> 1.4.0)
recaptcha (~> 4.11)
redis (~> 4.4.0)
redis-actionpack (~> 5.2.0)

View File

@ -88,7 +88,10 @@ module MarkupHelper
text,
tags: tags,
attributes: Rails::Html::WhiteListSanitizer.allowed_attributes +
%w(style data-src data-name data-unicode-version data-iid data-project-path data-mr-title data-html)
%w(
style data-src data-name data-unicode-version data-html
data-reference-type data-project-path data-iid data-mr-title
)
)
# since <img> tags are stripped, this can leave empty <a> tags hanging around

View File

@ -1083,6 +1083,8 @@ module Ci
all_runtime_metadata.delete_all
end
deployment&.sync_status_with(self)
Gitlab::AppLogger.info(
message: 'Build doomed',
class: self.class.name,

View File

@ -63,12 +63,12 @@ module Projects
# rubocop: disable CodeReuse/ActiveRecord
def self.query(projects, public_only: true)
issues_filtered_by_type = Issue.opened.with_issue_type(Issue::TYPES_FOR_LIST)
open_issues = Issue.opened
if public_only
issues_filtered_by_type.public_only.where(project: projects)
open_issues.public_only.where(project: projects)
else
issues_filtered_by_type.where(project: projects)
open_issues.where(project: projects)
end
end
# rubocop: enable CodeReuse/ActiveRecord

View File

@ -118,7 +118,6 @@
- snippets
- source_code_management
- static_application_security_testing
- static_site_editor
- subgroups
- system_access
- team_planning

View File

@ -1,8 +0,0 @@
---
name: slack_app_use_v2_flow
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/85726
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/360680
milestone: '15.0'
type: development
group: group::integrations
default_enabled: false

View File

@ -7,7 +7,7 @@ product_stage: create
product_group: group::editor
product_category: static_site_editor
value_type: number
status: active
status: removed
time_frame: 28d
data_source: redis_hll
distribution:
@ -19,3 +19,5 @@ tier:
- ultimate
performance_indicator_type: []
milestone: "<13.9"
milestone_removed: "15.1"
removed_by_url: "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/88485"

View File

@ -16,7 +16,6 @@ options:
- g_edit_by_web_ide
- g_edit_by_sfe
- g_edit_by_snippet_ide
- g_edit_by_sse
distribution:
- ce
- ee

View File

@ -7,7 +7,7 @@ product_stage: create
product_group: group::editor
product_category: static_site_editor
value_type: number
status: active
status: removed
time_frame: 28d
data_source: redis_hll
instrumentation_class: RedisHLLMetric
@ -23,3 +23,5 @@ tier:
- ultimate
performance_indicator_type: []
milestone: "<13.9"
milestone_removed: "15.1"
removed_by_url: "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/88485"

View File

@ -16,7 +16,6 @@ options:
- g_edit_by_web_ide
- g_edit_by_sfe
- g_edit_by_snippet_ide
- g_edit_by_sse
distribution:
- ce
- ee

View File

@ -7,7 +7,7 @@ product_stage: create
product_group: group::editor
product_category: static_site_editor
value_type: number
status: active
status: removed
time_frame: 7d
data_source: redis_hll
instrumentation_class: RedisHLLMetric
@ -23,3 +23,5 @@ tier:
- ultimate
performance_indicator_type: []
milestone: "<13.9"
milestone_removed: "15.1"
removed_by_url: "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/88485"

View File

@ -7,7 +7,7 @@ product_stage: create
product_group: group::editor
product_category: static_site_editor
value_type: number
status: active
status: removed
time_frame: all
data_source: redis
distribution:
@ -21,3 +21,5 @@ performance_indicator_type:
- gmau
- paid_gmau
milestone: "<13.9"
milestone_removed: "15.1"
removed_by_url: "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/88485"

View File

@ -7,7 +7,7 @@ product_stage: create
product_group: group::editor
product_category: static_site_editor
value_type: number
status: active
status: removed
time_frame: all
data_source: redis
distribution:
@ -18,3 +18,5 @@ tier:
- premium
- ultimate
milestone: "<13.9"
milestone_removed: "15.1"
removed_by_url: "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/88485"

View File

@ -7,7 +7,7 @@ product_stage: create
product_group: group::editor
product_category: static_site_editor
value_type: number
status: active
status: removed
time_frame: all
data_source: redis
distribution:
@ -18,3 +18,5 @@ tier:
- premium
- ultimate
milestone: "<13.9"
milestone_removed: "15.1"
removed_by_url: "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/88485"

View File

@ -10,7 +10,7 @@ value_type: number
status: active
milestone: "14.3"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70496
time_frame: 7d
time_frame: all
data_source: database
data_category: optional
performance_indicator_type: []

View File

@ -10,7 +10,7 @@ value_type: number
status: active
milestone: "14.3"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70496
time_frame: 7d
time_frame: all
data_source: database
data_category: optional
performance_indicator_type: []

View File

@ -10,7 +10,7 @@ value_type: number
status: active
milestone: "14.3"
introduced_by_url: https://gilab.com/gitlab-org/gitlab/-/merge_requests/70496
time_frame: 7d
time_frame: all
data_source: database
data_category: optional
performance_indicator_type: []

View File

@ -10,7 +10,7 @@ value_type: number
status: active
milestone: "14.3"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70496
time_frame: 7d
time_frame: all
data_source: database
data_category: optional
performance_indicator_type: []

View File

@ -10,7 +10,7 @@ value_type: number
status: active
milestone: "14.3"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70496
time_frame: 7d
time_frame: all
data_source: database
data_category: optional
performance_indicator_type: []

View File

@ -0,0 +1,15 @@
# frozen_string_literal: true
class RemoveSseUsageDataFromRedis < Gitlab::Database::Migration[2.0]
disable_ddl_transaction!
def up
Gitlab::Redis::SharedState.with { |r| r.del("USAGE_STATIC_SITE_EDITOR_VIEWS") }
Gitlab::Redis::SharedState.with { |r| r.del("USAGE_STATIC_SITE_EDITOR_COMMITS") }
Gitlab::Redis::SharedState.with { |r| r.del("USAGE_STATIC_SITE_EDITOR_MERGE_REQUESTS") }
end
def down
# no-op
end
end

View File

@ -0,0 +1 @@
10676671b1893267c3c466d74a2e9a66525df7c5706eed56afe4fdcb734211cd

View File

@ -29,6 +29,14 @@ module Banzai
super + design_link_extras(issue, matches.named_captures['path'])
end
def reference_class(object_sym, tooltip: false)
super
end
def data_attributes_for(text, parent, object, **data)
super.merge(project_path: parent.full_path, iid: object.iid)
end
private
def additional_object_attributes(issue)

View File

@ -17,12 +17,6 @@ module Banzai
only_path: context[:only_path])
end
def object_link_title(object, matches)
# The method will return `nil` if object is not a commit
# allowing for properly handling the extended MR Tooltip
object_link_commit_title(object, matches)
end
def object_link_text_extras(object, matches)
extras = super
@ -53,20 +47,16 @@ module Banzai
.includes(target_project: :namespace)
end
def reference_class(object_sym, options = {})
super(object_sym, tooltip: false)
def reference_class(object_sym, tooltip: false)
super
end
def data_attributes_for(text, parent, object, **data)
super.merge(project_path: parent.full_path, iid: object.iid, mr_title: object.title)
super.merge(project_path: parent.full_path, iid: object.iid)
end
private
def object_link_commit_title(object, matches)
object_link_commit(object, matches)&.title
end
def object_link_commit_ref(object, matches)
object_link_commit(object, matches)&.short_id
end

View File

@ -11,7 +11,7 @@ module Gitlab
# this if the change to the renderer output is a new feature or a
# minor bug fix.
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/330313
CACHE_COMMONMARK_VERSION = 30
CACHE_COMMONMARK_VERSION = 31
CACHE_COMMONMARK_VERSION_START = 10
BaseError = Class.new(StandardError)

View File

@ -754,7 +754,6 @@ module Gitlab
action_monthly_active_users_web_ide_edit: redis_usage_data { counter.count_web_ide_edit_actions(**date_range) },
action_monthly_active_users_sfe_edit: redis_usage_data { counter.count_sfe_edit_actions(**date_range) },
action_monthly_active_users_snippet_editor_edit: redis_usage_data { counter.count_snippet_editor_edit_actions(**date_range) },
action_monthly_active_users_sse_edit: redis_usage_data { counter.count_sse_edit_actions(**date_range) },
action_monthly_active_users_ide_edit: redis_usage_data { counter.count_edit_using_editor(**date_range) }
}
end

View File

@ -15,7 +15,6 @@ module Gitlab
MergeRequestCounter,
DesignsCounter,
KubernetesAgentCounter,
StaticSiteEditorCounter,
DiffsCounter,
ServiceUsageDataCounter
].freeze

View File

@ -6,7 +6,6 @@ module Gitlab
EDIT_BY_SNIPPET_EDITOR = 'g_edit_by_snippet_ide'
EDIT_BY_SFE = 'g_edit_by_sfe'
EDIT_BY_WEB_IDE = 'g_edit_by_web_ide'
EDIT_BY_SSE = 'g_edit_by_sse'
EDIT_CATEGORY = 'ide_edit'
EDIT_BY_LIVE_PREVIEW = 'g_edit_by_live_preview'
@ -40,14 +39,6 @@ module Gitlab
count_unique(events, date_from, date_to)
end
def track_sse_edit_action(author:, time: Time.zone.now)
track_unique_action(EDIT_BY_SSE, author, time)
end
def count_sse_edit_actions(date_from:, date_to:)
count_unique(EDIT_BY_SSE, date_from, date_to)
end
def track_live_preview_edit_action(author:, time: Time.zone.now)
track_unique_action(EDIT_BY_LIVE_PREVIEW, author, time)
end

View File

@ -30,11 +30,6 @@
redis_slot: edit
expiry: 29
aggregation: daily
- name: g_edit_by_sse
category: ide_edit
redis_slot: edit
expiry: 29
aggregation: daily
- name: g_edit_by_snippet_ide
category: ide_edit
redis_slot: edit

View File

@ -1,16 +0,0 @@
# frozen_string_literal: true
module Gitlab
module UsageDataCounters
class StaticSiteEditorCounter < BaseCounter
KNOWN_EVENTS = %w[views commits merge_requests].freeze
PREFIX = 'static_site_editor'
class << self
def increment_views_count
count(:views)
end
end
end
end
end

View File

@ -55,7 +55,8 @@ RSpec.describe 'Dashboard Todos' do
expect(link).not_to be_nil
expect(link['data-iid']).to eq(referenced_mr.iid.to_s)
expect(link['data-project-path']).to eq(referenced_mr.project.full_path)
expect(link['data-mr-title']).to eq(referenced_mr.title)
expect(link['title']).to eq(referenced_mr.title)
expect(link['data-reference-type']).to eq('merge_request')
end
end

View File

@ -750,7 +750,7 @@
markdown: |-
Hi @gfm_user - thank you for reporting this bug (#1) we hope to fix it in %1.1 as part of !1
html: |-
<p data-sourcepos="1:1-1:92" dir="auto">Hi <a href="/gfm_user" data-user="1" data-reference-type="user" data-container="body" data-placement="top" class="gfm gfm-project_member js-user-link" title="John Doe1">@gfm_user</a> - thank you for reporting this bug (<a href="/group1/project1/-/issues/1" data-original="#1" data-link="false" data-link-reference="false" data-project="11" data-issue="11" data-issue-type="issue" data-reference-type="issue" data-container="body" data-placement="top" title="My title 1" class="gfm gfm-issue has-tooltip">#1</a>) we hope to fix it in <a href="/group1/project1/-/milestones/1" data-original="%1.1" data-link="false" data-link-reference="false" data-project="11" data-milestone="11" data-reference-type="milestone" data-container="body" data-placement="top" title="" class="gfm gfm-milestone has-tooltip">%1.1</a> as part of <a href="/group1/project1/-/merge_requests/1" data-original="!1" data-link="false" data-link-reference="false" data-project="11" data-merge-request="11" data-project-path="group1/project1" data-iid="1" data-mr-title="My title 2" data-reference-type="merge_request" data-container="body" data-placement="top" title="" class="gfm gfm-merge_request">!1</a></p>
<p data-sourcepos="1:1-1:92" dir="auto">Hi <a href="/gfm_user" data-user="1" data-reference-type="user" data-container="body" data-placement="top" class="gfm gfm-project_member js-user-link" title="John Doe1">@gfm_user</a> - thank you for reporting this bug (<a href="/group1/project1/-/issues/1" data-original="#1" data-link="false" data-link-reference="false" data-project="11" data-issue="11" data-project-path="group1/project1" data-iid="1" data-issue-type="issue" data-reference-type="issue" data-container="body" data-placement="top" title="My title 1" class="gfm gfm-issue">#1</a>) we hope to fix it in <a href="/group1/project1/-/milestones/1" data-original="%1.1" data-link="false" data-link-reference="false" data-project="11" data-milestone="11" data-reference-type="milestone" data-container="body" data-placement="top" title="" class="gfm gfm-milestone has-tooltip">%1.1</a> as part of <a href="/group1/project1/-/merge_requests/1" data-original="!1" data-link="false" data-link-reference="false" data-project="11" data-merge-request="11" data-project-path="group1/project1" data-iid="1" data-reference-type="merge_request" data-container="body" data-placement="top" title="My title 2" class="gfm gfm-merge_request">!1</a></p>
- name: strike
markdown: |-
~~del~~

View File

@ -93,7 +93,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do
it 'includes default classes' do
doc = reference_filter("Issue #{reference}")
expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip'
expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue'
end
it 'includes a data-project attribute' do
@ -112,6 +112,14 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do
expect(link.attr('data-issue')).to eq issue.id.to_s
end
it 'includes data attributes for issuable popover' do
doc = reference_filter("See #{reference}")
link = doc.css('a').first
expect(link.attr('data-project-path')).to eq project.full_path
expect(link.attr('data-iid')).to eq issue.iid.to_s
end
it 'includes a data-original attribute' do
doc = reference_filter("See #{reference}")
link = doc.css('a').first
@ -201,7 +209,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do
it 'includes default classes' do
doc = reference_filter("Fixed (#{reference}.)")
expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip'
expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue'
end
it 'ignores invalid issue IDs on the referenced project' do
@ -253,7 +261,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do
it 'includes default classes' do
doc = reference_filter("Fixed (#{reference}.)")
expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip'
expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue'
end
it 'ignores invalid issue IDs on the referenced project' do
@ -305,7 +313,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do
it 'includes default classes' do
doc = reference_filter("Fixed (#{reference}.)")
expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip'
expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue'
end
it 'ignores invalid issue IDs on the referenced project' do
@ -347,7 +355,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do
it 'includes default classes' do
doc = reference_filter("Fixed (#{reference}.)")
expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip'
expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue'
end
end
@ -378,7 +386,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do
it 'includes default classes' do
doc = reference_filter("Fixed (#{reference_link}.)")
expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip'
expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue'
end
end
@ -409,7 +417,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do
it 'includes default classes' do
doc = reference_filter("Fixed (#{reference_link}.)")
expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip'
expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue'
end
end

View File

@ -77,9 +77,9 @@ RSpec.describe Banzai::Filter::References::MergeRequestReferenceFilter do
expect(reference_filter(act).to_html).to eq exp
end
it 'has no title' do
it 'has the MR title in the title attribute' do
doc = reference_filter("Merge #{reference}")
expect(doc.css('a').first.attr('title')).to eq ""
expect(doc.css('a').first.attr('title')).to eq(merge.title)
end
it 'escapes the title attribute' do
@ -169,7 +169,6 @@ RSpec.describe Banzai::Filter::References::MergeRequestReferenceFilter do
expect(link.attr('data-project')).to eq project2.id.to_s
expect(link.attr('data-project-path')).to eq project2.full_path
expect(link.attr('data-iid')).to eq merge.iid.to_s
expect(link.attr('data-mr-title')).to eq merge.title
end
it 'ignores invalid merge IDs on the referenced project' do
@ -273,12 +272,6 @@ RSpec.describe Banzai::Filter::References::MergeRequestReferenceFilter do
expect(doc.text).to eq("See #{mr.to_reference(full: true)} (#{commit.short_id})")
end
it 'has valid title attribute' do
doc = reference_filter("See #{reference}")
expect(doc.css('a').first.attr('title')).to eq(commit.title)
end
it 'ignores invalid commit short_ids on link text' do
invalidate_commit_reference =
urls.project_merge_request_url(mr.project, mr) + "/diffs?commit_id=12345678"

View File

@ -66,18 +66,6 @@ RSpec.describe Gitlab::UsageDataCounters::EditorUniqueCounter, :clean_gitlab_red
end
end
context 'for SSE edit actions' do
it_behaves_like 'tracks and counts action' do
def track_action(params)
described_class.track_sse_edit_action(**params)
end
def count_unique(params)
described_class.count_sse_edit_actions(**params)
end
end
end
it 'can return the count of actions per user deduplicated' do
described_class.track_web_ide_edit_action(author: user1)
described_class.track_live_preview_edit_action(author: user1)

View File

@ -1,14 +0,0 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::UsageDataCounters::StaticSiteEditorCounter do
it_behaves_like 'a redis usage counter', 'StaticSiteEditor', :views
it_behaves_like 'a redis usage counter', 'StaticSiteEditor', :commits
it_behaves_like 'a redis usage counter', 'StaticSiteEditor', :merge_requests
it_behaves_like 'a redis usage counter with totals', :static_site_editor,
views: 3,
commits: 4,
merge_requests: 5
end

View File

@ -13,10 +13,10 @@ RSpec.describe Gitlab::UsageDataCounters do
describe '.count' do
subject { described_class.count(event_name) }
let(:event_name) { 'static_site_editor_views' }
let(:event_name) { 'web_ide_views' }
it 'increases a view counter' do
expect(Gitlab::UsageDataCounters::StaticSiteEditorCounter).to receive(:count).with('views')
expect(Gitlab::UsageDataCounters::WebIdeCounter).to receive(:count).with('views')
subject
end

View File

@ -754,7 +754,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
it { is_expected.to include(:kubernetes_agent_gitops_sync) }
it { is_expected.to include(:kubernetes_agent_k8s_api_proxy_request) }
it { is_expected.to include(:static_site_editor_views) }
it { is_expected.to include(:package_events_i_package_pull_package) }
it { is_expected.to include(:package_events_i_package_delete_package_by_user) }
it { is_expected.to include(:package_events_i_package_conan_push_package) }
@ -1187,12 +1186,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
counter.track_web_ide_edit_action(author: user3, time: time - 3.days)
counter.track_snippet_editor_edit_action(author: user3)
counter.track_sse_edit_action(author: user1)
counter.track_sse_edit_action(author: user1)
counter.track_sse_edit_action(author: user2)
counter.track_sse_edit_action(author: user3)
counter.track_sse_edit_action(author: user2, time: time - 3.days)
end
it 'returns the distinct count of user actions within the specified time period' do
@ -1205,8 +1198,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
action_monthly_active_users_web_ide_edit: 2,
action_monthly_active_users_sfe_edit: 2,
action_monthly_active_users_snippet_editor_edit: 2,
action_monthly_active_users_ide_edit: 3,
action_monthly_active_users_sse_edit: 3
action_monthly_active_users_ide_edit: 3
}
)
end

View File

@ -5462,6 +5462,19 @@ RSpec.describe Ci::Build do
subject
end
context 'with deployment' do
let(:environment) { create(:environment) }
let(:build) { create(:ci_build, :with_deployment, environment: environment.name, pipeline: pipeline) }
it 'updates the deployment status', :aggregate_failures do
expect(build.deployment).to receive(:sync_status_with).with(build).and_call_original
subject
expect(build.deployment.reload.status).to eq("failed")
end
end
context 'with queued builds' do
let(:traits) { [:queued] }