Skip to content

Commit cc1e91b

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent 012ed4e commit cc1e91b

File tree

84 files changed

+1509
-330
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1509
-330
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ gem 'warning', '~> 1.3.0'
347347
group :development do
348348
gem 'lefthook', '~> 1.0.0', require: false
349349
gem 'rubocop'
350-
gem 'solargraph', '~> 0.44.3', require: false
350+
gem 'solargraph', '~> 0.45.0', require: false
351351

352352
gem 'letter_opener_web', '~> 2.0.0'
353353

Gemfile.lock

+6-6
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ GEM
310310
devise (~> 4.0)
311311
railties (< 7.1)
312312
rotp (~> 6.0)
313-
diff-lcs (1.4.4)
313+
diff-lcs (1.5.0)
314314
diff_match_patch (0.1.0)
315315
diffy (3.3.0)
316316
discordrb-webhooks (3.4.2)
@@ -744,7 +744,7 @@ GEM
744744
grpc (~> 1.0)
745745
knapsack (1.21.1)
746746
rake
747-
kramdown (2.3.1)
747+
kramdown (2.3.2)
748748
rexml
749749
kramdown-parser-gfm (1.1.0)
750750
kramdown (~> 2.0)
@@ -838,7 +838,7 @@ GEM
838838
netrc (0.11.0)
839839
nio4r (2.5.8)
840840
no_proxy_fix (0.1.2)
841-
nokogiri (1.13.6)
841+
nokogiri (1.13.7)
842842
mini_portile2 (~> 2.8.0)
843843
racc (~> 1.4)
844844
notiffany (0.1.3)
@@ -1172,7 +1172,7 @@ GEM
11721172
rubocop-ast (>= 0.6.0)
11731173
ruby-progressbar (~> 1.7)
11741174
unicode-display_width (>= 1.4.0, < 2.0)
1175-
rubocop-ast (1.18.0)
1175+
rubocop-ast (1.19.1)
11761176
parser (>= 3.1.1.0)
11771177
rubocop-gitlab-security (0.1.1)
11781178
rubocop (>= 0.51)
@@ -1281,7 +1281,7 @@ GEM
12811281
slack-messenger (2.3.4)
12821282
snowplow-tracker (0.6.1)
12831283
contracts (~> 0.7, <= 0.11)
1284-
solargraph (0.44.3)
1284+
solargraph (0.45.0)
12851285
backport (~> 1.2)
12861286
benchmark
12871287
bundler (>= 1.17.2)
@@ -1730,7 +1730,7 @@ DEPENDENCIES
17301730
simplecov-lcov (~> 0.8.0)
17311731
slack-messenger (~> 2.3.4)
17321732
snowplow-tracker (~> 0.6.1)
1733-
solargraph (~> 0.44.3)
1733+
solargraph (~> 0.45.0)
17341734
spamcheck (~> 0.1.0)
17351735
spring (~> 2.1.0)
17361736
spring-commands-rspec (~> 1.0.4)

app/assets/javascripts/boards/components/board_card_inner.vue

