Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-09-20 14:18:08 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-09-20 14:18:08 +0300
commit5afcbe03ead9ada87621888a31a62652b10a7e4f (patch)
tree9918b67a0d0f0bafa6542e839a8be37adf73102d /tooling
parentc97c0201564848c1f53226fe19d71fdcc472f7d0 (diff)
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'tooling')
-rw-r--r--tooling/audit_events/docs/templates/audit_event_types.md.erb18
-rw-r--r--tooling/danger/clickhouse.rb11
-rw-r--r--tooling/danger/ignored_model_columns.rb76
-rw-r--r--tooling/danger/project_helper.rb4
-rw-r--r--tooling/danger/required_stops.rb3
5 files changed, 102 insertions, 10 deletions
diff --git a/tooling/audit_events/docs/templates/audit_event_types.md.erb b/tooling/audit_events/docs/templates/audit_event_types.md.erb
index 9376b3c4fcd..429d341f9a6 100644
--- a/tooling/audit_events/docs/templates/audit_event_types.md.erb
+++ b/tooling/audit_events/docs/templates/audit_event_types.md.erb
@@ -17,18 +17,24 @@ info: "See the Technical Writers assigned to Development Guidelines: https://abo
Please do not edit this file directly. To update this file, run:
bundle exec rake gitlab:audit_event_types:compile_docs
+
+ To make changes to the output of the rake task,
+ edit `tooling/audit_events/docs/templates/audit_event_types.md.erb`.
--->
-# Audit event types **(ULTIMATE)**
+# Audit event types **(PREMIUM ALL)**
Audit event types are used to [filter streamed audit events](index.md#update-event-filters).
-Every audit event is associated with an event type. The association with the event type can mean that an audit event is:
+Every audit event is associated with an event type. Audit event types can allow audit events to be:
+
+- Saved to the database. Available in the Premium and Ultimate tier. You can retrieve audit events associated with these
+ types by using the audit events dashboard or the [audit events API](../../api/audit_events.md).
+- Streamed to external destinations. Available in the Ultimate tier. You can stream audit events associated with these
+ types [to external destinations](../index.md) if a destination is set.
-- Saved to database. Audit events associated with these types are retrievable by using the audit events dashboard or the [audit events API](../../api/audit_events.md).
-- Streamed. Audit events associated with these types are [streamed to external destinations](../index.md) if a
- destination is set.
-- Not streamed. Audit events associated with these types are not streamed to external destinations even if a destination is set.
+Some audit event types don't allow saving audit events to the database. Other audit event types don't allow streaming
+audit events to external destinations.
## Available audit event types
diff --git a/tooling/danger/clickhouse.rb b/tooling/danger/clickhouse.rb
new file mode 100644
index 00000000000..b36e12219ed
--- /dev/null
+++ b/tooling/danger/clickhouse.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+module Tooling
+ module Danger
+ module Clickhouse
+ def changes
+ helper.changes_by_category[:clickhouse]
+ end
+ end
+ end
+end
diff --git a/tooling/danger/ignored_model_columns.rb b/tooling/danger/ignored_model_columns.rb
new file mode 100644
index 00000000000..50379eed85c
--- /dev/null
+++ b/tooling/danger/ignored_model_columns.rb
@@ -0,0 +1,76 @@
+# frozen_string_literal: true
+
+require_relative 'suggestor'
+
+module Tooling
+ module Danger
+ module IgnoredModelColumns
+ include ::Tooling::Danger::Suggestor
+
+ METHODS = %w[remove_column cleanup_concurrent_column_rename cleanup_conversion_of_integer_to_bigint].freeze
+ MIGRATION_FILES_REGEX = %r{^db/(post_)?migrate}
+ MIGRATION_METHODS_REGEX = /^\+\s*(.*\.)?(#{METHODS.join('|')})[(\s]/
+ UP_METHOD_REGEX = /^.+(def\sup)/
+ END_METHOD_REGEX = /^.+(end)/
+ DOC_URL = "https://docs.gitlab.com/ee/development/database/avoiding_downtime_in_migrations.html"
+
+ COMMENT = <<~COMMENT.freeze
+ Column operations, like [dropping](#{DOC_URL}#dropping-columns), [renaming](#{DOC_URL}#renaming-columns) or
+ [primary key conversion](#{DOC_URL}#migrating-integer-primary-keys-to-bigint), require columns to be ignored in
+ the model. This step is necessary because Rails caches the columns and re-uses it in various places across the
+ application. Please ensure that columns are properly ignored in the model.
+ COMMENT
+
+ def add_comment_for_ignored_model_columns
+ migration_files.each do |filename|
+ add_suggestion(filename: filename, regex: MIGRATION_METHODS_REGEX, comment_text: COMMENT)
+ end
+ end
+
+ private
+
+ # This method was overwritten to make use of +up_method_lines+.
+ # It's necessary to only match lines that are inside the +up+ block in a migration file.
+ #
+ # @return [Integer, Nil] the line number - only if the line is from within a +up+ method
+ def find_line_number(file_lines, searched_line, exclude_indexes: [])
+ lines_to_search = up_method_lines(file_lines)
+
+ _, index = file_lines.each_with_index.find do |file_line, index|
+ next unless lines_to_search.include?(index)
+
+ file_line == searched_line && !exclude_indexes.include?(index) # rubocop:disable Rails/NegateInclude
+ end
+
+ index
+ end
+
+ # Return the line numbers from within the up method
+ #
+ # @example
+ # line 0 def up
+ # line 1 cleanup_conversion_of_integer_to_bigint():my_table, :my_column)
+ # line 2 remove_column(:my_table, :my_column)
+ # line 3 other_method
+ # line 4 end
+ #
+ # => [1, 2, 3]
+ def up_method_lines(file_lines)
+ capture_up_block = false
+ up_method_content_lines = []
+
+ file_lines.each_with_index do |content, line_number|
+ capture_up_block = false if capture_up_block && END_METHOD_REGEX.match?(content)
+ up_method_content_lines << line_number if capture_up_block
+ capture_up_block = true if UP_METHOD_REGEX.match?(content)
+ end
+
+ up_method_content_lines
+ end
+
+ def migration_files
+ helper.all_changed_files.grep(MIGRATION_FILES_REGEX)
+ end
+ end
+ end
+end
diff --git a/tooling/danger/project_helper.rb b/tooling/danger/project_helper.rb
index 633c7b57097..d0cea5516ac 100644
--- a/tooling/danger/project_helper.rb
+++ b/tooling/danger/project_helper.rb
@@ -98,8 +98,8 @@ module Tooling
\.gitlab/ci/frontend\.gitlab-ci\.yml
)\z}x => %i[frontend tooling],
- %r{\A((ee|jh)/)?db/(geo/)?(migrate|post_migrate)/} => [:database],
- %r{\A((ee|jh)/)?db/(?!fixtures)[^/]+} => [:database],
+ %r{\A((ee|jh)/)?db/(geo/)?(?!click_house|fixtures)[^/]+} => [:database],
+ %r{\A((ee|jh)/)?db/[^/]+\z} => [:database], # db/ root files
%r{\A((ee|jh)/)?lib/gitlab/(database|background_migration|sql)(/|\.rb)} => [:database, :backend],
%r{\A(app/services/authorized_project_update/find_records_due_for_refresh_service)(/|\.rb)} => [:database, :backend],
%r{\A(app/models/project_authorization|app/services/users/refresh_authorized_projects_service)(/|\.rb)} => [:database, :backend],
diff --git a/tooling/danger/required_stops.rb b/tooling/danger/required_stops.rb
index dcba23021ad..788be5d70e6 100644
--- a/tooling/danger/required_stops.rb
+++ b/tooling/danger/required_stops.rb
@@ -17,8 +17,7 @@ module Tooling
WARNING_COMMENT = <<~COMMENT.freeze
Finalizing data migration might be time consuming and require a [required stop](#{DOC_URL}).
Check the timings of the underlying data migration.
- If possible postpone the finalization to the scheduled required stop.
- If postponing is impossible please create new required stop as documentation suggests.
+ If possible schedule finalization for the first minor version after the next required stop.
COMMENT
def add_comment_for_finalized_migrations