Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 14a5012

Browse files
committed
Support failure statuses for GitHub
1 parent 4474f6e commit 14a5012

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/cc/services/github_pull_requests.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def receive_pull_request
4444
setup_http
4545
state = @payload["state"]
4646

47-
if %w(pending success skipped error).include?(state)
47+
if %w[pending success failure skipped error].include?(state)
4848
send("update_status_#{state}")
4949
else
5050
@response = simple_failure("Unknown state")
@@ -75,6 +75,11 @@ def update_status_success
7575
update_status("success", presenter.success_message)
7676
end
7777

78+
def update_status_failure
79+
add_comment
80+
update_status("failure", presenter.success_message)
81+
end
82+
7883
def presenter
7984
CC::Service::GitHubPullRequestsPresenter.new(@payload)
8085
end

test/github_pull_requests_test.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@ def test_pull_request_status_success_detailed
3030
)
3131
end
3232

33+
def test_pull_request_status_failure
34+
expect_status_update("pbrisbin/foo", "abc123", {
35+
"state" => "failure",
36+
"description" => "Code Climate found 2 new issues and 1 fixed issue.",
37+
})
38+
39+
receive_pull_request(
40+
{ update_status: true },
41+
{
42+
github_slug: "pbrisbin/foo",
43+
commit_sha: "abc123",
44+
state: "failure"
45+
}
46+
)
47+
end
48+
3349
def test_pull_request_status_success_generic
3450
expect_status_update("pbrisbin/foo", "abc123", {
3551
"state" => "success",

0 commit comments

Comments
 (0)