diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 19:05:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 19:05:49 +0300 |
commit | 43a25d93ebdabea52f99b05e15b06250cd8f07d7 (patch) | |
tree | dceebdc68925362117480a5d672bcff122fb625b /danger | |
parent | 20c84b99005abd1c82101dfeff264ac50d2df211 (diff) |
Add latest changes from gitlab-org/gitlab@16-0-stable-eev16.0.0-rc42
Diffstat (limited to 'danger')
-rw-r--r-- | danger/analytics_instrumentation/Dangerfile | 9 | ||||
-rw-r--r-- | danger/ci_tables/Dangerfile | 32 | ||||
-rw-r--r-- | danger/database/Dangerfile | 2 | ||||
-rw-r--r-- | danger/datateam/Dangerfile | 2 | ||||
-rw-r--r-- | danger/feature_flag/Dangerfile | 58 | ||||
-rw-r--r-- | danger/multiversion/Dangerfile | 3 | ||||
-rw-r--r-- | danger/plugins/analytics_instrumentation.rb | 10 | ||||
-rw-r--r-- | danger/plugins/database_dictionary.rb | 10 | ||||
-rw-r--r-- | danger/plugins/multiversion.rb | 9 | ||||
-rw-r--r-- | danger/plugins/product_intelligence.rb | 10 | ||||
-rw-r--r-- | danger/plugins/sidekiq_args.rb | 10 | ||||
-rw-r--r-- | danger/product_intelligence/Dangerfile | 7 | ||||
-rw-r--r-- | danger/roulette/Dangerfile | 19 | ||||
-rw-r--r-- | danger/sidekiq_args/Dangerfile | 5 | ||||
-rw-r--r-- | danger/specs/Dangerfile | 8 | ||||
-rw-r--r-- | danger/stable_branch_patch/Dangerfile | 2 |
16 files changed, 159 insertions, 37 deletions
diff --git a/danger/analytics_instrumentation/Dangerfile b/danger/analytics_instrumentation/Dangerfile new file mode 100644 index 00000000000..bbb984939dc --- /dev/null +++ b/danger/analytics_instrumentation/Dangerfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +return if stable_branch.valid_stable_branch? + +analytics_instrumentation.check! + +analytics_instrumentation.check_affected_scopes! + +analytics_instrumentation.check_usage_data_insertions! diff --git a/danger/ci_tables/Dangerfile b/danger/ci_tables/Dangerfile new file mode 100644 index 00000000000..1d4601d33b2 --- /dev/null +++ b/danger/ci_tables/Dangerfile @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +SEE_DB_DOC = "See the [database dictionary documentation](https://docs.gitlab.com/ee/development/database/database_dictionary.html)." + +PARTITIONING_COMMENT = <<~SUGGEST_COMMENT +When adding new CI tables, consider [partitioning](https://docs.gitlab.com/ee/development/cicd/cicd_tables.html) the table +from the start if it references any of the larger CI tables: `ci_pipelines`, `ci_stages`, `ci_builds`, `p_ci_builds_metadata`, `ci_job_artifacts`, `ci_pipeline_variables`. +SUGGEST_COMMENT + +def check_database_dictionary_yaml(database_dictionary) + return unless database_dictionary.ci_schema? + # `p_` prefix is used by the partitioned tables, so we can assume that the table is already partitioned + return if database_dictionary.table_name.to_s.start_with?('p_') + + mr_line = database_dictionary.raw.lines.find_index { |line| line.start_with?('table_name:') } + return unless mr_line + + markdown(PARTITIONING_COMMENT, file: database_dictionary.path, line: mr_line.succ) +rescue Psych::Exception + # YAML could not be parsed, fail the build. + fail "#{helper.html_link(database_ditionary.path)} isn't valid YAML! #{SEE_DB_DOC}" # rubocop:disable Style/SignalException +rescue StandardError => e + warn "There was a problem trying to check the database dictionary file. Exception: #{e.class.name} - #{e.message}" +end + +def added_database_dictionary_files + database_dictionary.database_dictionary_files(change_type: :added) +end + +added_database_dictionary_files.each do |database_dictionary| + check_database_dictionary_yaml(database_dictionary) +end diff --git a/danger/database/Dangerfile b/danger/database/Dangerfile index df6ffab7c94..96134ea66a6 100644 --- a/danger/database/Dangerfile +++ b/danger/database/Dangerfile @@ -45,6 +45,8 @@ geo_migration_created = !git.added_files.grep(%r{\Aee/db/geo/(post_)?migrate/}). format_str = helper.ci? ? SCHEMA_NOT_UPDATED_MESSAGE_FULL : SCHEMA_NOT_UPDATED_MESSAGE_SHORT +return if stable_branch.valid_stable_branch? + if non_geo_migration_created && !non_geo_db_schema_updated warn format(format_str, migrations: 'migrations', schema: helper.html_link("db/structure.sql")) end diff --git a/danger/datateam/Dangerfile b/danger/datateam/Dangerfile index ed2703f31e6..3cd0578a068 100644 --- a/danger/datateam/Dangerfile +++ b/danger/datateam/Dangerfile @@ -1,3 +1,5 @@ # frozen_string_literal: true +return if stable_branch.valid_stable_branch? + markdown(datateam.build_message) if datateam.impacted? diff --git a/danger/feature_flag/Dangerfile b/danger/feature_flag/Dangerfile index d5b907377aa..602ff1128f2 100644 --- a/danger/feature_flag/Dangerfile +++ b/danger/feature_flag/Dangerfile @@ -3,6 +3,9 @@ SEE_DOC = "See the [feature flag documentation](https://docs.gitlab.com/ee/development/feature_flags#feature-flag-definition-and-validation)." FEATURE_FLAG_LABEL = "feature flag" +FEATURE_FLAG_EXISTS_LABEL = "#{FEATURE_FLAG_LABEL}::exists" +FEATURE_FLAG_SKIPPED_LABEL = "#{FEATURE_FLAG_LABEL}::skipped" +DEVOPS_LABELS_REQUIRING_FEATURE_FLAG_REVIEW = ["devops::verify"] SUGGEST_MR_COMMENT = <<~SUGGEST_COMMENT ```suggestion @@ -12,6 +15,17 @@ group: "%<group>s" #{SEE_DOC} SUGGEST_COMMENT +FEATURE_FLAG_ENFORCEMENT_WARNING = <<~WARNING_MESSAGE +There were no new or modified feature flag YAML files detected in this MR. + +If the changes here are already controlled under an existing feature flag, please add +the ~"#{FEATURE_FLAG_EXISTS_LABEL}". Otherwise, if you think the changes here don't need +to be under a feature flag, please add the label ~"#{FEATURE_FLAG_SKIPPED_LABEL}", and +add a short comment about why we skipped the feature flag. + +For guidance on when to use a feature flag, please see the [documentation](https://about.gitlab.com/handbook/product-development-flow/feature-flag-lifecycle/#when-to-use-feature-flags). +WARNING_MESSAGE + def check_feature_flag_yaml(feature_flag) mr_group_label = helper.group_label @@ -64,22 +78,56 @@ def message_for_feature_flag_with_group!(feature_flag:, mr_group_label:) end end +def added_feature_flag_files + feature_flag.feature_flag_files(change_type: :added) +end + +def modified_feature_flag_files + feature_flag.feature_flag_files(change_type: :modified) +end + def feature_flag_file_added? - feature_flag.feature_flag_files(change_type: :added).any? + added_feature_flag_files.any? end -def feature_flag_file_added_or_removed? - feature_flag_file_added? || feature_flag.feature_flag_files(change_type: :deleted).any? +def feature_flag_file_modified? + modified_feature_flag_files.any? end -feature_flag.feature_flag_files(change_type: :added).each do |feature_flag| +def feature_flag_file_added_or_modified? + feature_flag_file_added? || feature_flag_file_modified? +end + +def mr_has_backend_or_frontend_changes? + changes = helper.changes_by_category + changes.has_key?(:backend) || changes.has_key?(:frontend) +end + +def mr_missing_feature_flag_status_label? + ([FEATURE_FLAG_EXISTS_LABEL, FEATURE_FLAG_SKIPPED_LABEL] & helper.mr_labels).none? +end + +def stage_requires_feature_flag_review? + DEVOPS_LABELS_REQUIRING_FEATURE_FLAG_REVIEW.include?(feature_flag.stage_label) +end + +added_feature_flag_files.each do |feature_flag| check_feature_flag_yaml(feature_flag) end -feature_flag.feature_flag_files(change_type: :modified).each do |feature_flag| +modified_feature_flag_files.each do |feature_flag| message_for_global_rollout(feature_flag) end if helper.security_mr? && feature_flag_file_added? fail "Feature flags are discouraged from security merge requests. Read the [security documentation](https://gitlab.com/gitlab-org/release/docs/-/blob/master/general/security/utilities/feature_flags.md) for details." end + +if !helper.security_mr? && mr_has_backend_or_frontend_changes? && stage_requires_feature_flag_review? + if feature_flag_file_added_or_modified? && !helper.mr_has_labels?(FEATURE_FLAG_EXISTS_LABEL) + # Feature flag config file touched in this MR, so let's add the label to avoid the warning. + helper.labels_to_add << FEATURE_FLAG_EXISTS_LABEL + end + + warn FEATURE_FLAG_ENFORCEMENT_WARNING if mr_missing_feature_flag_status_label? +end diff --git a/danger/multiversion/Dangerfile b/danger/multiversion/Dangerfile new file mode 100644 index 00000000000..9a53592abdb --- /dev/null +++ b/danger/multiversion/Dangerfile @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +multiversion.check! diff --git a/danger/plugins/analytics_instrumentation.rb b/danger/plugins/analytics_instrumentation.rb new file mode 100644 index 00000000000..2343a56f09d --- /dev/null +++ b/danger/plugins/analytics_instrumentation.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require_relative '../../tooling/danger/analytics_instrumentation' + +module Danger + class AnalyticsInstrumentation < ::Danger::Plugin + # Put the helper code somewhere it can be tested + include Tooling::Danger::AnalyticsInstrumentation + end +end diff --git a/danger/plugins/database_dictionary.rb b/danger/plugins/database_dictionary.rb new file mode 100644 index 00000000000..b6a3c320891 --- /dev/null +++ b/danger/plugins/database_dictionary.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require_relative '../../tooling/danger/database_dictionary' + +module Danger + class DatabaseDictionary < Plugin + # Put the helper code somewhere it can be tested + include Tooling::Danger::DatabaseDictionary + end +end diff --git a/danger/plugins/multiversion.rb b/danger/plugins/multiversion.rb new file mode 100644 index 00000000000..b180580cf70 --- /dev/null +++ b/danger/plugins/multiversion.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require_relative '../../tooling/danger/multiversion' + +module Danger + class Multiversion < ::Danger::Plugin + include Tooling::Danger::Multiversion + end +end diff --git a/danger/plugins/product_intelligence.rb b/danger/plugins/product_intelligence.rb deleted file mode 100644 index 91551a8312f..00000000000 --- a/danger/plugins/product_intelligence.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -require_relative '../../tooling/danger/product_intelligence' - -module Danger - class ProductIntelligence < ::Danger::Plugin - # Put the helper code somewhere it can be tested - include Tooling::Danger::ProductIntelligence - end -end diff --git a/danger/plugins/sidekiq_args.rb b/danger/plugins/sidekiq_args.rb new file mode 100644 index 00000000000..2210aa66b07 --- /dev/null +++ b/danger/plugins/sidekiq_args.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require_relative '../../tooling/danger/sidekiq_args' + +module Danger + class SidekiqArgs < ::Danger::Plugin + # Put the helper code somewhere it can be tested + include Tooling::Danger::SidekiqArgs + end +end diff --git a/danger/product_intelligence/Dangerfile b/danger/product_intelligence/Dangerfile deleted file mode 100644 index 86888fe542e..00000000000 --- a/danger/product_intelligence/Dangerfile +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -product_intelligence.check! - -product_intelligence.check_affected_scopes! - -product_intelligence.check_usage_data_insertions! diff --git a/danger/roulette/Dangerfile b/danger/roulette/Dangerfile index ca5a671ef29..5b865498651 100644 --- a/danger/roulette/Dangerfile +++ b/danger/roulette/Dangerfile @@ -55,9 +55,9 @@ end OPTIONAL_REVIEW_TEMPLATE = '%{role} review is optional for %{category}' NOT_AVAILABLE_TEMPLATES = { default: 'No %{role} available', - product_intelligence: group_not_available_template('#g_product_intelligence', '@gitlab-org/analytics-section/product-intelligence/engineers'), - integrations_be: group_not_available_template('#g_manage_integrations', '@gitlab-org/manage/integrations'), - integrations_fe: group_not_available_template('#g_manage_integrations', '@gitlab-org/manage/integrations') + product_intelligence: group_not_available_template('#g_analyze_analytics_instrumentation', '@gitlab-org/analytics-section/product-intelligence/engineers'), + import_integrate_be: group_not_available_template('#g_manage_import_and_integrate', '@gitlab-org/manage/import-and-integrate'), + import_integrate_fe: group_not_available_template('#g_manage_import_and_integrate', '@gitlab-org/manage/import-and-integrate') }.freeze def note_for_spin_role(spin, role, category) @@ -96,13 +96,16 @@ categories = Set.new(changes.keys - [:unknown]) categories << :database if helper.mr_labels.include?('database') # Ensure to spin for UX reviewer when ~UX is applied (e.g. to review changes to the UI) except when it's from wider community contribution where we want to assign from the corresponding group -categories << :ux if helper.mr_labels.include?('UX') && !helper.mr_labels.include?('Community contribution') +categories << :ux if helper.mr_labels.include?('UX') && !helper.mr_labels.include?('Community contribution') # rubocop:disable Rails/NegateInclude -# Ensure to spin for Product Intelligence reviewer when ~"product intelligence::review pending" is applied -categories << :product_intelligence if helper.mr_labels.include?("product intelligence::review pending") +# Ensure to spin for Analytics Instrumentation reviewer when ~"analytics instrumentation::review pending" is applied +categories << :analytics_instrumentation if helper.mr_labels.include?("analytics instrumentation::review pending") -# Skip Product intelligence reviews for growth experiment MRs -categories.delete(:product_intelligence) if helper.mr_labels.include?("growth experiment") +# Skip Analytics Instrumentation reviews for growth experiment MRs +categories.delete(:analytics_instrumentation) if helper.mr_labels.include?("growth experiment") + +# Skip specialty reviews for stable branch MRs since they have already been merged to the default branch +categories.subtract([:database, :ux, :analytics_instrumentation]) if stable_branch.valid_stable_branch? if changes.any? random_roulette_spins = roulette.spin(nil, categories, timezone_experiment: false) diff --git a/danger/sidekiq_args/Dangerfile b/danger/sidekiq_args/Dangerfile new file mode 100644 index 00000000000..fdd582889f3 --- /dev/null +++ b/danger/sidekiq_args/Dangerfile @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +sidekiq_args.changed_worker_files.each do |filename| + sidekiq_args.add_comment_for_matched_line(filename) +end diff --git a/danger/specs/Dangerfile b/danger/specs/Dangerfile index d17c17bc545..ff766cf688e 100644 --- a/danger/specs/Dangerfile +++ b/danger/specs/Dangerfile @@ -50,12 +50,8 @@ if has_ee_app_changes && has_spec_changes && !(has_app_changes || has_ee_spec_ch end # Forbidding a new file addition under `/spec/controllers` or `/ee/spec/controllers` -if helper.changes.added.files.grep(%r{^(ee/)?spec/controllers/}).any? - warn CONTROLLER_SPEC_DEPRECATION_MESSAGE -end +warn CONTROLLER_SPEC_DEPRECATION_MESSAGE if helper.changes.added.files.grep(%r{^(ee/)?spec/controllers/}).any? specs.changed_specs_files.each do |filename| - specs.add_suggestions_for_match_with_array(filename) - specs.add_suggestions_for_project_factory_usage(filename) - specs.add_suggestions_for_feature_category(filename) + specs.add_suggestions_for(filename) end diff --git a/danger/stable_branch_patch/Dangerfile b/danger/stable_branch_patch/Dangerfile index 2ac1b14c91f..a4b557c1eaa 100644 --- a/danger/stable_branch_patch/Dangerfile +++ b/danger/stable_branch_patch/Dangerfile @@ -2,7 +2,7 @@ if stable_branch.encourage_package_and_qa_execution? markdown(<<~MARKDOWN) - ## QA `e2e:package-and-test` + ## QA `e2e:package-and-test-ee` **@#{helper.mr_author}, the `package-and-test` job must complete before merging this merge request.*** |