Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Send a message on GitHub when a duplicate preflight poll terminates. #1084

Merged
merged 2 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/worker/batcher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,15 @@ defmodule BorsNG.Worker.Batcher do

Logger.info("Continue Poll Patch #{patch.id} prerun")

project = Repo.get(Project, patch.project_id)
repo_conn = get_repo_conn(project)

case Repo.get(Patch.all(:awaiting_review), patch.id) do
nil ->
send_message(repo_conn, [patch], {:preflight, :duplicate})
Logger.info("Patch #{patch.id} already left prerun, exiting prerun poll loop")

_ ->
project = Repo.get(Project, patch.project_id)
repo_conn = get_repo_conn(project)
{:ok, toml} = Batcher.GetBorsToml.get(repo_conn, patch.commit)

prerun_timeout_ms = toml.prerun_timeout_sec * 1000
Expand Down
4 changes: 4 additions & 0 deletions lib/worker/batcher/message.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ defmodule BorsNG.Worker.Batcher.Message do
"All preflight checks passed. Batching this PR into the staging branch."
end

def generate_message({:preflight, :duplicate}) do
"Stopped waiting for PR status (Github check) without running due to duplicate requests to run. You may check Bors to see that this PR is included in a batch by one of the other requests."
end

def generate_message({:preflight, :timeout}) do
"GitHub status checks took too long to complete, so bors is giving up. You can adjust bors configuration to have it wait longer if you like."
end
Expand Down
2 changes: 2 additions & 0 deletions test/batcher/batcher_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,8 @@ defmodule BorsNG.Worker.BatcherTest do
commits: %{},
comments: %{
1 => [
"Stopped waiting for PR status (Github check) without running due to duplicate requests to run. You may check Bors to see that this PR is included in a batch by one of the other requests.",
"Stopped waiting for PR status (Github check) without running due to duplicate requests to run. You may check Bors to see that this PR is included in a batch by one of the other requests.",
":clock1: Waiting for PR status (Github check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set."
]
},
Expand Down