+1
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ export default {
367367
:img-alt="avatarUrlTitle(assignee)"
368368
:img-src="avatarUrl(assignee)"
369369
:img-size="24"
370+
img-css-classes="avatar gl-mr-0!"
370371
class="js-no-trigger"
371372
tooltip-placement="bottom"
372373
>

app/assets/javascripts/editor/extensions/source_editor_markdown_livepreview_ext.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { KeyMod, KeyCode } from 'monaco-editor';
12
import { debounce } from 'lodash';
23
import { BLOB_PREVIEW_ERROR } from '~/blob_edit/constants';
34
import createFlash from '~/flash';
@@ -158,8 +159,8 @@ export class EditorMarkdownPreviewExtension {
158159
if (instance.getAction(EXTENSION_MARKDOWN_PREVIEW_ACTION_ID)) return;
159160
const actionBasis = {
160161
keybindings: [
161-
// eslint-disable-next-line no-bitwise,no-undef
162-
monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.KEY_P),
162+
// eslint-disable-next-line no-bitwise
163+
KeyMod.chord(KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_P),
163164
],
164165
contextMenuGroupId: 'navigation',
165166
contextMenuOrder: 1.5,

app/assets/javascripts/linked_resources/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export default function initLinkedResources() {
2727
render: (createElement) =>
2828
createElement('resource-links-block', {
2929
props: {
30-
issuableId,
3130
helpPath,
31+
issuableId: parseInt(issuableId, 10),
3232
canAddResourceLinks: parseBoolean(canAddResourceLinks),
3333
},
3434
}),
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { editor } from 'monaco-editor';
12
import { Sortable } from 'sortablejs';
23
import simulateDrag from './simulate_drag';
34
import simulateInput from './simulate_input';
45

56
// Export to global space for rspec to use
7+
window.localMonaco = editor;
68
window.simulateDrag = simulateDrag;
79
window.simulateInput = simulateInput;
810
window.Sortable = Sortable;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
### Widget Extensions
2+
3+
#### Telemetry
4+
5+
Telemetry is enabled by default in all widget extensions.
6+
7+
However, telemetry events are not reported until they have been marked as a "known event" with a Metric Dictionary.
8+
9+
If telemetry metrics are desired when adding a widget extension, it is important to also create known events.
10+
11+
The following steps are needed to generate these known events for a single widget:
12+
13+
1. Widgets should be named `Widget${CamelName}`.
14+
- For example: a widget for "Test Reports" should be `WidgetTestReports`
15+
1. "Compute" the widget name slug by converting the `${CamelName}` to lower-, snake-case.
16+
- The above example would be `test_reports`
17+
1. Add the new widget name slug to `lib/gitlab/usage_data_counters/merge_request_widget_extension_counter.rb` in the `WIDGETS` list.
18+
1. Ensure the GDK is running (`gdk start`)
19+
1. Generate known events on the command line with the following command. Replace `test_reports` with your appropriate name slug.
20+
```
21+
bundle exec rails generate gitlab:usage_metric_definition \
22+
counts.code_review.i_merge_request_widget_test_reports_count_view \
23+
counts.code_review.i_merge_request_widget_test_reports_count_full_report_clicked \
24+
counts.code_review.i_merge_request_widget_test_reports_count_expand \
25+
counts.code_review.i_merge_request_widget_test_reports_count_expand_success \
26+
counts.code_review.i_merge_request_widget_test_reports_count_expand_warning \
27+
counts.code_review.i_merge_request_widget_test_reports_count_expand_failed \
28+
--dir=all
29+
```
30+
1. Modify each newly generated file so that they match the existing files for MR Widget Extension telemetry.
31+
- You can find existing examples by doing a glob search like so: `metrics/**/*_i_code_review_merge_request_widget_*`
32+
- Roughly-speaking, each file should have these values:
33+
1. `description` = A plain English description of this value. Please see existing widget extension telemetry files for examples.
34+
1. `product_section` = `dev`
35+
1. `product_stage` = `create`
36+
1. `product_group` = `code_review`
37+
1. `product_category` = `code_review`
38+
1. `introduced_by_url` = `'[your MR]'`
39+
1. `options.events` = (the event in the command from above that generated this file, like `i_code_review_merge_request_widget_test_reports_count_view`)
40+
- This is how the telemetry events are linked to "metrics" so this is probably one of the more important values
41+
1. `data_source` = `redis`
42+
1. `data_category` = `optional`
43+
1. Repeat steps 5 and 6 for the HLL metrics. Replace `test_reports` with your appropriate name slug.
44+
```
45+
bundle exec rails generate gitlab:usage_metric_definition:redis_hll code_review \
46+
i_code_review_merge_request_widget_test_reports_view \
47+
i_code_review_merge_request_widget_test_reports_full_report_clicked \
48+
i_code_review_merge_request_widget_test_reports_expand \
49+
i_code_review_merge_request_widget_test_reports_expand_success \
50+
i_code_review_merge_request_widget_test_reports_expand_warning \
51+
i_code_review_merge_request_widget_test_reports_expand_failed \
52+
--class_name=RedisHLLMetric
53+
```
54+
- In step 6 for HLL, change the `data_source` to `redis_hll`.
55+
1. Add each of the HLL metrics to `lib/gitlab/usage_data_counters/known_events/code_review_events.yml`
56+
1. `name` = [the event]
57+
1. `redis_slot` = `code_review`
58+
1. `category` = `code_review`
59+
1. `aggregation` = `weekly`
60+
1. Add each event to the appropriate aggregates in `config/metrics/aggregates/code_review.yml`
61+
62+
##### New Events
63+
64+
If you are adding a new event to our known events, it will need to be included in `lib/gitlab/usage_data_counters/merge_request_widget_extension_counter.rb`. Update the list of `KNOWN_EVENTS` with the new event(s).

app/assets/stylesheets/framework/files.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,10 @@ span.idiff {
576576
}
577577
}
578578

579-
// *:nth-of-type(1n+5) - makes sure we do not render elements 5+ right away when
579+
// *:nth-of-type(1n+30) - makes sure we do not render elements 30+ right away when
580580
// viewing a file. Even though the HTML is injected in the DOM, as long as we do
581581
// not render those elements, the browser doesn't need to spend resources
582582
// calculating and repainting what's hidden.
583-
.file-holder [data-loading] .file-content *:nth-of-type(1n+5) {
583+
.file-holder [data-loading] .file-content *:nth-of-type(1n+30) {
584584
@include gl-display-none;
585585
}

app/controllers/profiles/personal_access_tokens_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def set_index_vars
5858
end
5959

6060
def active_personal_access_tokens
61-
tokens = finder(state: 'active', sort: 'expires_at_asc').execute
61+
tokens = finder(state: 'active', sort: 'expires_at_asc_id_desc').execute
6262

6363
if Feature.enabled?('access_token_pagination')
6464
tokens = tokens.page(page)

app/models/ci/pipeline.rb

+58-18
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class Pipeline < Ci::ApplicationRecord
102102
has_one :chat_data, class_name: 'Ci::PipelineChatData'
103103

104104
has_many :triggered_pipelines, through: :sourced_pipelines, source: :pipeline
105+
# Only includes direct and not nested children
105106
has_many :child_pipelines, -> { merge(Ci::Sources::Pipeline.same_project) }, through: :sourced_pipelines, source: :pipeline
106107
has_one :triggered_by_pipeline, through: :source_pipeline, source: :source_pipeline
107108
has_one :parent_pipeline, -> { merge(Ci::Sources::Pipeline.same_project) }, through: :source_pipeline, source: :source_pipeline
@@ -592,26 +593,20 @@ def auto_canceled?
592593
canceled? && auto_canceled_by_id?
593594
end
594595

595-
def cancel_running(retries: 1)
596-
preloaded_relations = [:project, :pipeline, :deployment, :taggings]
596+
# Cancel a pipelines cancelable jobs and optionally it's child pipelines cancelable jobs
597+
# retries - # of times to retry if errors
598+
# cascade_to_children - if true cancels all related child pipelines for parent child pipelines
599+
# auto_canceled_by_pipeline_id - store the pipeline_id of the pipeline that triggered cancellation
600+
# execute_async - if true cancel the children asyncronously
601+
def cancel_running(retries: 1, cascade_to_children: true, auto_canceled_by_pipeline_id: nil, execute_async: true)
602+
update(auto_canceled_by_id: auto_canceled_by_pipeline_id) if auto_canceled_by_pipeline_id
597603

598-
retry_lock(cancelable_statuses, retries, name: 'ci_pipeline_cancel_running') do |cancelables|
599-
cancelables.find_in_batches do |batch|
600-
Preloaders::CommitStatusPreloader.new(batch).execute(preloaded_relations)
604+
cancel_jobs(cancelable_statuses, retries: retries, auto_canceled_by_pipeline_id: auto_canceled_by_pipeline_id)
601605

602-
batch.each do |job|
603-
yield(job) if block_given?
604-
job.cancel
605-
end
606-
end
607-
end
608-
end
609-
610-
def auto_cancel_running(pipeline, retries: 1)
611-
update(auto_canceled_by: pipeline)
612-
613-
cancel_running(retries: retries) do |job|
614-
job.auto_canceled_by = pipeline
606+
if cascade_to_children && project.cascade_cancel_pipelines_enabled?
607+
# cancel any bridges that could spin up new child pipelines
608+
cancel_jobs(bridges_in_self_and_descendants.cancelable, retries: retries, auto_canceled_by_pipeline_id: auto_canceled_by_pipeline_id)
609+
cancel_children(auto_canceled_by_pipeline_id: auto_canceled_by_pipeline_id, execute_async: execute_async)
615610
end
616611
end
617612

@@ -953,6 +948,10 @@ def builds_in_self_and_descendants
953948
Ci::Build.latest.where(pipeline: self_and_descendants)
954949
end
955950

951+
def bridges_in_self_and_descendants
952+
Ci::Bridge.latest.where(pipeline: self_and_descendants)
953+
end
954+
956955
def environments_in_self_and_descendants(deployment_status: nil)
957956
# We limit to 100 unique environments for application safety.
958957
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/340781#note_699114700
@@ -986,6 +985,11 @@ def self_and_descendants
986985
object_hierarchy(project_condition: :same).base_and_descendants
987986
end
988987

988+
# With only parent-child pipelines
989+
def all_child_pipelines
990+
object_hierarchy(project_condition: :same).descendants
991+
end
992+
989993
def self_and_descendants_complete?
990994
self_and_descendants.all?(&:complete?)
991995
end
@@ -1323,6 +1327,42 @@ def age_in_minutes
13231327

13241328
private
13251329

1330+
def cancel_jobs(jobs, retries: 1, auto_canceled_by_pipeline_id: nil)
1331+
retry_lock(jobs, retries, name: 'ci_pipeline_cancel_running') do |statuses|
1332+
preloaded_relations = [:project, :pipeline, :deployment, :taggings]
1333+
1334+
statuses.find_in_batches do |status_batch|
1335+
relation = CommitStatus.where(id: status_batch)
1336+
Preloaders::CommitStatusPreloader.new(relation).execute(preloaded_relations)
1337+
1338+
relation.each do |job|
1339+
job.auto_canceled_by_id = auto_canceled_by_pipeline_id if auto_canceled_by_pipeline_id
1340+
job.cancel
1341+
end
1342+
end
1343+
end
1344+
end
1345+
1346+
# For parent child-pipelines only (not multi-project)
1347+
def cancel_children(auto_canceled_by_pipeline_id: nil, execute_async: true)
1348+
all_child_pipelines.each do |child_pipeline|
1349+
if execute_async
1350+
::Ci::CancelPipelineWorker.perform_async(
1351+
child_pipeline.id,
1352+
auto_canceled_by_pipeline_id
1353+
)
1354+
else
1355+
child_pipeline.cancel_running(
1356+
# cascade_to_children is false because we iterate through children
1357+
# we also cancel bridges prior to prevent more children
1358+
cascade_to_children: false,
1359+
execute_async: execute_async,
1360+
auto_canceled_by_pipeline_id: auto_canceled_by_pipeline_id
1361+
)
1362+
end
1363+
end
1364+
end
1365+
13261366
def add_message(severity, content)
13271367
messages.build(severity: severity, content: content)
13281368
end

app/models/personal_access_token.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class PersonalAccessToken < ApplicationRecord
3333
scope :preload_users, -> { preload(:user) }
3434
scope :order_expires_at_asc, -> { reorder(expires_at: :asc) }
3535
scope :order_expires_at_desc, -> { reorder(expires_at: :desc) }
36+
scope :order_expires_at_asc_id_desc, -> { reorder(expires_at: :asc, id: :desc) }
3637
scope :project_access_token, -> { includes(:user).where(user: { user_type: :project_bot }) }
3738
scope :owner_is_human, -> { includes(:user).where(user: { user_type: :human }) }
3839

@@ -77,7 +78,8 @@ def self.simple_sorts
7778
super.merge(
7879
{
7980
'expires_at_asc' => -> { order_expires_at_asc },
80-
'expires_at_desc' => -> { order_expires_at_desc }
81+
'expires_at_desc' => -> { order_expires_at_desc },
82+
'expires_at_asc_id_desc' => -> { order_expires_at_asc_id_desc }
8183
}
8284
)
8385
end

app/models/project.rb

+7
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,13 @@ def emails_disabled?
10411041
def emails_enabled?
10421042
!emails_disabled?
10431043
end
1044+
1045+
def cascade_cancel_pipelines_enabled?
1046+
strong_memoize(:cascade_cancel_pipelines_enabled) do
1047+
Feature.enabled?(:ci_parent_pipeline_cancels_children, self)
1048+
end
1049+
end
1050+
10441051
override :lfs_enabled?
10451052
def lfs_enabled?
10461053
return namespace.lfs_enabled? if self[:lfs_enabled].nil?
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
# rubocop: disable Gitlab/NamespacedClass
4+
class GroupAccessTokenEntity < API::Entities::PersonalAccessToken
5+
include Gitlab::Routing
6+
7+
expose :revoke_path do |token, options|
8+
group = options.fetch(:group)
9+
10+
next unless group
11+
12+
revoke_group_settings_access_token_path(
13+
id: token,
14+
group_id: group.path)
15+
end
16+
17+
expose :access_level do |token, options|
18+
group = options.fetch(:group)
19+
20+
next unless group
21+
next unless token.user
22+
23+
group.member(token.user)&.access_level
24+
end
25+
end
26+
# rubocop: enable Gitlab/NamespacedClass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
# rubocop: disable Gitlab/NamespacedClass
4+
class GroupAccessTokenSerializer < BaseSerializer
5+
entity GroupAccessTokenEntity
6+
end
7+
# rubocop: enable Gitlab/NamespacedClass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
# rubocop: disable Gitlab/NamespacedClass
4+
class PersonalAccessTokenEntity < API::Entities::PersonalAccessToken
5+
include Gitlab::Routing
6+
7+
expose :revoke_path do |token, options|
8+
revoke_profile_personal_access_token_path(token)
9+
end
10+
end
11+
# rubocop: enable Gitlab/NamespacedClass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
# rubocop: disable Gitlab/NamespacedClass
4+
class PersonalAccessTokenSerializer < BaseSerializer
5+
entity PersonalAccessTokenEntity
6+
end
7+
# rubocop: enable Gitlab/NamespacedClass

0 commit comments

Comments
 (0)