Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/cc/services/github_pull_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def receive_pull_request
else
simple_failure("Nothing happened")
end
when "skipped"
if config.update_status
update_status_skipped
end
when "error"
update_status_error
else
Expand All @@ -68,6 +72,10 @@ def simple_failure(message)
{ ok: false, message: message }
end

def update_status_skipped
update_status("success", "Code Climate has skipped analysis of this commit.")
end

def update_status_success
update_status("success", "Code Climate has analyzed this pull request.")
end
Expand Down
34 changes: 33 additions & 1 deletion test/github_pull_requests_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,39 @@ def test_pull_request_status_error
})
end

def test_pull_request_status_skipped
expect_status_update("pbrisbin/foo", "abc123", {
"state" => "success",
"description" => /skipped analysis/,
})

receive_pull_request({ update_status: true }, {
github_slug: "pbrisbin/foo",
commit_sha: "abc123",
state: "skipped",
})
end

def test_no_status_update_for_skips_when_update_status_config_is_falsey
# With no POST expectation, test will fail if request is made.

receive_pull_request({}, {
github_slug: "pbrisbin/foo",
commit_sha: "abc123",
state: "skipped",
})
end

def test_no_comment_for_skips_regardless_of_add_comment_config
# With no POST expectation, test will fail if request is made.

receive_pull_request({ add_comment: true }, {
github_slug: "pbrisbin/foo",
commit_sha: "abc123",
state: "skipped",
})
end

def test_pull_request_status_test_success
@stubs.post("/repos/pbrisbin/foo/statuses/#{"0" * 40}") { |env| [422, {}, ""] }

Expand Down Expand Up @@ -169,5 +202,4 @@ def receive_test(config, event_data = {})
{ name: "test" }.merge(event_data)
)
end

end