Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-08-15 03:11:57 +00:00
parent 25c9c07a16
commit 1b5891ee8c
22 changed files with 224 additions and 195 deletions

View File

@ -318,7 +318,7 @@ ul.related-merge-requests > li gl-emoji {
.issuable-header-slide-enter-active,
.issuable-header-slide-leave-active {
@include gl-transition-slow;
@include gl-transition-medium;
}
.issuable-header-slide-enter,

View File

@ -147,7 +147,8 @@ module Notes
end
def track_note_creation_usage_for_issues(note)
Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_added_action(author: note.author)
Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_added_action(author: note.author,
project: project)
end
def track_note_creation_usage_for_merge_requests(note)

View File

@ -15,7 +15,8 @@ module Notes
private
def track_note_removal_usage_for_issues(note)
Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_removed_action(author: note.author)
Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_removed_action(author: note.author,
project: project)
end
def track_note_removal_usage_for_merge_requests(note)

View File

@ -86,7 +86,8 @@ module Notes
end
def track_note_edit_usage_for_issues(note)
Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_edited_action(author: note.author)
Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_edited_action(author: note.author,
project: project)
end
def track_note_edit_usage_for_merge_requests(note)

View File

@ -327,7 +327,9 @@ module SystemNotes
cross_reference = noteable_ref.to_reference(project)
body = "cloned #{direction} #{cross_reference}"
issue_activity_counter.track_issue_cloned_action(author: author) if noteable.is_a?(Issue) && direction == :to
if noteable.is_a?(Issue) && direction == :to
issue_activity_counter.track_issue_cloned_action(author: author, project: project)
end
create_note(NoteSummary.new(noteable, project, author, body, action: 'cloned', created_at: created_at))
end

View File

@ -1,20 +0,0 @@
---
description: Epic was changed on an issue
category: issues_edit
action: g_project_management_issue_changed_epic
identifiers:
- project
- user
- namespace
product_section: dev
product_stage: plan
product_group: project_management
product_category: issue_tracking
milestone: "15.2"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91443
distributions:
- ee
tiers:
- premium
- ultimate

View File

@ -1,20 +0,0 @@
---
description: Health status was changed on an issue
category: issues_edit
action: g_project_management_issue_health_status_changed
identifiers:
- project
- user
- namespace
product_section: dev
product_stage: plan
product_group: project_management
product_category: issue_tracking
milestone: "15.2"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91443
distributions:
- ee
tiers:
- premium
- ultimate

View File

@ -1,20 +0,0 @@
---
description: Issue's iteration was changed
category: issues_edit
action: g_project_management_issue_iteration_changed
identifiers:
- project
- user
- namespace
product_section: dev
product_stage: plan
product_group: project_management
product_category: issue_tracking
milestone: "15.2"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91443
distributions:
- ee
tiers:
- premium
- ultimate

View File

@ -1,20 +0,0 @@
---
description: An issue was removed from an epic
category: issues_edit
action: g_project_management_issue_removed_from_epic
identifiers:
- project
- user
- namespace
product_section: dev
product_stage: plan
product_group: project_management
product_category: issue_tracking
milestone: "15.2"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91443
distributions:
- ee
tiers:
- premium
- ultimate

View File

@ -1,20 +0,0 @@
---
description: Issue's weight was changed
category: issues_edit
action: g_project_management_issue_weight_changed
identifiers:
- project
- user
- namespace
product_section: dev
product_stage: plan
product_group: project_management
product_category: issue_tracking
milestone: "15.2"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91443
distributions:
- ee
tiers:
- premium
- ultimate

View File

@ -1,20 +1,25 @@
---
description: Issue was added to an epic
description: Issue usage event
category: issues_edit
action: g_project_management_issue_added_to_epic
action: perform_issue_action
label_description:
property_description: the name of the performed action
value_description:
extra_properties:
identifiers:
- namespace
- project
- user
- namespace
product_section: dev
product_stage: plan
product_group: project_management
product_category: issue_tracking
milestone: "15.2"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91443
milestone: "15.3"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91659
distributions:
- ce
- ee
tiers:
- free
- premium
- ultimate

View File

@ -6,25 +6,86 @@
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Dart.gitlab-ci.yml
# https://hub.docker.com/r/google/dart
image: google/dart:2.8.4
# https://hub.docker.com/_/dart
image: dart:2.17
variables:
# Use to learn more:
# pub run test --help
# To learn more go to https://dart.dev/tools/dart-test
# Or run `dart test --help`
PUB_VARS: "--platform vm --timeout 30s --concurrency=6 --test-randomize-ordering-seed=random --reporter=expanded"
.use-pub-cache-bin:
# Define commands that need to be executed before each job.
before_script:
# Set PUB_CACHE either here or in the CI/CD Settings if you have multiple jobs that use dart commands.
# PUB_CACHE is used by the `dart pub` command, it needs to be set so package dependencies are stored at the project-level for CI/CD operations.
- export PUB_CACHE=".pub-cache"
- export PATH="$PATH:$HOME/$PUB_CACHE/bin"
# Cache generated files and plugins between builds.
.upload-cache:
cache:
when: 'on_success'
paths:
- .pub-cache/bin/
- .pub-cache/global_packages/
- .pub-cache/hosted/
- .dart_tool/
- .packages
# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
cache:
paths:
- .pub-cache/global_packages
.download-cache:
cache:
paths:
- .dart_tool/
- .packages
policy: pull
before_script:
- export PATH="$PATH:$HOME/.pub-cache/bin"
- pub get --no-precompile
test:
stage: test
install-dependencies:
stage: .pre
extends:
- .use-pub-cache-bin
- .upload-cache
script:
- pub run test $PUB_VARS
- dart pub get --no-precompile
build:
stage: build
needs:
- install-dependencies
extends:
- .use-pub-cache-bin
- .upload-cache
script:
- dart pub get --offline --precompile
unit-test:
stage: test
needs:
- build
extends:
- .use-pub-cache-bin
- .download-cache
script:
- dart test $PUB_VARS
lint-test:
stage: test
needs:
- install-dependencies
extends:
- .use-pub-cache-bin
- .download-cache
script:
- dart analyze .
format-test:
stage: test
needs:
- install-dependencies
extends:
- .use-pub-cache-bin
- .download-cache
script:
- dart format --set-exit-if-changed bin/ lib/ test/

View File

@ -4,6 +4,8 @@ module Gitlab
module UsageDataCounters
module IssueActivityUniqueCounter
ISSUE_CATEGORY = 'issues_edit'
ISSUE_ACTION = 'perform_issue_action'
ISSUE_LABEL = 'redis_hll_counters.issues_edit.issues_edit_total_unique_counts_monthly'
ISSUE_ASSIGNEE_CHANGED = 'g_project_management_issue_assignee_changed'
ISSUE_CREATED = 'g_project_management_issue_created'
@ -126,42 +128,48 @@ module Gitlab
track_unique_action(ISSUE_TIME_SPENT_CHANGED, author)
end
def track_issue_comment_added_action(author:)
def track_issue_comment_added_action(author:, project:)
track_snowplow_action(ISSUE_COMMENT_ADDED, author, project)
track_unique_action(ISSUE_COMMENT_ADDED, author)
end
def track_issue_comment_edited_action(author:)
def track_issue_comment_edited_action(author:, project:)
track_snowplow_action(ISSUE_COMMENT_EDITED, author, project)
track_unique_action(ISSUE_COMMENT_EDITED, author)
end
def track_issue_comment_removed_action(author:)
def track_issue_comment_removed_action(author:, project:)
track_snowplow_action(ISSUE_COMMENT_REMOVED, author, project)
track_unique_action(ISSUE_COMMENT_REMOVED, author)
end
def track_issue_cloned_action(author:)
def track_issue_cloned_action(author:, project:)
track_snowplow_action(ISSUE_CLONED, author, project)
track_unique_action(ISSUE_CLONED, author)
end
private
def track_unique_action(action, author)
return unless author
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(action, values: author.id)
end
def track_snowplow_action(action, author, project)
return unless Feature.enabled?(:route_hll_to_snowplow_phase2, project&.namespace)
return unless Feature.enabled?(:route_hll_to_snowplow_phase2, project.namespace)
return unless author
Gitlab::Tracking.event(
ISSUE_CATEGORY,
action.to_s,
ISSUE_ACTION,
label: ISSUE_LABEL,
property: action,
project: project,
namespace: project&.namespace,
namespace: project.namespace,
user: author
)
end
def track_unique_action(action, author)
return unless author
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(action, values: author.id)
end
end
end
end

View File

@ -22,7 +22,7 @@ describe('IDE store file mutations', () => {
active: true,
});
expect(localFile.active).toBeTruthy();
expect(localFile.active).toBe(true);
});
it('sets pending tab as not active', () => {
@ -41,7 +41,7 @@ describe('IDE store file mutations', () => {
it('adds into opened files', () => {
mutations.TOGGLE_FILE_OPEN(localState, localFile.path);
expect(localFile.opened).toBeTruthy();
expect(localFile.opened).toBe(true);
expect(localState.openFiles.length).toBe(1);
});
@ -50,7 +50,7 @@ describe('IDE store file mutations', () => {
mutations.TOGGLE_FILE_OPEN(localState, localFile.path);
mutations.TOGGLE_FILE_OPEN(localState, localFile.path);
expect(localFile.opened).toBeFalsy();
expect(localFile.opened).toBe(false);
expect(localState.openFiles.length).toBe(0);
});
});
@ -162,7 +162,7 @@ describe('IDE store file mutations', () => {
callMutationForFile(localFile);
expect(localFile.raw).toBeFalsy();
expect(localFile.raw).toEqual('');
expect(localState.stagedFiles[0].raw).toBe('testing');
});
@ -172,7 +172,7 @@ describe('IDE store file mutations', () => {
callMutationForFile(localFile);
expect(localFile.raw).toBeFalsy();
expect(localFile.raw).toEqual('');
expect(localFile.content).toBe('testing');
});
@ -202,7 +202,7 @@ describe('IDE store file mutations', () => {
callMutationForFile(localFile);
expect(localFile.raw).toBeFalsy();
expect(localFile.raw).toEqual('');
expect(localState.stagedFiles[0].raw).toBe('testing');
});
});
@ -239,7 +239,7 @@ describe('IDE store file mutations', () => {
});
expect(localFile.content).toBe('testing');
expect(localFile.changed).toBeTruthy();
expect(localFile.changed).toBe(true);
});
it('sets changed if file is a temp file', () => {
@ -250,7 +250,7 @@ describe('IDE store file mutations', () => {
content: '',
});
expect(localFile.changed).toBeTruthy();
expect(localFile.changed).toBe(true);
});
});
@ -329,7 +329,7 @@ describe('IDE store file mutations', () => {
mutations.DISCARD_FILE_CHANGES(localState, localFile.path);
expect(localFile.content).toBe('');
expect(localFile.changed).toBeFalsy();
expect(localFile.changed).toBe(false);
});
it('adds to root tree if deleted', () => {
@ -527,7 +527,7 @@ describe('IDE store file mutations', () => {
changed: true,
});
expect(localFile.changed).toBeTruthy();
expect(localFile.changed).toBe(true);
});
});

