diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /danger | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) | |
download | gitlab-ce-9dc93a4519d9d5d7be48ff274127136236a3adb3.tar.gz |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'danger')
-rw-r--r-- | danger/changelog/Dangerfile | 32 | ||||
-rw-r--r-- | danger/commit_messages/Dangerfile | 2 | ||||
-rw-r--r-- | danger/datateam/Dangerfile | 15 | ||||
-rw-r--r-- | danger/feature_flag/Dangerfile | 14 | ||||
-rw-r--r-- | danger/pipeline/Dangerfile | 4 | ||||
-rw-r--r-- | danger/product_intelligence/Dangerfile | 21 | ||||
-rw-r--r-- | danger/roulette/Dangerfile | 26 | ||||
-rw-r--r-- | danger/specs/Dangerfile | 6 |
8 files changed, 87 insertions, 33 deletions
diff --git a/danger/changelog/Dangerfile b/danger/changelog/Dangerfile index 444303d4b9e..6f045d7b5ab 100644 --- a/danger/changelog/Dangerfile +++ b/danger/changelog/Dangerfile @@ -21,6 +21,7 @@ def check_changelog_yaml(path) fail "`type` should be set, in #{helper.html_link(path)}! #{SEE_DOC}" if yaml["type"].nil? return if helper.security_mr? + return if helper.mr_iid.to_s.empty? cherry_pick_against_stable_branch = helper.cherry_pick_mr? && helper.stable_branch? @@ -28,12 +29,12 @@ def check_changelog_yaml(path) mr_line = raw_file.lines.find_index("merge_request:\n") if mr_line - markdown(format(SUGGEST_MR_COMMENT, mr_iid: gitlab.mr_json["iid"]), file: path, line: mr_line.succ) + markdown(format(SUGGEST_MR_COMMENT, mr_iid: helper.mr_iid), file: path, line: mr_line.succ) else - message "Consider setting `merge_request` to #{gitlab.mr_json["iid"]} in #{helper.html_link(path)}. #{SEE_DOC}" + message "Consider setting `merge_request` to #{helper.mr_iid} in #{helper.html_link(path)}. #{SEE_DOC}" end - elsif yaml["merge_request"] != gitlab.mr_json["iid"] && !cherry_pick_against_stable_branch - fail "Merge request ID was not set to #{gitlab.mr_json["iid"]}! #{SEE_DOC}" + elsif yaml["merge_request"] != helper.mr_iid && !cherry_pick_against_stable_branch + fail "Merge request ID was not set to #{helper.mr_iid}! #{SEE_DOC}" end rescue Psych::Exception # YAML could not be parsed, fail the build. @@ -73,3 +74,26 @@ elsif changelog.required? elsif changelog.optional? message changelog.optional_text end + +message <<~MSG + We are in the process of rolling out a new workflow for adding changelog entries. This new workflow uses Git commit subjects and Git trailers to generate changelogs. This new approach will soon replace the current YAML based approach. + + To ease the transition process, we recommend you start using both the old and new approach in parallel. This is not required at this time, but will make it easier to transition to the new approach in the future. To do so, pick the commit that should go in the changelog and add a `Changelog` trailer to it. For example: + + ``` + This is my commit's subject line + + This is the optional commit body. + + Changelog: added + ``` + + The value of the `Changelog` trailer should be one of the following: added, fixed, changed, deprecated, removed, security, performance, other. + + For more information, take a look at the following resources: + + - https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/1564 + - https://docs.gitlab.com/ee/api/repositories.html#generate-changelog-data + + If you'd like to see the new approach in action, take a look at the commits in [the Omnibus repository](https://gitlab.com/gitlab-org/omnibus-gitlab/-/commits/master). +MSG diff --git a/danger/commit_messages/Dangerfile b/danger/commit_messages/Dangerfile index b4a0b6ad8cb..ac3d41adcf4 100644 --- a/danger/commit_messages/Dangerfile +++ b/danger/commit_messages/Dangerfile @@ -127,7 +127,7 @@ def warn_or_fail_commits(failed_linters, default_to_fail: true) Array(failed_linters).each do |linter| linter.problems.each do |problem_key, problem_desc| case problem_key - when :subject_too_short, :subject_above_warning + when :subject_too_short, :subject_above_warning, :details_too_many_changes, :details_line_too_long warn_commit(linter.commit, problem_desc) else self.__send__("#{level}_commit", linter.commit, problem_desc) # rubocop:disable GitlabSecurity/PublicSend diff --git a/danger/datateam/Dangerfile b/danger/datateam/Dangerfile new file mode 100644 index 00000000000..0a33cb6777b --- /dev/null +++ b/danger/datateam/Dangerfile @@ -0,0 +1,15 @@ +# frozen_string_literal: true +# rubocop:disable Style/SignalException + +CHANGED_SCHEMA_MESSAGE = <<~MSG +Mentioning @gitlab-data/engineers to notify the team about changes to the db/structure.sql file. + +MSG + +db_schema_updated = !git.modified_files.grep(%r{\Adb/structure\.sql}).empty? + +if db_schema_updated + + markdown(CHANGED_SCHEMA_MESSAGE) + +end diff --git a/danger/feature_flag/Dangerfile b/danger/feature_flag/Dangerfile index e66ed35c9ab..d14dd97380f 100644 --- a/danger/feature_flag/Dangerfile +++ b/danger/feature_flag/Dangerfile @@ -2,6 +2,7 @@ # rubocop:disable Style/SignalException 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" SUGGEST_MR_COMMENT = <<~SUGGEST_COMMENT ```suggestion @@ -65,14 +66,21 @@ if feature_flag_file_added_or_removed? new_mr_title << ' [RUN ALL RSPEC]' unless helper.run_all_rspec_mr? new_mr_title << ' [RUN AS-IF-FOSS]' unless helper.run_as_if_foss_mr? + changes = {} + changes[:add_labels] = FEATURE_FLAG_LABEL unless helper.mr_has_labels?(FEATURE_FLAG_LABEL) + if new_mr_title != helper.mr_title + changes[:title] = new_mr_title + else + message "You're adding or removing a feature flag, your MR title needs to include `[RUN ALL RSPEC] [RUN AS-IF-FOSS]` (we may have updated it automatically for you and started a new MR pipeline) to ensure everything is covered." + end + + if changes.any? gitlab.api.update_merge_request( gitlab.mr_json['project_id'], gitlab.mr_json['iid'], - title: new_mr_title + **changes ) gitlab.api.post("/projects/#{gitlab.mr_json['project_id']}/merge_requests/#{gitlab.mr_json['iid']}/pipelines") - else - message "You're adding or removing a feature flag, your MR title needs to include `[RUN ALL RSPEC] [RUN AS-IF-FOSS]` (we may have updated it automatically for you and started a new MR pipeline) to ensure everything is covered." end end diff --git a/danger/pipeline/Dangerfile b/danger/pipeline/Dangerfile index c71fb86325d..5503094ba50 100644 --- a/danger/pipeline/Dangerfile +++ b/danger/pipeline/Dangerfile @@ -3,9 +3,9 @@ MESSAGE = <<~MESSAGE ## Pipeline Changes -This Merge Request contains changes to the pipeline configuration for the GitLab project. +This merge request contains changes to the pipeline configuration for the GitLab project. -Please consider the effect of the changes in this Merge Request on the following: +Please consider the effect of the changes in this merge request on the following: - Effects on different [pipeline types](https://docs.gitlab.com/ee/development/pipelines.html#pipelines-for-merge-requests) - Effects on non-canonical projects: - `gitlab-foss` diff --git a/danger/product_intelligence/Dangerfile b/danger/product_intelligence/Dangerfile index fe77ea5fc52..d2bed7629ff 100644 --- a/danger/product_intelligence/Dangerfile +++ b/danger/product_intelligence/Dangerfile @@ -3,15 +3,13 @@ CHANGED_FILES_MESSAGE = <<~MSG For the following files, a review from the [Data team and Product Intelligence team](https://gitlab.com/groups/gitlab-org/growth/product-intelligence/engineers/-/group_members?with_inherited_permissions=exclude) is recommended -Please check the ~"product intelligence" [guide](https://docs.gitlab.com/ee/development/usage_ping.html) and reach out to %<engineers_group>s group for a review. +Please check the ~"product intelligence" [guide](https://docs.gitlab.com/ee/development/usage_ping.html). %<changed_files>s MSG -ENGINEERS_GROUP = '@gitlab-org/growth/product-intelligence/engineers' - UPDATE_DICTIONARY_MESSAGE = <<~MSG When adding, changing, or updating metrics, please update the [Metrics Dictionary](https://docs.gitlab.com/ee/development/usage_ping/dictionary.html) @@ -30,8 +28,10 @@ tracking_files = [ 'app/assets/javascripts/tracking.js', 'spec/frontend/tracking_spec.js', 'generator_templates/usage_metric_definition/metric_definition.yml', - 'lib/generators/rails/usage_metric_definition_generator.rb', - 'spec/lib/generators/usage_metric_definition_generator_spec.rb', + 'lib/generators/gitlab/usage_metric_definition_generator.rb', + 'lib/generators/gitlab/usage_metric_definition/redis_hll_generator.rb', + 'spec/lib/generators/gitlab/usage_metric_definition_generator_spec.rb', + 'spec/lib/generators/gitlab/usage_metric_definition/redis_hll_generator_spec.rb', 'config/metrics/schema.json' ] @@ -49,7 +49,8 @@ end js_patterns = Regexp.union( 'Tracking.event', /\btrack\(/, - 'data-track-event' + 'data-track-event', + 'data-track-action' ) dictionary_pattern = Regexp.union( @@ -81,13 +82,7 @@ matching_changed_files = usage_data_changed_files + if matching_changed_files.any? - mention = if helper.draft_mr? - "`#{ENGINEERS_GROUP}`" - else - ENGINEERS_GROUP - end - - warn format(CHANGED_FILES_MESSAGE, changed_files: helper.markdown_list(matching_changed_files), engineers_group: mention) + warn format(CHANGED_FILES_MESSAGE, changed_files: helper.markdown_list(matching_changed_files)) fail format(UPDATE_DICTIONARY_MESSAGE) if required_dictionary_update_changed_files.any? && dictionary_changed_file.empty? diff --git a/danger/roulette/Dangerfile b/danger/roulette/Dangerfile index b46220d7886..06d2929cd54 100644 --- a/danger/roulette/Dangerfile +++ b/danger/roulette/Dangerfile @@ -40,16 +40,21 @@ for them. MARKDOWN OPTIONAL_REVIEW_TEMPLATE = '%{role} review is optional for %{category}' -NOT_AVAILABLE_TEMPLATE = 'No %{role} available' +NOT_AVAILABLE_TEMPLATES = { + default: 'No %{role} available', + product_intelligence: "No engineer is available for automated assignment, please reach out to `#g_product_intelligence` slack channel or mention `@gitlab-org/growth/product-intelligence/engineers` for assistance." +}.freeze + +def note_for_spins_role(spins, role, category) + template = NOT_AVAILABLE_TEMPLATES[category] || NOT_AVAILABLE_TEMPLATES[:default] -def note_for_spins_role(spins, role) spins.each do |spin| note = note_for_spin_role(spin, role) return note if note end - NOT_AVAILABLE_TEMPLATE % { role: role } + template % { role: role } end def note_for_spin_role(spin, role) @@ -61,8 +66,8 @@ def note_for_spin_role(spin, role) end def markdown_row_for_spins(category, spins_array) - reviewer_note = note_for_spins_role(spins_array, :reviewer) - maintainer_note = note_for_spins_role(spins_array, :maintainer) + maintainer_note = note_for_spins_role(spins_array, :maintainer, category) + reviewer_note = note_for_spins_role(spins_array, :reviewer, category) "| #{helper.label_for_category(category)} | #{reviewer_note} | #{maintainer_note} |" end @@ -73,10 +78,17 @@ changes = project_helper.changes_by_category changes.delete(:none) # To reinstate roulette for documentation, remove this line. changes.delete(:docs) -categories = changes.keys - [:unknown] +# No special review for changelog needed and changelog was never a label. +changes.delete(:changelog) +# No special review for feature flags needed. +changes.delete(:feature_flag) +categories = Set.new(changes.keys - [:unknown]) # Ensure to spin for database reviewer/maintainer when ~database is applied (e.g. to review SQL queries) -categories << :database if helper.mr_labels.include?('database') && !categories.include?(:database) +categories << :database if helper.mr_labels.include?('database') + +# 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") if changes.any? project = project_helper.project_name diff --git a/danger/specs/Dangerfile b/danger/specs/Dangerfile index 26b52f64f2e..35476ae645d 100644 --- a/danger/specs/Dangerfile +++ b/danger/specs/Dangerfile @@ -7,12 +7,12 @@ NO_SPECS_LABELS = [ 'documentation', 'QA' ].freeze -NO_NEW_SPEC_MESSAGE = <<~MSG.freeze +NO_NEW_SPEC_MESSAGE = <<~MSG You've made some app changes, but didn't add any tests. That's OK as long as you're refactoring existing code, but please consider adding any of the %<labels>s labels. MSG -EE_CHANGE_WITH_FOSS_SPEC_CHANGE_MESSAGE = <<~MSG.freeze +EE_CHANGE_WITH_FOSS_SPEC_CHANGE_MESSAGE = <<~MSG You've made some EE-specific changes, but only made changes to FOSS tests. This could be a sign that you're testing an EE-specific behavior in a FOSS test. @@ -24,7 +24,7 @@ Please make sure the spec files pass in AS-IF-FOSS mode either: MSG -CONTROLLER_SPEC_DEPRECATION_MESSAGE = <<~MSG.freeze +CONTROLLER_SPEC_DEPRECATION_MESSAGE = <<~MSG Do not add new controller specs. We are moving from controller specs to request specs (and/or feature specs). Please add request specs under `/spec/requests` and/or `/ee/spec/requests` instead. |