From b4a7469fad5cb77f4897692b33afa3062c2a3ff1 Mon Sep 17 00:00:00 2001 From: Max Jacobson Date: Mon, 14 Nov 2016 18:52:59 -0500 Subject: [PATCH 1/2] Pass thru Travis PR SHA When Travis builds a PR, as opposed to a push, it checks out the merge commit that GitHub exposes and runs the tests at that SHA. When we report the results, however, we'd like to report them for the HEAD SHA from the PR, because otherwise the status won't show up. it's possible the coverage results will differ slightly between the merge SHA and the HEAD sha, but I'm not sure if anyone will be offended by this fiction. We've had one report that a user is surprised not to receive a status check when they only have Pull Request builds enabled, and not Push builds. --- lib/code_climate/test_reporter/ci.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/code_climate/test_reporter/ci.rb b/lib/code_climate/test_reporter/ci.rb index 455467b..559ea05 100644 --- a/lib/code_climate/test_reporter/ci.rb +++ b/lib/code_climate/test_reporter/ci.rb @@ -4,12 +4,16 @@ class Ci def self.service_data(env = ENV) if env["TRAVIS"] + travis_extras = {} + if env["TRAVIS_PULL_REQUEST_SHA"] != "" + travis_extras[:commit_sha] = env["TRAVIS_PULL_REQUEST_SHA"] + end { name: "travis-ci", branch: env["TRAVIS_BRANCH"], build_identifier: env["TRAVIS_JOB_ID"], pull_request: env["TRAVIS_PULL_REQUEST"] - } + }.merge(travis_extras) elsif env["CIRCLECI"] { name: "circleci", From edc4ccbc96c53d6b4d74c73ebf686c8cc7a799a2 Mon Sep 17 00:00:00 2001 From: Max Jacobson Date: Mon, 14 Nov 2016 19:13:27 -0500 Subject: [PATCH 2/2] also send the branch from the pull request --- lib/code_climate/test_reporter/ci.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/code_climate/test_reporter/ci.rb b/lib/code_climate/test_reporter/ci.rb index 559ea05..557b267 100644 --- a/lib/code_climate/test_reporter/ci.rb +++ b/lib/code_climate/test_reporter/ci.rb @@ -7,6 +7,7 @@ def self.service_data(env = ENV) travis_extras = {} if env["TRAVIS_PULL_REQUEST_SHA"] != "" travis_extras[:commit_sha] = env["TRAVIS_PULL_REQUEST_SHA"] + travis_extras[:branch] = env["TRAVIS_PULL_REQUEST_BRANCH"] end { name: "travis-ci",