Commit bb48d270 authored by Pavel Shutsin's avatar Pavel Shutsin

Merge branch 'am-add-data-label-to-pi-changes-mr' into 'master'

Add performance indicator changes to Danger

See merge request gitlab-org/gitlab!77017
parents 74dadeb0 d2292276
......@@ -6,14 +6,28 @@ DATA_WAREHOUSE_LABELS = [
"Data Warehouse::Not Impacted"
].freeze
FILE_PATH_REGEX = %r{((ee|jh)/)?config/metrics(/.+\.yml)}.freeze
PERFORMANCE_INDICATOR_REGEX = %r{gmau|smau|paid_gmau|umau}.freeze
CHANGED_SCHEMA_MESSAGE = <<~MSG
Notification to the Data Team about changes to the db/structure.sql file, add label `Data Warehouse::Impact Check`.
Notification to the Data Team about changes to files with possible impact on Data Warehouse, add label `Data Warehouse::Impact Check`.
/label ~"Data Warehouse::Impact Check"
The following files require a review:
MSG
db_schema_updated = !git.modified_files.grep(%r{\Adb/structure\.sql}).empty?
metrics_definitions_files = git.modified_files.grep(FILE_PATH_REGEX)
data_warehouse_impact_files = metrics_definitions_files.select do |file|
helper.changed_lines(file).grep(PERFORMANCE_INDICATOR_REGEX).any?
end.compact
data_warehouse_impact_files << 'db/structure.sql' if db_schema_updated
no_data_warehouse_labels = (gitlab.mr_labels & DATA_WAREHOUSE_LABELS).empty?
markdown(CHANGED_SCHEMA_MESSAGE) if db_schema_updated && no_data_warehouse_labels
markdown(CHANGED_SCHEMA_MESSAGE + helper.markdown_list(data_warehouse_impact_files)) if data_warehouse_impact_files.any? && no_data_warehouse_labels
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment