Commit d2292276 authored by Alina Mihaila's avatar Alina Mihaila Committed by Pavel Shutsin

Add performance indicator changes to Danger

parent cffd45fa
......@@ -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