debian-mirror-gitlab/tooling/danger/sidekiq_queues.rb

38 lines
954 B
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
2021-03-11 19:13:27 +05:30
module Tooling
2020-07-28 23:09:34 +05:30
module Danger
module SidekiqQueues
def changed_queue_files
@changed_queue_files ||= git.modified_files.grep(%r{\A(ee/)?app/workers/all_queues\.yml})
end
def added_queue_names
@added_queue_names ||= new_queues.keys - old_queues.keys
end
def changed_queue_names
@changed_queue_names ||=
(new_queues.values_at(*old_queues.keys) - old_queues.values)
.compact.map { |queue| queue[:name] }
end
private
def old_queues
@old_queues ||= queues_for(gitlab.base_commit)
end
def new_queues
@new_queues ||= queues_for(gitlab.head_commit)
end
def queues_for(branch)
changed_queue_files
.flat_map { |file| YAML.safe_load(`git show #{branch}:#{file}`, permitted_classes: [Symbol]) }
.to_h { |queue| [queue[:name], queue] }
end
end
end
end