View File

@ -6,7 +6,12 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
let_it_be(:user1) { build(:user, id: 1) }
let_it_be(:user2) { build(:user, id: 2) }
let_it_be(:user3) { build(:user, id: 3) }
let_it_be(:project) { build(:project) }
let_it_be(:category) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_CATEGORY }
let_it_be(:event_action) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_ACTION }
let_it_be(:event_label) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_LABEL }
let(:event_property) { action }
let(:time) { Time.zone.now }
context 'for Issue title edit actions' do
@ -120,8 +125,8 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
context 'for Issue cloned actions' do
it_behaves_like 'a daily tracked issuable event' do
let(:action) { described_class::ISSUE_CLONED }
it_behaves_like 'daily tracked issuable snowplow and service ping events with project' do
let_it_be(:action) { described_class::ISSUE_CLONED }
def track_action(params)
described_class.track_issue_cloned_action(**params)
@ -239,8 +244,8 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
end
context 'for Issue comment added actions' do
it_behaves_like 'a daily tracked issuable event' do
context 'for Issue comment added actions', :snowplow do
it_behaves_like 'daily tracked issuable snowplow and service ping events with project' do
let(:action) { described_class::ISSUE_COMMENT_ADDED }
def track_action(params)
@ -249,8 +254,8 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
end
context 'for Issue comment edited actions' do
it_behaves_like 'a daily tracked issuable event' do
context 'for Issue comment edited actions', :snowplow do
it_behaves_like 'daily tracked issuable snowplow and service ping events with project' do
let(:action) { described_class::ISSUE_COMMENT_EDITED }
def track_action(params)
@ -259,8 +264,8 @@ RSpec.describe Gitlab::UsageDataCounters::IssueActivityUniqueCounter, :clean_git
end
end
context 'for Issue comment removed actions' do
it_behaves_like 'a daily tracked issuable event' do
context 'for Issue comment removed actions', :snowplow do
it_behaves_like 'daily tracked issuable snowplow and service ping events with project' do
let(:action) { described_class::ISSUE_COMMENT_REMOVED }
def track_action(params)

