diff options
22 files changed, 163 insertions, 37 deletions
diff --git a/app/assets/stylesheets/framework/files.scss b/app/assets/stylesheets/framework/files.scss index ab1fbf6d4ce..02df4905c39 100644 --- a/app/assets/stylesheets/framework/files.scss +++ b/app/assets/stylesheets/framework/files.scss @@ -136,6 +136,13 @@ * Blame file */ &.blame { + // + // IMPORTANT PERFORMANCE OPTIMIZATION + // + // When viewinng a blame with many commits a lot of content is rendered on the page. + // The line below ensures that we only render what is visible to the user, thus reducing TBT in the browser. + content-visibility: auto; + table { border: 0; margin: 0; @@ -150,6 +157,12 @@ } td { + // + // IMPORTANT PERFORMANCE OPTIMIZATION + // + // When viewinng a blame with many commits a lot of content is rendered on the page. + // The line below ensures that we only render what is visible to the user, thus reducing TBT in the browser. + content-visibility: auto; border-top: 0; border-bottom: 0; diff --git a/app/models/concerns/limitable.rb b/app/models/concerns/limitable.rb index 41efea65c5a..fab1aa21634 100644 --- a/app/models/concerns/limitable.rb +++ b/app/models/concerns/limitable.rb @@ -9,6 +9,7 @@ module Limitable class_attribute :limit_relation class_attribute :limit_name class_attribute :limit_feature_flag + class_attribute :limit_feature_flag_for_override # Allows selectively disabling by actor (as per https://docs.gitlab.com/ee/development/feature_flags/#selectively-disable-by-actor) self.limit_name = self.name.demodulize.tableize validate :validate_plan_limit_not_exceeded, on: :create @@ -28,6 +29,7 @@ module Limitable scope_relation = self.public_send(limit_scope) # rubocop:disable GitlabSecurity/PublicSend return unless scope_relation return if limit_feature_flag && ::Feature.disabled?(limit_feature_flag, scope_relation, default_enabled: :yaml) + return if limit_feature_flag_for_override && ::Feature.enabled?(limit_feature_flag_for_override, scope_relation, default_enabled: :yaml) relation = limit_relation ? self.public_send(limit_relation) : self.class.where(limit_scope => scope_relation) # rubocop:disable GitlabSecurity/PublicSend limits = scope_relation.actual_limits diff --git a/app/views/projects/blame/show.html.haml b/app/views/projects/blame/show.html.haml index 8fe9c9e5c52..30c052e054f 100644 --- a/app/views/projects/blame/show.html.haml +++ b/app/views/projects/blame/show.html.haml @@ -51,7 +51,7 @@ = i \ - %td.lines + %td.lines.gl-w-full %pre.code.highlight %code - blame_group[:lines].each do |line| diff --git a/config/metrics/counts_28d/20210216175113_merge_request_action_monthly.yml b/config/metrics/counts_28d/20210216175113_merge_request_action_monthly.yml index 197e7af6944..969b426dc4e 100644 --- a/config/metrics/counts_28d/20210216175113_merge_request_action_monthly.yml +++ b/config/metrics/counts_28d/20210216175113_merge_request_action_monthly.yml @@ -10,6 +10,10 @@ value_type: number status: data_available time_frame: 28d data_source: redis_hll +instrumentation_class: RedisHLLMetric +options: + events: + - merge_request_action distribution: - ce - ee diff --git a/config/metrics/counts_28d/20210216175117_i_source_code_code_intelligence_monthly.yml b/config/metrics/counts_28d/20210216175117_i_source_code_code_intelligence_monthly.yml index acd657dec0a..e8fa311ed23 100644 --- a/config/metrics/counts_28d/20210216175117_i_source_code_code_intelligence_monthly.yml +++ b/config/metrics/counts_28d/20210216175117_i_source_code_code_intelligence_monthly.yml @@ -10,6 +10,10 @@ value_type: number status: data_available time_frame: 28d data_source: redis_hll +instrumentation_class: RedisHLLMetric +options: + events: + - i_source_code_code_intelligence distribution: - ce - ee diff --git a/config/metrics/counts_28d/20210216182102_wiki_action_monthly.yml b/config/metrics/counts_28d/20210216182102_wiki_action_monthly.yml index 834bfca933b..118a33016a5 100644 --- a/config/metrics/counts_28d/20210216182102_wiki_action_monthly.yml +++ b/config/metrics/counts_28d/20210216182102_wiki_action_monthly.yml @@ -10,6 +10,10 @@ value_type: number status: data_available time_frame: 28d data_source: redis_hll +instrumentation_class: RedisHLLMetric +options: + events: + - wiki_action distribution: - ce - ee diff --git a/config/metrics/counts_28d/20210216182106_design_action_monthly.yml b/config/metrics/counts_28d/20210216182106_design_action_monthly.yml index b63c79fa9b5..b725b30a03f 100644 --- a/config/metrics/counts_28d/20210216182106_design_action_monthly.yml +++ b/config/metrics/counts_28d/20210216182106_design_action_monthly.yml @@ -10,6 +10,10 @@ value_type: number status: data_available time_frame: 28d data_source: redis_hll +instrumentation_class: RedisHLLMetric +options: + events: + - design_action distribution: - ce - ee diff --git a/config/metrics/counts_28d/20210216182109_project_action_monthly.yml b/config/metrics/counts_28d/20210216182109_project_action_monthly.yml index c5b38cf041e..fa8c04668b6 100644 --- a/config/metrics/counts_28d/20210216182109_project_action_monthly.yml +++ b/config/metrics/counts_28d/20210216182109_project_action_monthly.yml @@ -10,6 +10,10 @@ value_type: number status: data_available time_frame: 28d data_source: redis_hll +instrumentation_class: RedisHLLMetric +options: + events: + - project_action distribution: - ce - ee diff --git a/config/metrics/counts_28d/20210216184047_git_write_action_monthly.yml b/config/metrics/counts_28d/20210216184047_git_write_action_monthly.yml index 46bca52fe2b..cc722bd3da2 100644 --- a/config/metrics/counts_28d/20210216184047_git_write_action_monthly.yml +++ b/config/metrics/counts_28d/20210216184047_git_write_action_monthly.yml @@ -10,6 +10,10 @@ value_type: number status: data_available time_frame: 28d data_source: redis_hll +instrumentation_class: RedisHLLMetric +options: + events: + - git_write_action distribution: - ce - ee diff --git a/config/metrics/counts_7d/20210216175111_merge_request_action_weekly.yml b/config/metrics/counts_7d/20210216175111_merge_request_action_weekly.yml index 24ac0a96342..351b5772fda 100644 --- a/config/metrics/counts_7d/20210216175111_merge_request_action_weekly.yml +++ b/config/metrics/counts_7d/20210216175111_merge_request_action_weekly.yml @@ -10,6 +10,10 @@ value_type: number status: data_available time_frame: 7d data_source: redis_hll +instrumentation_class: RedisHLLMetric +options: + events: + - merge_request_action distribution: - ce - ee diff --git a/config/metrics/counts_7d/20210216175114_i_source_code_code_intelligence_weekly.yml b/config/metrics/counts_7d/20210216175114_i_source_code_code_intelligence_weekly.yml index e5e1b1f7ed3..2259495aa6e 100644 --- a/config/metrics/counts_7d/20210216175114_i_source_code_code_intelligence_weekly.yml +++ b/config/metrics/counts_7d/20210216175114_i_source_code_code_intelligence_weekly.yml @@ -10,6 +10,10 @@ value_type: number status: data_available time_frame: 7d data_source: redis_hll +instrumentation_class: RedisHLLMetric +options: + events: + - i_source_code_code_intelligence distribution: - ce - ee diff --git a/config/metrics/counts_7d/20210216182100_wiki_action_weekly.yml b/config/metrics/counts_7d/20210216182100_wiki_action_weekly.yml index ea8ebc2b18f..1e11f69d057 100644 --- a/config/metrics/counts_7d/20210216182100_wiki_action_weekly.yml +++ b/config/metrics/counts_7d/20210216182100_wiki_action_weekly.yml @@ -10,8 +10,12 @@ value_type: number status: data_available time_frame: 7d data_source: redis_hll +instrumentation_class: RedisHLLMetric +options: + events: + - wiki_action distribution: -- ee +- ce - ee tier: - free diff --git a/config/metrics/counts_7d/20210216182104_design_action_weekly.yml b/config/metrics/counts_7d/20210216182104_design_action_weekly.yml index 34cd3645bfe..5598225e534 100644 --- a/config/metrics/counts_7d/20210216182104_design_action_weekly.yml +++ b/config/metrics/counts_7d/20210216182104_design_action_weekly.yml @@ -10,8 +10,12 @@ value_type: number status: data_available time_frame: 7d data_source: redis_hll +instrumentation_class: RedisHLLMetric +options: + events: + - design_action distribution: -- ee +- ce - ee tier: - free diff --git a/config/metrics/counts_7d/20210216182107_project_action_weekly.yml b/config/metrics/counts_7d/20210216182107_project_action_weekly.yml index 95919f7919c..be0e472797a 100644 --- a/config/metrics/counts_7d/20210216182107_project_action_weekly.yml +++ b/config/metrics/counts_7d/20210216182107_project_action_weekly.yml @@ -10,6 +10,10 @@ value_type: number status: data_available time_frame: 7d data_source: redis_hll +instrumentation_class: RedisHLLMetric +options: + events: + - project_action distribution: - ce - ee diff --git a/config/metrics/counts_7d/20210216184045_git_write_action_weekly.yml b/config/metrics/counts_7d/20210216184045_git_write_action_weekly.yml index baf098dd19b..ec5e1984451 100644 --- a/config/metrics/counts_7d/20210216184045_git_write_action_weekly.yml +++ b/config/metrics/counts_7d/20210216184045_git_write_action_weekly.yml @@ -10,6 +10,10 @@ value_type: number status: data_available time_frame: 7d data_source: redis_hll +instrumentation_class: RedisHLLMetric +options: + events: + - git_write_action distribution: - ce - ee diff --git a/locale/gitlab.pot b/locale/gitlab.pot index d59bc11fc65..b84c33a8fec 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -17163,7 +17163,7 @@ msgstr "" msgid "InProductMarketing|Use GitLab CI/CD" msgstr "" -msgid "InProductMarketing|Used by more than 100,000 organizations from around the globe:" +msgid "InProductMarketing|Used by more than 100,000 organizations from around the globe." msgstr "" msgid "InProductMarketing|Very difficult" diff --git a/qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb index 6c2ff005f49..4fee7e6d07f 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/group/bulk_import_group_spec.rb @@ -92,7 +92,7 @@ module QA Page::Group::BulkImport.perform do |import_page| import_page.import_group(source_group.path, sandbox.path) - expect(import_page).to have_imported_group(source_group.path, wait: 180) + expect(import_page).to have_imported_group(source_group.path, wait: 300) aggregate_failures do expect { imported_group.reload! }.to eventually_eq(source_group).within(duration: 10) diff --git a/qa/qa/specs/features/browser_ui/5_package/pypi_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/pypi_repository_spec.rb index a9034174cab..f0f0ab0fddf 100644 --- a/qa/qa/specs/features/browser_ui/5_package/pypi_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/pypi_repository_spec.rb @@ -26,10 +26,10 @@ module QA end end - let(:gitlab_address_with_port) do - uri = URI.parse(Runtime::Scenario.gitlab_address) - "#{uri.scheme}://#{uri.host}:#{uri.port}" - end + let(:uri) { URI.parse(Runtime::Scenario.gitlab_address) } + let(:gitlab_address_with_port) { "#{uri.scheme}://#{uri.host}:#{uri.port}" } + let(:gitlab_host_with_port) { "#{uri.host}:#{uri.port}" } + let(:personal_access_token) { Runtime::Env.personal_access_token } before do Flow::Login.sign_in @@ -42,14 +42,25 @@ module QA content: <<~YAML image: python:latest + stages: + - run + - install run: + stage: run script: - pip install twine - python setup.py sdist bdist_wheel - "TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url #{gitlab_address_with_port}/api/v4/projects/${CI_PROJECT_ID}/packages/pypi dist/*" tags: - "runner-for-#{project.name}" + install: + stage: install + script: + - "pip install mypypipackage --no-deps --index-url http://#{personal_access_token}:#{personal_access_token}@#{gitlab_host_with_port}/api/v4/projects/${CI_PROJECT_ID}/packages/pypi/simple --trusted-host #{gitlab_host_with_port}" + tags: + - "runner-for-#{project.name}" + YAML }, { @@ -87,6 +98,16 @@ module QA Page::Project::Job::Show.perform do |job| expect(job).to be_successful(timeout: 800) end + + Flow::Pipeline.visit_latest_pipeline + + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.click_job('install') + end + + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 800) + end end after do @@ -95,20 +116,22 @@ module QA project&.remove_via_api! end - it 'publishes a pypi package and deletes it', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1087' do - Page::Project::Menu.perform(&:click_packages_link) + context 'when at the project level' do + it 'publishes and installs a pypi package and deletes it', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1087' do + Page::Project::Menu.perform(&:click_packages_link) - Page::Project::Packages::Index.perform do |index| - expect(index).to have_package(package.name) - index.click_package(package.name) - end + Page::Project::Packages::Index.perform do |index| + expect(index).to have_package(package.name) + index.click_package(package.name) + end - Page::Project::Packages::Show.perform(&:click_delete) + Page::Project::Packages::Show.perform(&:click_delete) - Page::Project::Packages::Index.perform do |index| - aggregate_failures do - expect(index).to have_content("Package deleted successfully") - expect(index).not_to have_package(package.name) + Page::Project::Packages::Index.perform do |index| + aggregate_failures do + expect(index).to have_content("Package deleted successfully") + expect(index).not_to have_package(package.name) + end end end end diff --git a/rubocop/cop/gitlab/mark_used_feature_flags.rb b/rubocop/cop/gitlab/mark_used_feature_flags.rb index 2a020d6efb2..a0de43abe85 100644 --- a/rubocop/cop/gitlab/mark_used_feature_flags.rb +++ b/rubocop/cop/gitlab/mark_used_feature_flags.rb @@ -32,6 +32,7 @@ module RuboCop SELF_METHODS = %i[ push_frontend_feature_flag limit_feature_flag= + limit_feature_flag_for_override= ].freeze + EXPERIMENT_METHODS + RUGGED_METHODS + WORKER_METHODS RESTRICT_ON_SEND = FEATURE_METHODS + EXPERIMENTATION_METHODS + GRAPHQL_METHODS + SELF_METHODS diff --git a/spec/lib/gitlab/usage_data_metrics_spec.rb b/spec/lib/gitlab/usage_data_metrics_spec.rb index 2851c5efba4..bcf14d8ea4d 100644 --- a/spec/lib/gitlab/usage_data_metrics_spec.rb +++ b/spec/lib/gitlab/usage_data_metrics_spec.rb @@ -41,6 +41,17 @@ RSpec.describe Gitlab::UsageDataMetrics do ]) end + it 'includes source_code monthly and weekly keys' do + expect(subject[:redis_hll_counters][:source_code].keys).to contain_exactly(*[ + :wiki_action_monthly, :wiki_action_weekly, + :design_action_monthly, :design_action_weekly, + :project_action_monthly, :project_action_weekly, + :git_write_action_monthly, :git_write_action_weekly, + :merge_request_action_monthly, :merge_request_action_weekly, + :i_source_code_code_intelligence_monthly, :i_source_code_code_intelligence_weekly + ]) + end + it 'includes counts keys' do expect(subject[:counts]).to include(:issues) end diff --git a/spec/models/concerns/limitable_spec.rb b/spec/models/concerns/limitable_spec.rb index 6b25ed39efb..850282d54c7 100644 --- a/spec/models/concerns/limitable_spec.rb +++ b/spec/models/concerns/limitable_spec.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true -require 'fast_spec_helper' -require 'active_model' +require 'spec_helper' RSpec.describe Limitable do let(:minimal_test_class) do @@ -17,7 +16,7 @@ RSpec.describe Limitable do end before do - stub_const("MinimalTestClass", minimal_test_class) + stub_const('MinimalTestClass', minimal_test_class) end it { expect(MinimalTestClass.limit_name).to eq('test_classes') } @@ -37,25 +36,50 @@ RSpec.describe Limitable do instance.valid?(:create) end - context 'with custom relation' do - before do - MinimalTestClass.limit_relation = :custom_relation + context 'with custom relation and feature flags' do + using RSpec::Parameterized::TableSyntax + + where(:limit_feature_flag, :limit_feature_flag_value, :limit_feature_flag_for_override, :limit_feature_flag_override_value, :expect_limit_applied?) do + nil | nil | nil | nil | true + :some_feature_flag | false | nil | nil | false + :some_feature_flag | true | nil | nil | true + :some_feature_flag | true | :some_feature_flag_disable | false | true + :some_feature_flag | false | :some_feature_flag_disable | false | false + :some_feature_flag | false | :some_feature_flag_disable | true | false + :some_feature_flag | true | :some_feature_flag_disable | true | false end - it 'triggers custom limit_relation' do - instance = MinimalTestClass.new + with_them do + let(:instance) { MinimalTestClass.new } - def instance.project - @project ||= Object.new - end + before do + def instance.project + @project ||= stub_feature_flag_gate('CustomActor') + end + + stub_feature_flags("#{limit_feature_flag}": limit_feature_flag_value ? [instance.project] : false) if limit_feature_flag + stub_feature_flags("#{limit_feature_flag_for_override}": limit_feature_flag_override_value ? [instance.project] : false) if limit_feature_flag_for_override + skip_feature_flags_yaml_validation + skip_default_enabled_yaml_check - limits = Object.new - custom_relation = Object.new - expect(instance).to receive(:custom_relation).and_return(custom_relation) - expect(instance.project).to receive(:actual_limits).and_return(limits) - expect(limits).to receive(:exceeded?).with(instance.class.name.demodulize.tableize, custom_relation).and_return(false) + MinimalTestClass.limit_relation = :custom_relation + MinimalTestClass.limit_feature_flag = limit_feature_flag + MinimalTestClass.limit_feature_flag_for_override = limit_feature_flag_for_override + end - instance.valid?(:create) + it 'acts according to the feature flag settings' do + limits = Object.new + custom_relation = Object.new + if expect_limit_applied? + expect(instance).to receive(:custom_relation).and_return(custom_relation) + expect(instance.project).to receive(:actual_limits).and_return(limits) + expect(limits).to receive(:exceeded?).with(instance.class.name.demodulize.tableize, custom_relation).and_return(false) + else + expect(instance).not_to receive(:custom_relation) + end + + instance.valid?(:create) + end end end end diff --git a/spec/rubocop/cop/gitlab/mark_used_feature_flags_spec.rb b/spec/rubocop/cop/gitlab/mark_used_feature_flags_spec.rb index 968cafc57d4..30028a1f1aa 100644 --- a/spec/rubocop/cop/gitlab/mark_used_feature_flags_spec.rb +++ b/spec/rubocop/cop/gitlab/mark_used_feature_flags_spec.rb @@ -194,6 +194,10 @@ RSpec.describe RuboCop::Cop::Gitlab::MarkUsedFeatureFlags do include_examples 'sets flag as used', 'self.limit_feature_flag = :foo', 'foo' end + describe 'self.limit_feature_flag_for_override = :foo' do + include_examples 'sets flag as used', 'self.limit_feature_flag_for_override = :foo', 'foo' + end + describe 'FEATURE_FLAG = :foo' do include_examples 'sets flag as used', 'FEATURE_FLAG = :foo', 'foo' end |