-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #403 from Fryguy/pr_mergeability_checker_to_commit…
…_range Change PrMergeabilityChecker to be queued by BranchMergeabilityChecker.
- Loading branch information
Showing
9 changed files
with
92 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/workers/commit_monitor_handlers/commit_range/branch_mergeability_checker.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class CommitMonitorHandlers::CommitRange::BranchMergeabilityChecker | ||
include Sidekiq::Worker | ||
sidekiq_options :queue => :miq_bot | ||
|
||
include BranchWorkerMixin | ||
|
||
def self.handled_branch_modes | ||
[:regular] | ||
end | ||
|
||
def perform(branch_id, _new_commits) | ||
return unless find_branch(branch_id, :regular) | ||
|
||
repo.pr_branches.where(:merge_target => branch.name).each do |pr| | ||
logger.info("Queueing PrMergeabilityChecker for PR #{pr.fq_pr_number}.") | ||
PrMergeabilityChecker.perform_async(pr.id) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
spec/workers/commit_monitor_handlers/commit_range/branch_mergeability_checker_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
describe CommitMonitorHandlers::CommitRange::BranchMergeabilityChecker do | ||
let!(:branch) { create(:branch) } | ||
let!(:pr_branch) { create(:pr_branch, :repo => branch.repo, :merge_target => branch.name) } | ||
let!(:pr_branch2) { create(:pr_branch, :repo => branch.repo) } | ||
|
||
before { stub_sidekiq_logger } | ||
|
||
it "queues up PrMergeabilityChecker for PRs targeting this branch" do | ||
expect(PrMergeabilityChecker).to receive(:perform_async).once.with(pr_branch.id) | ||
|
||
described_class.new.perform(branch.id, ["abcde123"]) | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
...rs/branch/pr_mergeability_checker_spec.rb → spec/workers/pr_mergeability_checker_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters