From cb4a77d5a61cf9a0fc72922ae2199b0fe475b47d Mon Sep 17 00:00:00 2001 From: Jason Frey Date: Tue, 6 Feb 2018 17:58:23 -0500 Subject: [PATCH 1/2] Move GithubPrCommenter to be a commit_range worker --- .../{batch => commit_range}/github_pr_commenter.rb | 0 .../github_pr_commenter/diff_content_checker.rb | 0 .../github_pr_commenter/diff_filename_checker.rb | 0 .../github_pr_commenter/diff_content_checker_spec.rb | 0 .../github_pr_commenter/diff_filename_checker_spec.rb | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename app/workers/commit_monitor_handlers/{batch => commit_range}/github_pr_commenter.rb (100%) rename app/workers/commit_monitor_handlers/{batch => commit_range}/github_pr_commenter/diff_content_checker.rb (100%) rename app/workers/commit_monitor_handlers/{batch => commit_range}/github_pr_commenter/diff_filename_checker.rb (100%) rename spec/workers/commit_monitor_handlers/{batch => commit_range}/github_pr_commenter/diff_content_checker_spec.rb (100%) rename spec/workers/commit_monitor_handlers/{batch => commit_range}/github_pr_commenter/diff_filename_checker_spec.rb (100%) diff --git a/app/workers/commit_monitor_handlers/batch/github_pr_commenter.rb b/app/workers/commit_monitor_handlers/commit_range/github_pr_commenter.rb similarity index 100% rename from app/workers/commit_monitor_handlers/batch/github_pr_commenter.rb rename to app/workers/commit_monitor_handlers/commit_range/github_pr_commenter.rb diff --git a/app/workers/commit_monitor_handlers/batch/github_pr_commenter/diff_content_checker.rb b/app/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_content_checker.rb similarity index 100% rename from app/workers/commit_monitor_handlers/batch/github_pr_commenter/diff_content_checker.rb rename to app/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_content_checker.rb diff --git a/app/workers/commit_monitor_handlers/batch/github_pr_commenter/diff_filename_checker.rb b/app/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_filename_checker.rb similarity index 100% rename from app/workers/commit_monitor_handlers/batch/github_pr_commenter/diff_filename_checker.rb rename to app/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_filename_checker.rb diff --git a/spec/workers/commit_monitor_handlers/batch/github_pr_commenter/diff_content_checker_spec.rb b/spec/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_content_checker_spec.rb similarity index 100% rename from spec/workers/commit_monitor_handlers/batch/github_pr_commenter/diff_content_checker_spec.rb rename to spec/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_content_checker_spec.rb diff --git a/spec/workers/commit_monitor_handlers/batch/github_pr_commenter/diff_filename_checker_spec.rb b/spec/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_filename_checker_spec.rb similarity index 100% rename from spec/workers/commit_monitor_handlers/batch/github_pr_commenter/diff_filename_checker_spec.rb rename to spec/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_filename_checker_spec.rb From 8fedc58a4a67a2a72045ecef039ec127d5cf4f77 Mon Sep 17 00:00:00 2001 From: Jason Frey Date: Tue, 6 Feb 2018 18:04:20 -0500 Subject: [PATCH 2/2] Change GithubPrCommenter to be a commit_range worker This commit temporarily merges batch workers with commit range workers, differentiating based on respond_to?(:perform_batch_async). This will be significantly changed when the final CommitMonitor revamp is completed. --- app/workers/commit_monitor.rb | 4 ++-- .../commit_range/github_pr_commenter.rb | 2 +- .../commit_range/github_pr_commenter/diff_content_checker.rb | 2 +- .../commit_range/github_pr_commenter/diff_filename_checker.rb | 2 +- .../github_pr_commenter/diff_content_checker_spec.rb | 2 +- .../github_pr_commenter/diff_filename_checker_spec.rb | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/workers/commit_monitor.rb b/app/workers/commit_monitor.rb index 6f8f937d..e7991762 100644 --- a/app/workers/commit_monitor.rb +++ b/app/workers/commit_monitor.rb @@ -22,7 +22,7 @@ def self.commit_handlers # to check the new commits, but as a group, since newer commits may fix # issues in prior commits. def self.commit_range_handlers - @commit_range_handlers ||= handlers_for(:commit_range) + @commit_range_handlers ||= handlers_for(:commit_range).select { |h| !h.respond_to?(:perform_batch_async) } end # branch handlers expect to handle an entire branch at once. @@ -38,7 +38,7 @@ def self.branch_handlers # # Example: A general commenter to GitHub for a number of issues def self.batch_handlers - @batch_handlers ||= handlers_for(:batch) + @batch_handlers ||= handlers_for(:commit_range).select { |h| h.respond_to?(:perform_batch_async) } end def perform diff --git a/app/workers/commit_monitor_handlers/commit_range/github_pr_commenter.rb b/app/workers/commit_monitor_handlers/commit_range/github_pr_commenter.rb index 34767345..be706734 100644 --- a/app/workers/commit_monitor_handlers/commit_range/github_pr_commenter.rb +++ b/app/workers/commit_monitor_handlers/commit_range/github_pr_commenter.rb @@ -1,4 +1,4 @@ -module CommitMonitorHandlers::Batch +module CommitMonitorHandlers::CommitRange class GithubPrCommenter include Sidekiq::Worker sidekiq_options :queue => :miq_bot_glacial diff --git a/app/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_content_checker.rb b/app/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_content_checker.rb index 3fc2d1e2..77dd687c 100644 --- a/app/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_content_checker.rb +++ b/app/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_content_checker.rb @@ -1,6 +1,6 @@ require 'rugged' -module CommitMonitorHandlers::Batch +module CommitMonitorHandlers::CommitRange class GithubPrCommenter::DiffContentChecker include Sidekiq::Worker sidekiq_options :queue => :miq_bot diff --git a/app/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_filename_checker.rb b/app/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_filename_checker.rb index 4d2273f8..df461131 100644 --- a/app/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_filename_checker.rb +++ b/app/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_filename_checker.rb @@ -1,6 +1,6 @@ require 'rugged' -module CommitMonitorHandlers::Batch +module CommitMonitorHandlers::CommitRange class GithubPrCommenter::DiffFilenameChecker include Sidekiq::Worker sidekiq_options :queue => :miq_bot_glacial diff --git a/spec/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_content_checker_spec.rb b/spec/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_content_checker_spec.rb index b452051c..3aa987e9 100644 --- a/spec/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_content_checker_spec.rb +++ b/spec/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_content_checker_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe CommitMonitorHandlers::Batch::GithubPrCommenter::DiffContentChecker do +describe CommitMonitorHandlers::CommitRange::GithubPrCommenter::DiffContentChecker do let(:batch_entry) { BatchEntry.create!(:job => BatchJob.create!) } let(:branch) { create(:pr_branch) } let(:content_1) { "def a(variable)" } diff --git a/spec/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_filename_checker_spec.rb b/spec/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_filename_checker_spec.rb index 93fec4bd..15f44187 100644 --- a/spec/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_filename_checker_spec.rb +++ b/spec/workers/commit_monitor_handlers/commit_range/github_pr_commenter/diff_filename_checker_spec.rb @@ -1,4 +1,4 @@ -describe CommitMonitorHandlers::Batch::GithubPrCommenter::DiffFilenameChecker do +describe CommitMonitorHandlers::CommitRange::GithubPrCommenter::DiffFilenameChecker do let(:batch_entry) { BatchEntry.create!(:job => BatchJob.create!) } let(:branch) { create(:pr_branch) } let(:git_service) { double("GitService", :diff => double("RuggedDiff", :new_files => new_files)) }