View File

@ -69,20 +69,31 @@ RSpec.describe Notes::CreateService do
end
end
it 'tracks issue comment usage data', :clean_gitlab_redis_shared_state do
event = Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_ADDED
counter = Gitlab::UsageDataCounters::HLLRedisCounter
describe 'event tracking', :snowplow do
let(:event) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_ADDED }
let(:execute_create_service) { described_class.new(project, user, opts).execute }
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_added_action).with(author: user).and_call_original
expect do
described_class.new(project, user, opts).execute
end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1)
end
it 'tracks issue comment usage data', :clean_gitlab_redis_shared_state do
counter = Gitlab::UsageDataCounters::HLLRedisCounter
it 'does not track merge request usage data' do
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter).not_to receive(:track_create_comment_action)
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_added_action)
.with(author: user, project: project)
.and_call_original
expect do
execute_create_service
end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1)
end
described_class.new(project, user, opts).execute
it 'does not track merge request usage data' do
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter).not_to receive(:track_create_comment_action)
execute_create_service
end
it_behaves_like 'issue_edit snowplow tracking' do
let(:property) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_ADDED }
subject(:service_action) { execute_create_service }
end
end
context 'in a merge request' do

View File

@ -25,15 +25,25 @@ RSpec.describe Notes::DestroyService do
.to change { user.todos_pending_count }.from(1).to(0)
end
it 'tracks issue comment removal usage data', :clean_gitlab_redis_shared_state do
note = create(:note, project: project, noteable: issue)
event = Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_REMOVED
counter = Gitlab::UsageDataCounters::HLLRedisCounter
describe 'comment removed event tracking', :snowplow do
let(:property) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_REMOVED }
let(:note) { create(:note, project: project, noteable: issue) }
let(:service_action) { described_class.new(project, user).execute(note) }
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_removed_action).with(author: user).and_call_original
expect do
described_class.new(project, user).execute(note)
end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1)
it 'tracks issue comment removal usage data', :clean_gitlab_redis_shared_state do
counter = Gitlab::UsageDataCounters::HLLRedisCounter
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_removed_action)
.with(author: user, project: project)
.and_call_original
expect do
service_action
end.to change { counter.unique_events(event_names: property, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1)
end
it_behaves_like 'issue_edit snowplow tracking' do
subject(:execute_service_action) { service_action }
end
end
it 'tracks merge request usage data' do

View File

@ -47,21 +47,31 @@ RSpec.describe Notes::UpdateService do
end
end
it 'does not track usage data when params is blank' do
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).not_to receive(:track_issue_comment_edited_action)
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter).not_to receive(:track_edit_comment_action)
describe 'event tracking', :snowplow do
let(:event) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_EDITED }
update_note({})
end
it 'does not track usage data when params is blank' do
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).not_to receive(:track_issue_comment_edited_action)
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter).not_to receive(:track_edit_comment_action)
it 'tracks issue usage data', :clean_gitlab_redis_shared_state do
event = Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_EDITED
counter = Gitlab::UsageDataCounters::HLLRedisCounter
update_note({})
end
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_edited_action).with(author: user).and_call_original
expect do
update_note(note: 'new text')
end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1)
it 'tracks issue usage data', :clean_gitlab_redis_shared_state do
counter = Gitlab::UsageDataCounters::HLLRedisCounter
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_edited_action)
.with(author: user, project: project)
.and_call_original
expect do
update_note(note: 'new text')
end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1)
end
it_behaves_like 'issue_edit snowplow tracking' do
let(:property) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_EDITED }
subject(:service_action) { update_note(note: 'new text') }
end
end
context 'when note text was changed' do

