Skip to content

Commit

Permalink
travis: cc-test-reporter for Code Climate coverage
Browse files Browse the repository at this point in the history
Per: https://docs.codeclimate.com/v1.0/docs/test-reporter

Since I can't get `CODECLIMATE_REPO_TOKEN` to work after renaming the
repository from mbland/url-pointers to mbland/custom-links, this seems
worth a try.
  • Loading branch information
mbland committed Jul 26, 2017
1 parent 7b591f7 commit 0cddc72
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ before_install:
- sh -e /etc/init.d/xvfb start
- export PATH=$PWD/node_modules/phantomjs-prebuilt/lib/phantom/bin:$PATH
- npm install -g npm@^5.0.1
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
script:
- "./go setup"
env:
global:
- secure: ANIV8Nbz0uyJlbyGhOAHifuFJRvuhqGG2Tbo2vNr8hATd56Bxp1J+DCs9LDWi3uZK6zGrxOhDvywttdnC/ulYpV6btWmBCR7sl57BoyEc2xkX2Q1qQpSJ6fr+/4fmJkkZU2KRiQ+JSV4rBNVsqQywZiaRCXBlVUQlV81t7uIzqg6U3T8a7zOCY7Gg0gKNMjYOMEYGTyeIvcEYvKAAqZ0Z7Qib3ireMhzRj+lll94NrRyFNJwYQtxBZPXbF3FI/MmkKo61UeRuhVS/UyZv0qv9rnIyak16nydQjLyifG+s2h3xAW+sqQTocLYVKzgwKJPORAZQwCEkazKi/RnpzEuMjLXpvQ7dEZF0L8O/X+Mrb++15j01iTK85l+9+P3U1RnAgjFwpjnoAKXf/r0pU9O8N8y9xt9pwbSEy5sH+4dLAVU400+4R2Py+JNntNwCwJ7m2Giy5D+9FwV9w0fPz8PQMUom4PUDWulrA9y8pz7MOx3VdYPaCp1346nxSVkpv0B9u8GebTot/geoqmbbJB8nFstnC0G3HgM2jKnve8h4ok0xW3zN3C1JTzT37F+xsEgHddoP6dZ+6aLnDjgtcxvouME2kHGoNwU9n4Rw8cVJyfyy1BG2UJIWLxStm8U1zgEgTsWro5+wT5PK8o5CXCrmKhiWfGo2UEoLxVwTNK2tX0=
- secure: nqpv3MQGMDVSIx0TD6CL0oJVAvgD8HyUn02mzJ79HX8DMvT7UGaL6HuXbc7nATX04px9jdbkH2IKIFDuvIc73ZxZFRygwgU1MA+kuAPcafXQKjOwXTyDgTYWMetPM+PFcALY2756MNfeSWTrjOuxq5wuLxHlq1D4CnPvxonKAOmta0qXk69De4+BgDvqC8HDvXGwcWDXjvGOabAAp2Yqi/gU69AZfPm8J9AzkNEqzwOcTCIFihD89drJM85AT0MsnMMFu2r7xktiOoIh2AEkKVIRKsm10q5sKGPPkfj4gCTGTXUZq2732id8lMWv8a1br9S5pLZhJl2L15S6CMS70AthReUW3dTrqiMLhzxirUyblpBvfe56gUkCAzm8IZKEIVXExXZdv3aWzJ2S7YPLd5+HCWthMw5Ahy8zrtu9vY18ByJ1wDgW8EgOaF0LF5683zfbp/dZ0J7gsP19s64oy9va5fdhqXAUdrENpzIgJKCHEc6TLC5gE+0hLiMGaN++XeHgV4uwgPEpqa+TV3OKr5oS1LrtKbhD/4S4zw61toN3wwVKE6h8/w9mVUSkUmmtL9pl1Nax7/54cI2uhD6Vd8chuOKsxs954isk4Aqt4O24db5EOcYxXz2A6xozv0pNweOj200StsV9xH9Ly68LpbXkskq70XHFrsCDu2Q7KIo=
14 changes: 12 additions & 2 deletions scripts/lib/coverage
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
# Coverage report generator

export URLP_COVERAGE_DATADIR="${URLP_COVERAGE_DATADIR:-$_GO_ROOTDIR/.coverage}"
declare CC_TEST_REPORTER="${_GO_ROOTDIR}/cc-test-reporter"

urlp.init_code_climate() {
if [[ -n "$CC_TEST_REPORTER_ID" && -x "$CC_TEST_REPORTER" ]]; then
if ! "$CC_TEST_REPORTER" before-build; then
echo 'Failed to initiate Code Climate coverage report.' >&2
return 1
fi
fi
}

urlp.generate_coverage_report() {
local report_dir="${_GO_ROOTDIR}/coverage/lcov-report"
Expand Down Expand Up @@ -46,8 +56,8 @@ urlp.send_coverage_report() {
printf 'Coverage report sent to Coveralls: %s\n' \
"https://coveralls.io/github/${github_repo}"

if [[ -n "$CODECLIMATE_REPO_TOKEN" ]]; then
if ! codeclimate-test-reporter < "$lcov_info_path"; then
if [[ -n "$CC_TEST_REPORTER_ID" && -x "$CC_TEST_REPORTER" ]]; then
if ! "$CC_TEST_REPORTER" after-build --exit-code "$TRAVIS_TEST_RESULT"; then
echo 'Failed to send report to Code Climate.' >&2
return 1
fi
Expand Down
3 changes: 3 additions & 0 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ _test() {

@go.log START 'Running all automated tests...'

if [[ -n "$coverage_run" ]] && ! urlp.init_code_climate; then
result='1'
fi
if ! @go.log_command @go test server "${flags[@]}"; then
result='1'
fi
Expand Down

0 comments on commit 0cddc72

Please sign in to comment.