diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
commit | db384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch) | |
tree | 34beaef37df5f47ccbcf5729d7583aae093cffa0 /danger | |
parent | 54fd7b1bad233e3944434da91d257fa7f63c3996 (diff) |
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
Diffstat (limited to 'danger')
-rw-r--r-- | danger/bulk_database_actions/Dangerfile | 3 | ||||
-rw-r--r-- | danger/database/Dangerfile | 19 | ||||
-rw-r--r-- | danger/model_validations/Dangerfile | 3 | ||||
-rw-r--r-- | danger/plugins/bulk_database_actions.rb | 9 | ||||
-rw-r--r-- | danger/plugins/model_validations.rb | 10 | ||||
-rw-r--r-- | danger/plugins/required_stops.rb | 10 | ||||
-rw-r--r-- | danger/qa_selector/Dangerfile | 35 | ||||
-rw-r--r-- | danger/required_stops/Dangerfile | 3 | ||||
-rw-r--r-- | danger/roulette/Dangerfile | 8 | ||||
-rw-r--r-- | danger/z_metadata/Dangerfile | 19 |
10 files changed, 72 insertions, 47 deletions
diff --git a/danger/bulk_database_actions/Dangerfile b/danger/bulk_database_actions/Dangerfile new file mode 100644 index 00000000000..a8cc7bea000 --- /dev/null +++ b/danger/bulk_database_actions/Dangerfile @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +bulk_database_actions.add_comment_for_bulk_database_action_method_usage diff --git a/danger/database/Dangerfile b/danger/database/Dangerfile index 1c0e9d72118..f3bdddb0d95 100644 --- a/danger/database/Dangerfile +++ b/danger/database/Dangerfile @@ -31,8 +31,10 @@ by removing the ~database label and re-running the [`danger-review` job](#{ENV[' MSG DB_MIGRATION_TESTING_REQUIRED_MESSAGE = <<~MSG -1. Kick off the `db:gitlabcom-database-testing` manual job. This job can also be used before - requesting review to test your migrations against production data. +The [database migration pipeline](https://docs.gitlab.com/ee/development/database/database_migration_pipeline.html) +must be triggered by the job `db:gitlabcom-database-testing` must be run before requesting +~database review. This job takes ~30m and will post the results to a comment on the merge +request. Please run and review any results before passing to a reviewer. MSG DB_OLD_MIGRATIONS_MESSAGE = <<~MSG @@ -45,6 +47,8 @@ DB_OLD_MIGRATIONS_MESSAGE = <<~MSG MSG DATABASE_APPROVED_LABEL = 'database::approved' +DATABASE_TESTING_RUN_LABEL = 'database-testing-automation' +COMMUNITY_CONTRIBUTION_LABEL = 'Community contribution' non_geo_db_schema_updated = !git.modified_files.grep(%r{\Adb/structure\.sql}).empty? geo_db_schema_updated = !git.modified_files.grep(%r{\Aee/db/geo/structure\.sql}).empty? @@ -67,14 +71,19 @@ end return unless helper.ci? return if helper.mr_labels.include?(DATABASE_APPROVED_LABEL) -db_paths_to_review = helper.changes_by_category[:database] +migration_testing_has_run = helper.mr_labels.include?(DATABASE_TESTING_RUN_LABEL) +community_contribution = helper.mr_labels.include?(COMMUNITY_CONTRIBUTION_LABEL) +if non_geo_migration_created && !migration_testing_has_run && !community_contribution + fail DB_MIGRATION_TESTING_REQUIRED_MESSAGE # rubocop:disable Style/SignalException +end -if helper.mr_labels.include?('database') || db_paths_to_review.any? +if helper.mr_labels.include?('database') || database.changes.any? message 'This merge request adds or changes files that require a ' \ 'review from the [Database team](https://gitlab.com/groups/gl-database/-/group_members).' markdown(DB_MESSAGE) - markdown(DB_MIGRATION_TESTING_REQUIRED_MESSAGE) if non_geo_migration_created + + db_paths_to_review = database.changed_database_paths if db_paths_to_review.any? markdown(DB_FILES_MESSAGE + helper.markdown_list(db_paths_to_review.to_set)) diff --git a/danger/model_validations/Dangerfile b/danger/model_validations/Dangerfile new file mode 100644 index 00000000000..5daea3cdaa2 --- /dev/null +++ b/danger/model_validations/Dangerfile @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +model_validations.add_comment_for_added_validations diff --git a/danger/plugins/bulk_database_actions.rb b/danger/plugins/bulk_database_actions.rb new file mode 100644 index 00000000000..cc1b21a6673 --- /dev/null +++ b/danger/plugins/bulk_database_actions.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require_relative '../../tooling/danger/bulk_database_actions' + +module Danger + class BulkDatabaseActions < ::Danger::Plugin + include Tooling::Danger::BulkDatabaseActions + end +end diff --git a/danger/plugins/model_validations.rb b/danger/plugins/model_validations.rb new file mode 100644 index 00000000000..ceb8db32da2 --- /dev/null +++ b/danger/plugins/model_validations.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require_relative '../../tooling/danger/model_validations' + +module Danger + class ModelValidations < ::Danger::Plugin + # Put the helper code somewhere it can be tested + include Tooling::Danger::ModelValidations + end +end diff --git a/danger/plugins/required_stops.rb b/danger/plugins/required_stops.rb new file mode 100644 index 00000000000..7c845201d4d --- /dev/null +++ b/danger/plugins/required_stops.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require_relative '../../tooling/danger/required_stops' + +module Danger + class RequiredStops < ::Danger::Plugin + # Put the helper code somewhere it can be tested + include Tooling::Danger::RequiredStops + end +end diff --git a/danger/qa_selector/Dangerfile b/danger/qa_selector/Dangerfile index f049915dc42..57f992ec160 100644 --- a/danger/qa_selector/Dangerfile +++ b/danger/qa_selector/Dangerfile @@ -2,17 +2,17 @@ return if helper.stable_branch? -data_qa_selectors = /qa_selector|data-qa-selector/ +data_testids = /testid|data-testid|find_by_testid|within_testid/ -deprecated_qa_selectors = /(?!.*\bdata-qa-)(?=class=.*qa-.*|class: .*qa-.*)/ +deprecated_qa_selectors = /(?=qa_selector|data-qa-selector)|(?!.*\bdata-qa-)(?=class=.*qa-.*|class: .*qa-.*)/ def filter_changed_lines(files, pattern) lines = [] files.each do |file| - qa_selector_changed_lines = helper.changed_lines(file).select { |line| line =~ pattern } - next unless qa_selector_changed_lines.any? + testid_changed_lines = helper.changed_lines(file).select { |line| line =~ pattern } + next unless testid_changed_lines.any? - lines += ["file `#{file}`:", qa_selector_changed_lines] + lines += ["file `#{file}`:", testid_changed_lines] end lines end @@ -21,24 +21,25 @@ changed_code_files = helper.changed_files(/\.(vue|haml|js|rb)$/) return if changed_code_files.empty? -lines_with_qa_selectors = filter_changed_lines(changed_code_files, data_qa_selectors) +lines_with_testids = filter_changed_lines(changed_code_files, data_testids) deprecated_qa_class = filter_changed_lines(changed_code_files, deprecated_qa_selectors) -return if (lines_with_qa_selectors + deprecated_qa_class).empty? +return if (lines_with_testids + deprecated_qa_class).empty? markdown(<<~MARKDOWN) - ## QA Selectors + ## Testid Selectors MARKDOWN -if lines_with_qa_selectors.any? +if lines_with_testids.any? markdown(<<~MARKDOWN) - The following changed lines in this MR contain QA selectors: + The following changed lines in this MR contain testid selectors: - * #{lines_with_qa_selectors.join("\n* ")} + * #{lines_with_testids.join("\n* ")} - Please ensure `e2e:package-and-test` job is run and the tests are passing. + If the `e2e:package-and-test` job in the `qa` stage has run automatically, please ensure the tests are passing. + If the job has not run, please start the `trigger-omnibus-and-follow-up-e2e` job in the `qa` stage and ensure the tests in `follow-up-e2e:package-and-test-ee` pipeline are passing. For the list of known failures please refer to [the latest pipeline triage issue](https://gitlab.com/gitlab-org/quality/pipeline-triage/-/issues). @@ -46,20 +47,20 @@ if lines_with_qa_selectors.any? MARKDOWN - warn "This merge request contains lines with QA selectors. Please ensure `e2e:package-and-test` job is run." + warn "This merge request contains lines with testid selectors. Please ensure `e2e:package-and-test` job is run." end if deprecated_qa_class.any? markdown(<<~MARKDOWN) - ### Deprecated .qa-selector class + ### Deprecated data-qa-selector - The following lines in this MR contain deprecated qa class selectors: + The following lines in this MR contain deprecated data-qa-selector selectors: * #{deprecated_qa_class.join("\n* ")} - Please ensure all deprecated qa class selectors are replaced with data-qa-selectors in accordance with our [Testing Guide](https://docs.gitlab.com/ee/development/testing_guide/end_to_end/page_objects.html#data-qa-selector-vs-qa-selector). + Please ensure all deprecated data-qa-selector attributes are replaced with data-testid attributes in accordance with our [Testing Guide](https://docs.gitlab.com/ee/development/testing_guide/end_to_end/page_objects.html#data-testid-vs-data-qa-selector). MARKDOWN - warn "This merge request contains deprecated .qa-selector CSS class. Please use data-qa-selector attribute instead." + warn "This merge request contains deprecated data-qa-selector attribute. Please use data-testid attribute instead." end diff --git a/danger/required_stops/Dangerfile b/danger/required_stops/Dangerfile new file mode 100644 index 00000000000..227ee0aa185 --- /dev/null +++ b/danger/required_stops/Dangerfile @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +required_stops.add_comment_for_finalized_migrations diff --git a/danger/roulette/Dangerfile b/danger/roulette/Dangerfile index 39b79745ead..33fcb6cb807 100644 --- a/danger/roulette/Dangerfile +++ b/danger/roulette/Dangerfile @@ -97,12 +97,8 @@ categories = roulette.prepare_categories(changes.keys - [:unknown]) # 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) - - if categories.include?(:ux) # rubocop:disable Style/IfUnlessModifier - roulette.assign_pedroms_for_ux_wider_community_contribution(random_roulette_spins) - end +if changes.any? || roulette.required_approvals.any? + random_roulette_spins = roulette.spin(nil, categories) rows = random_roulette_spins.map do |spin| markdown_row_for_spin(spin.category, spin) diff --git a/danger/z_metadata/Dangerfile b/danger/z_metadata/Dangerfile deleted file mode 100644 index 1c36c02b69e..00000000000 --- a/danger/z_metadata/Dangerfile +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# rubocop:disable Style/SignalException - -default_branch = ENV['CI_DEFAULT_BRANCH'] || 'main' - -if gitlab.mr_body.size < 5 - fail "Please provide a proper merge request description." -end - -unless gitlab.mr_json["assignee"] - warn "This merge request does not have any assignee yet. Setting an assignee clarifies who needs to take action on the merge request at any given time." -end - -has_milestone = !gitlab.mr_json["milestone"].nil? - -unless has_milestone || (helper.security_mr? && helper.mr_target_branch == default_branch) - warn "This merge request does not refer to an existing milestone.", sticky: false -end |