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

Commit 4aa7dfa

Browse files
committed
Merge pull request #55 from codeclimate/mg-ia-skipped-status-message
Update GitHub status description for skipped builds
2 parents 6bb2a12 + 206107d commit 4aa7dfa

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

lib/cc/services/github_pull_requests.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def receive_pull_request
5555
else
5656
simple_failure("Nothing happened")
5757
end
58+
when "skipped"
59+
if config.update_status
60+
update_status_skipped
61+
end
5862
when "error"
5963
update_status_error
6064
else
@@ -68,6 +72,10 @@ def simple_failure(message)
6872
{ ok: false, message: message }
6973
end
7074

75+
def update_status_skipped
76+
update_status("success", "Code Climate has skipped analysis of this commit.")
77+
end
78+
7179
def update_status_success
7280
update_status("success", "Code Climate has analyzed this pull request.")
7381
end

test/github_pull_requests_test.rb

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,39 @@ def test_pull_request_status_error
4040
})
4141
end
4242

43+
def test_pull_request_status_skipped
44+
expect_status_update("pbrisbin/foo", "abc123", {
45+
"state" => "success",
46+
"description" => /skipped analysis/,
47+
})
48+
49+
receive_pull_request({ update_status: true }, {
50+
github_slug: "pbrisbin/foo",
51+
commit_sha: "abc123",
52+
state: "skipped",
53+
})
54+
end
55+
56+
def test_no_status_update_for_skips_when_update_status_config_is_falsey
57+
# With no POST expectation, test will fail if request is made.
58+
59+
receive_pull_request({}, {
60+
github_slug: "pbrisbin/foo",
61+
commit_sha: "abc123",
62+
state: "skipped",
63+
})
64+
end
65+
66+
def test_no_comment_for_skips_regardless_of_add_comment_config
67+
# With no POST expectation, test will fail if request is made.
68+
69+
receive_pull_request({ add_comment: true }, {
70+
github_slug: "pbrisbin/foo",
71+
commit_sha: "abc123",
72+
state: "skipped",
73+
})
74+
end
75+
4376
def test_pull_request_status_test_success
4477
@stubs.post("/repos/pbrisbin/foo/statuses/#{"0" * 40}") { |env| [422, {}, ""] }
4578

@@ -169,5 +202,4 @@ def receive_test(config, event_data = {})
169202
{ name: "test" }.merge(event_data)
170203
)
171204
end
172-
173205
end

0 commit comments

Comments
 (0)