View File

@ -712,15 +712,20 @@ RSpec.describe ::SystemNotes::IssuablesService do
end
end
context 'cloned to' do
context 'cloned to', :snowplow do
let(:direction) { :to }
it 'tracks usage' do
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter)
.to receive(:track_issue_cloned_action).with(author: author)
.to receive(:track_issue_cloned_action).with(author: author, project: project )
subject
end
it_behaves_like 'issue_edit snowplow tracking' do
let(:property) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_CLONED }
let(:user) { author }
end
end
end
end

View File

@ -74,12 +74,10 @@ RSpec.shared_examples 'a daily tracked issuable snowplow and service ping events
end
end
RSpec.shared_examples 'a daily tracked issuable snowplow and service ping events' do
RSpec.shared_examples 'daily tracked issuable snowplow and service ping events with project' do
it_behaves_like 'a daily tracked issuable snowplow and service ping events for given event params' do
let_it_be(:track_params) { { project: project } }
let_it_be(:event_params) { track_params.merge(namespace: project.namespace) }
let_it_be(:category) { 'issues_edit' }
let_it_be(:event_action) { action }
let(:track_params) { { project: project } }
let(:event_params) { track_params.merge(label: event_label, property: event_property, namespace: project.namespace) }
end
end

View File

@ -0,0 +1,11 @@
# frozen_string_literal: true
shared_examples 'issue_edit snowplow tracking' do
let(:category) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_CATEGORY }
let(:action) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_ACTION }
let(:label) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_LABEL }
let(:namespace) { project.namespace }
let(:feature_flag_name) { :route_hll_to_snowplow_phase2 }
it_behaves_like 'Snowplow event tracking'
end

View File

@ -32,7 +32,7 @@ diffs_dir.glob('**/*').each do |path|
next unless path.to_s.end_with?('_spec.rb.diff')
specs_count += 1
quarantine_specs_count += 1 if path.read.match?(/^\+.*, quarantine:/)
quarantine_specs_count += 1 if path.read.match?(/^\+.*,? quarantine:/)
end
# Run QA tests if there are no specs. E.g., when the MR changes QA framework files.