提交 d72fedf1 编写于 作者: G GitLab Bot

Add latest changes from gitlab-org/gitlab@master

上级 497b7315
......@@ -68,7 +68,7 @@ GitLab is an open source project and we are very happy to accept community contr
To work on GitLab itself, we recommend setting up your development environment with [the GitLab Development Kit](https://gitlab.com/gitlab-org/gitlab-development-kit).
If you do not use the GitLab Development Kit you need to install and setup all the dependencies yourself, this is a lot of work and error prone.
One small thing you also have to do when installing it yourself is to copy the example development unicorn configuration file:
One small thing you also have to do when installing it yourself is to copy the example development Unicorn configuration file:
cp config/unicorn.rb.example.development config/unicorn.rb
......@@ -79,8 +79,8 @@ Instructions on how to start GitLab and how to run the tests can be found in the
GitLab is a Ruby on Rails application that runs on the following software:
- Ubuntu/Debian/CentOS/RHEL/OpenSUSE
- Ruby (MRI) 2.6.5
- Git 2.8.4+
- Ruby (MRI) 2.6.6
- Git 2.24+
- Redis 4.0+
- PostgreSQL 11+
......
......@@ -103,8 +103,8 @@ class IssuableFinder
items = filter_negated_items(items)
# This has to be last as we use a CTE as an optimization fence
# for counts by passing the force_cte param and enabling the
# attempt_group_search_optimizations feature flag
# for counts by passing the force_cte param and passing the
# attempt_group_search_optimizations param
# https://www.postgresql.org/docs/current/static/queries-with.html
items = by_search(items)
......@@ -229,8 +229,7 @@ class IssuableFinder
end
def attempt_group_search_optimizations?
params[:attempt_group_search_optimizations] &&
Feature.enabled?(:attempt_group_search_optimizations, default_enabled: true)
params[:attempt_group_search_optimizations]
end
def attempt_project_search_optimizations?
......
......@@ -2,16 +2,35 @@
module Ci
module PipelinesHelper
include Gitlab::Ci::Warnings
def pipeline_warnings(pipeline)
return unless pipeline.warning_messages.any?
content_tag(:div, class: 'alert alert-warning') do
content_tag(:h4, 'Warning:') <<
content_tag(:div) do
pipeline.warning_messages.each do |warning|
concat(markdown(warning.content))
end
end
total_warnings = pipeline.warning_messages.length
message = warning_header(total_warnings)
content_tag(:div, class: 'bs-callout bs-callout-warning') do
content_tag(:details) do
concat content_tag(:summary, message, class: 'gl-mb-2')
warning_markdown(pipeline) { |markdown| concat markdown }
end
end
end
def warning_header(count)
message = _("%{total_warnings} warning(s) found:") % { total_warnings: count }
return message unless count > MAX_LIMIT
_("%{message} showing first %{warnings_displayed}") % { message: message, warnings_displayed: MAX_LIMIT }
end
private
def warning_markdown(pipeline)
pipeline.warning_messages(limit: MAX_LIMIT).each do |warning|
yield markdown(warning.content)
end
end
end
......
......@@ -677,8 +677,10 @@ module Ci
messages.select(&:error?)
end
def warning_messages
messages.select(&:warning?)
def warning_messages(limit: nil)
messages.select(&:warning?).tap do |warnings|
break warnings.take(limit) if limit
end
end
# Manually set the notes for a Ci::Pipeline
......
......@@ -22,7 +22,7 @@ module Issuable
end
create_due_date_note if issuable.previous_changes.include?('due_date')
create_milestone_note(old_milestone) if issuable.previous_changes.include?('milestone_id')
create_milestone_change_event(old_milestone) if issuable.previous_changes.include?('milestone_id')
create_labels_note(old_labels) if old_labels && issuable.labels != old_labels
end
end
......@@ -94,23 +94,11 @@ module Issuable
SystemNoteService.change_time_spent(issuable, issuable.project, issuable.time_spent_user)
end
def create_milestone_note(old_milestone)
if milestone_changes_tracking_enabled?
create_milestone_change_event(old_milestone)
else
SystemNoteService.change_milestone(issuable, issuable.project, current_user, issuable.milestone)
end
end
def create_milestone_change_event(old_milestone)
ResourceEvents::ChangeMilestoneService.new(issuable, current_user, old_milestone: old_milestone)
.execute
end
def milestone_changes_tracking_enabled?
::Feature.enabled?(:track_resource_milestone_change_events, issuable.project, default_enabled: true)
end
def create_due_date_note
SystemNoteService.change_due_date(issuable, issuable.project, current_user, issuable.due_date)
end
......
......@@ -41,10 +41,6 @@ module SystemNoteService
::SystemNotes::IssuablesService.new(noteable: issuable, project: project, author: author).change_issuable_assignees(old_assignees)
end
def change_milestone(noteable, project, author, milestone)
::SystemNotes::IssuablesService.new(noteable: noteable, project: project, author: author).change_milestone(milestone)
end
def relate_issue(noteable, noteable_ref, user)
::SystemNotes::IssuablesService.new(noteable: noteable, project: noteable.project, author: user).relate_issue(noteable_ref)
end
......
......@@ -77,24 +77,6 @@ module SystemNotes
create_note(NoteSummary.new(noteable, project, author, body, action: 'assignee'))
end
# Called when the milestone of a Noteable is changed
#
# milestone - Milestone being assigned, or nil
#
# Example Note text:
#
# "removed milestone"
#
# "changed milestone to 7.11"
#
# Returns the created Note object
def change_milestone(milestone)
format = milestone&.group_milestone? ? :name : :iid
body = milestone.nil? ? 'removed milestone' : "changed milestone to #{milestone.to_reference(project, format: format)}"
create_note(NoteSummary.new(noteable, project, author, body, action: 'milestone'))
end
# Called when the title of a Noteable is changed
#
# old_title - Previous String title
......
- if warnings
- warnings.each do |warning|
- total_warnings = warnings.length
- message = warning_header(total_warnings)
- if warnings.any?
.bs-callout.bs-callout-warning
%p
%b= _("Warning:")
= markdown(warning)
%details
%summary.gl-mb-2= message
- warnings.each do |warning|
= markdown(warning)
- total_warnings = warnings.length
- message = warning_header(total_warnings)
- if warnings.any?
- warnings.map(&:content).each do |warning|
.bs-callout.bs-callout-warning
%p
%b= _("Warning:")
.bs-callout.bs-callout-warning
%details
%summary.gl-mb-2= message
- warnings.map(&:content).each do |warning|
= markdown(warning)
......@@ -19,7 +19,7 @@
- lint_link_start = '<a href="%{url}">'.html_safe % { url: lint_link_url }
= s_('You can also test your %{gitlab_ci_yml} in %{lint_link_start}CI Lint%{lint_link_end}').html_safe % { gitlab_ci_yml: '.gitlab-ci.yml', lint_link_start: lint_link_start, lint_link_end: '</a>'.html_safe }
= render "projects/pipelines/pipeline_warnings", warnings: @pipeline.warning_messages
= render "projects/pipelines/pipeline_warnings", warnings: @pipeline.warning_messages(limit: Gitlab::Ci::Warnings::MAX_LIMIT)
= render "projects/pipelines/with_tabs", pipeline: @pipeline, pipeline_has_errors: pipeline_has_errors
.js-pipeline-details-vue{ data: { endpoint: project_pipeline_path(@project, @pipeline, format: :json) } }
---
title: Remove attempt_group_search_optimizations feature flag
merge_request: 40881
author: gaga5lala
type: other
---
title: Group pipeline warnings and make them collapsible
merge_request: 39634
author:
type: changed
......@@ -74,7 +74,7 @@ let(:project) { create(:project) }
let(:project) { build(:project) }
```
[Factory Profiler](https://test-prof.evilmartians.io/#/profilers/factory_prof) can help to identify repetitive database persistance via factories.
[Factory Profiler](https://test-prof.evilmartians.io/#/profilers/factory_prof) can help to identify repetitive database persistence via factories.
```shell
# run test for path
......
......@@ -84,7 +84,7 @@ See the [`RSpec.describe` outer block](#the-outer-rspecdescribe-block)
CAUTION: **Deprecation notice:**
The outer `context` [was deprecated](https://gitlab.com/gitlab-org/quality/team-tasks/-/issues/550) in `13.2`
in adherance to RSpec 4.0 specifications. Use `RSpec.describe` instead.
in adherence to RSpec 4.0 specifications. Use `RSpec.describe` instead.
### The outer `RSpec.describe` block
......
......@@ -230,7 +230,7 @@ it('exists', () => {
// Best
// NOTE: both mount and shallowMount work as long as a DOM element is available
// Finds a properly formatted link with an accessable name of "Click Me"
// Finds a properly formatted link with an accessible name of "Click Me"
getByRole(el, 'link', { name: /Click Me/i })
getByRole(el, 'link', { name: 'Click Me' })
// Finds any element with the text "Click Me"
......
......@@ -154,9 +154,9 @@ For project milestones in [GitLab Starter](https://about.gitlab.com/pricing/), a
![burndown chart](img/burndown_chart.png)
### Group Burndown Charts **(PREMIUM)**
### Group Burndown Charts **(STARTER)**
For group milestones in [GitLab Premium](https://about.gitlab.com/pricing/), a [burndown chart](burndown_charts.md) is in the milestone view, showing the progress of completing a milestone.
For group milestones in [GitLab Starter](https://about.gitlab.com/pricing/), a [burndown chart](burndown_charts.md) is in the milestone view, showing the progress of completing a milestone.
### Milestone sidebar
......
......@@ -40,7 +40,7 @@ module Gitlab
Result.new(
jobs: dry_run_convert_to_jobs(pipeline.stages),
errors: pipeline.error_messages.map(&:content),
warnings: pipeline.warning_messages.map(&:content)
warnings: pipeline.warning_messages(limit: ::Gitlab::Ci::Warnings::MAX_LIMIT).map(&:content)
)
end
......@@ -55,7 +55,7 @@ module Gitlab
Result.new(
jobs: static_validation_convert_to_jobs(result),
errors: result.errors,
warnings: result.warnings
warnings: result.warnings.take(::Gitlab::Ci::Warnings::MAX_LIMIT) # rubocop: disable CodeReuse/ActiveRecord
)
end
......
# frozen_string_literal: true
module Gitlab::Ci::Warnings
MAX_LIMIT = 25
end
......@@ -545,6 +545,9 @@ msgstr ""
msgid "%{mergeLength}/%{usersLength} can merge"
msgstr ""
msgid "%{message} showing first %{warnings_displayed}"
msgstr ""
msgid "%{milestone_name} (Past due)"
msgstr ""
......@@ -788,6 +791,9 @@ msgstr ""
msgid "%{totalWeight} total weight"
msgstr ""
msgid "%{total_warnings} warning(s) found:"
msgstr ""
msgid "%{total} open issue weight"
msgstr ""
......@@ -16164,6 +16170,9 @@ msgstr ""
msgid "NetworkPolicies|%{ifLabelStart}if%{ifLabelEnd} %{ruleType} %{isLabelStart}is%{isLabelEnd} %{ruleDirection} %{ruleSelector} %{directionLabelStart}and is outbound to a%{directionLabelEnd} %{rule} %{portsLabelStart}on%{portsLabelEnd} %{ports}"
msgstr ""
msgid "NetworkPolicies|%{labelStart}Then%{labelEnd} %{action} %{spanStart}the network traffic.%{spanEnd}"
msgstr ""
msgid "NetworkPolicies|%{number} selected"
msgstr ""
......@@ -16185,6 +16194,9 @@ msgstr ""
msgid "NetworkPolicies|All selected"
msgstr ""
msgid "NetworkPolicies|Allow"
msgstr ""
msgid "NetworkPolicies|Allow all inbound traffic to %{selector} from %{ruleSelector} on %{ports}"
msgstr ""
......@@ -16293,6 +16305,9 @@ msgstr ""
msgid "NetworkPolicies|Status"
msgstr ""
msgid "NetworkPolicies|Traffic that does not match any rule will be blocked."
msgstr ""
msgid "NetworkPolicies|YAML editor"
msgstr ""
......
......@@ -422,10 +422,6 @@ RSpec.describe GroupsController do
end
context 'searching' do
before do
stub_feature_flags(attempt_group_search_optimizations: true)
end
it 'works with popularity sort' do
get :issues, params: { id: group.to_param, search: 'foo', sort: 'popularity' }
......
......@@ -135,10 +135,6 @@ RSpec.describe Projects::MilestonesController do
end
describe "#destroy" do
before do
stub_feature_flags(track_resource_milestone_change_events: false)
end
it "removes milestone" do
expect(issue.milestone_id).to eq(milestone.id)
......@@ -153,10 +149,6 @@ RSpec.describe Projects::MilestonesController do
merge_request.reload
expect(merge_request.milestone_id).to eq(nil)
# Check system note left for milestone removal
last_note = project.issues.find(issue.id).notes[-1].note
expect(last_note).to eq('removed milestone')
end
end
......
......@@ -949,10 +949,6 @@ RSpec.describe IssuesFinder do
describe '#use_cte_for_search?' do
let(:finder) { described_class.new(nil, params) }
before do
stub_feature_flags(attempt_group_search_optimizations: true)
end
context 'when there is no search param' do
let(:params) { { attempt_group_search_optimizations: true } }
......@@ -969,18 +965,6 @@ RSpec.describe IssuesFinder do
end
end
context 'when the attempt_group_search_optimizations flag is disabled' do
let(:params) { { search: 'foo', attempt_group_search_optimizations: true } }
before do
stub_feature_flags(attempt_group_search_optimizations: false)
end
it 'returns false' do
expect(finder.use_cte_for_search?).to be_falsey
end
end
context 'when attempt_group_search_optimizations is unset and attempt_project_search_optimizations is set' do
let(:params) { { search: 'foo', attempt_project_search_optimizations: true } }
......
......@@ -22,8 +22,8 @@ RSpec.describe Ci::PipelinesHelper do
let(:warning_messages) { [double(content: 'Warning 1'), double(content: 'Warning 2')] }
it 'returns a warning callout box' do
expect(subject).to have_css 'div.alert-warning'
expect(subject).to include 'Warning:'
expect(subject).to have_css 'div.bs-callout-warning'
expect(subject).to include '2 warning(s) found:'
end
it 'lists the the warnings' do
......@@ -32,4 +32,24 @@ RSpec.describe Ci::PipelinesHelper do
end
end
end
describe 'warning_header' do
subject { helper.warning_header(count) }
context 'when warnings are more than max cap' do
let(:count) { 30 }
it 'returns 30 warning(s) found: showing first 25' do
expect(subject).to eq('30 warning(s) found: showing first 25')
end
end
context 'when warnings are less than max cap' do
let(:count) { 15 }
it 'returns 15 warning(s) found' do
expect(subject).to eq('15 warning(s) found:')
end
end
end
end
......@@ -92,6 +92,31 @@ RSpec.describe Gitlab::Ci::Lint do
end
end
context 'when content has more warnings than max limit' do
# content will result in 2 warnings
let(:content) do
<<~YAML
rspec:
script: rspec
rules:
- when: always
rspec2:
script: rspec
rules:
- when: always
YAML
end
before do
stub_const('Gitlab::Ci::Warnings::MAX_LIMIT', 1)
end
it 'returns a result with warnings' do
expect(subject).to be_valid
expect(subject.warnings.size).to eq(1)
end
end
context 'when content has errors and warnings' do
let(:content) do
<<~YAML
......
......@@ -32,17 +32,6 @@ RSpec.describe Issuable::CommonSystemNotesService do
end
end
context 'when new milestone is assigned' do
before do
milestone = create(:milestone, project: project)
issuable.milestone_id = milestone.id
stub_feature_flags(track_resource_milestone_change_events: false)
end
it_behaves_like 'system note creation', {}, 'changed milestone'
end
context 'with merge requests Draft note' do
context 'adding Draft note' do
let(:issuable) { create(:merge_request, title: "merge request") }
......@@ -100,32 +89,10 @@ RSpec.describe Issuable::CommonSystemNotesService do
expect(event.user_id).to eq user.id
end
context 'when milestone change event tracking is disabled' do
before do
stub_feature_flags(track_resource_milestone_change_events: false)
issuable.milestone = create(:milestone, project: project)
issuable.save
end
it 'creates a system note for milestone set' do
expect { subject }.to change { issuable.notes.count }.from(0).to(1)
expect(issuable.notes.last.note).to match('changed milestone')
end
it 'does not create a milestone change event' do
expect { subject }.not_to change { ResourceMilestoneEvent.count }
end
end
context 'when milestone change event tracking is enabled' do
context 'when changing milestones' do
let_it_be(:milestone) { create(:milestone, project: project) }
let_it_be(:issuable) { create(:issue, project: project, milestone: milestone) }
before do
stub_feature_flags(track_resource_milestone_change_events: true)
end
it 'does not create a system note for milestone set' do
expect { subject }.not_to change { issuable.notes.count }
end
......
......@@ -445,10 +445,6 @@ RSpec.describe Issues::UpdateService, :mailer do
end
context 'when the milestone is removed' do
before do
stub_feature_flags(track_resource_milestone_change_events: false)
end
let!(:non_subscriber) { create(:user) }
let!(:subscriber) do
......@@ -458,8 +454,6 @@ RSpec.describe Issues::UpdateService, :mailer do
end
end
it_behaves_like 'system notes for milestones'
it 'sends notifications for subscribers of changed milestone', :sidekiq_might_not_need_inline do
issue.milestone = create(:milestone, project: project)
......@@ -490,10 +484,6 @@ RSpec.describe Issues::UpdateService, :mailer do
end
context 'when the milestone is assigned' do
before do
stub_feature_flags(track_resource_milestone_change_events: false)
end
let!(:non_subscriber) { create(:user) }
let!(:subscriber) do
......@@ -509,8 +499,6 @@ RSpec.describe Issues::UpdateService, :mailer do
expect(todo.reload.done?).to eq true
end
it_behaves_like 'system notes for milestones'
it 'sends notifications for subscribers of changed milestone', :sidekiq_might_not_need_inline do
perform_enqueued_jobs do
update_issue(milestone: create(:milestone, project: project))
......
......@@ -380,10 +380,6 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
end
context 'when the milestone is removed' do
before do
stub_feature_flags(track_resource_milestone_change_events: false)
end
let!(:non_subscriber) { create(:user) }
let!(:subscriber) do
......@@ -393,8 +389,6 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
end
end
it_behaves_like 'system notes for milestones'
it 'sends notifications for subscribers of changed milestone', :sidekiq_might_not_need_inline do
merge_request.milestone = create(:milestone, project: project)
......@@ -410,10 +404,6 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
end
context 'when the milestone is changed' do
before do
stub_feature_flags(track_resource_milestone_change_events: false)
end
let!(:non_subscriber) { create(:user) }
let!(:subscriber) do
......@@ -429,8 +419,6 @@ RSpec.describe MergeRequests::UpdateService, :mailer do
expect(pending_todo.reload).to be_done
end
it_behaves_like 'system notes for milestones'
it 'sends notifications for subscribers of changed milestone', :sidekiq_might_not_need_inline do
perform_enqueued_jobs do
update_merge_request(milestone: create(:milestone, project: project))
......
......@@ -6,20 +6,23 @@ RSpec.describe ResourceEvents::SyntheticMilestoneNotesBuilderService do
describe '#execute' do
let_it_be(:user) { create(:user) }
let_it_be(:issue) { create(:issue, author: user) }
let_it_be(:milestone) { create(:milestone, project: issue.project) }
before do
create_list(:resource_milestone_event, 3, issue: issue)
stub_feature_flags(track_resource_milestone_change_events: false)
let_it_be(:events) do
[
create(:resource_milestone_event, issue: issue, milestone: milestone, action: :add, created_at: '2020-01-01 04:00'),
create(:resource_milestone_event, issue: issue, milestone: milestone, action: :remove, created_at: '2020-01-02 08:00')
]
end
context 'when resource milestone events are disabled' do
# https://gitlab.com/gitlab-org/gitlab/-/issues/212985
it 'still builds notes for existing resource milestone events' do
notes = described_class.new(issue, user).execute
it 'builds milestone notes for resource milestone events' do
notes = described_class.new(issue, user).execute
expect(notes.size).to eq(3)
end
expect(notes.map(&:created_at)).to eq(events.map(&:created_at))
expect(notes.map(&:note)).to eq([
"changed milestone to %#{milestone.iid}",
'removed milestone'
])
end
end
end
......@@ -74,18 +74,6 @@ RSpec.describe SystemNoteService do
end
end
describe '.change_milestone' do
let(:milestone) { double }
it 'calls IssuableService' do
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
expect(service).to receive(:change_milestone).with(milestone)
end
described_class.change_milestone(noteable, project, author, milestone)
end
end
describe '.relate_issue' do
let(:noteable_ref) { double }
let(:noteable) { double }
......
......@@ -128,64 +128,6 @@ RSpec.describe ::SystemNotes::IssuablesService do
end
end
describe '#change_milestone' do
subject { service.change_milestone(milestone) }
context 'for a project milestone' do
let(:milestone) { create(:milestone, project: project) }
it_behaves_like 'a system note' do
let(:action) { 'milestone' }
end
context 'when milestone added' do
it 'sets the note text' do
reference = milestone.to_reference(format: :iid)
expect(subject.note).to eq "changed milestone to #{reference}"
end
it_behaves_like 'a note with overridable created_at'
end
context 'when milestone removed' do
let(:milestone) { nil }
it 'sets the note text' do
expect(subject.note).to eq 'removed milestone'
end
it_behaves_like 'a note with overridable created_at'
end
end
context 'for a group milestone' do
let(:milestone) { create(:milestone, group: group) }
it_behaves_like 'a system note' do
let(:action) { 'milestone' }
end
context 'when milestone added' do
it 'sets the note text to use the milestone name' do
expect(subject.note).to eq "changed milestone to #{milestone.to_reference(format: :name)}"
end
it_behaves_like 'a note with overridable created_at'
end
context 'when milestone removed' do
let(:milestone) { nil }
it 'sets the note text' do
expect(subject.note).to eq 'removed milestone'
end
it_behaves_like 'a note with overridable created_at'
end
end
end
describe '#change_status' do
subject { service.change_status(status, source) }
......
......@@ -8,37 +8,6 @@ RSpec.shared_examples 'cache counters invalidator' do
end
end
RSpec.shared_examples 'system notes for milestones' do
def update_issuable(opts)
issuable = try(:issue) || try(:merge_request)
described_class.new(project, user, opts).execute(issuable)
end
context 'group milestones' do
let(:group) { create(:group) }
let(:group_milestone) { create(:milestone, group: group) }
before do
project.update!(namespace: group)
create(:group_member, group: group, user: user)
end
it 'creates a system note' do
expect do
update_issuable(milestone: group_milestone)
end.to change { Note.system.count }.by(1)
end
end
context 'project milestones' do
it 'creates a system note' do
expect do
update_issuable(milestone: create(:milestone, project: project))
end.to change { Note.system.count }.by(1)
end
end
end
RSpec.shared_examples 'updating a single task' do
def update_issuable(opts)
issuable = try(:issue) || try(:merge_request)
......
......@@ -87,7 +87,7 @@ RSpec.describe 'projects/ci/lints/show' do
it 'shows warning messages' do
render
expect(rendered).to have_content('Warning:')
expect(rendered).to have_content('2 warning(s) found:')
expect(rendered).to have_content('Warning 1')
expect(rendered).to have_content('Warning 2')
end
......@@ -116,7 +116,7 @@ RSpec.describe 'projects/ci/lints/show' do
it 'shows warning messages' do
render
expect(rendered).to have_content('Warning:')
expect(rendered).to have_content('2 warning(s) found:')
expect(rendered).to have_content('Warning 1')
expect(rendered).to have_content('Warning 2')
end
......
......@@ -26,7 +26,7 @@ RSpec.describe 'projects/pipelines/new' do
it 'displays the warnings' do
render
expect(rendered).to have_css('div.alert-warning')
expect(rendered).to have_css('div.bs-callout-warning')
expect(rendered).to have_content('warning 1')
expect(rendered).to have_content('warning 2')
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册