Skip to content

Instantly share code, notes, and snippets.

@rlander
Forked from lukaszkorecki/.circle.yml
Created July 4, 2019 03:48
Show Gist options
  • Save rlander/af8dfb632897b00fc5b51e1a856644c5 to your computer and use it in GitHub Desktop.
Save rlander/af8dfb632897b00fc5b51e1a856644c5 to your computer and use it in GitHub Desktop.
How to setup code coverage for Clojure + Cloverage + CircleCI + CodeClimate
version: 2
jobs:
build:
docker:
- image: circleci/clojure:lein-2.7.1
environment:
- CC_TEST_REPORTER_ID=....set in project settings....
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "project.clj" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: 'Install cloverage plugin for Leiningen'
command: |
mkdir -p $HOME/.lein/
echo '{ :user { :plugins [[lein-cloverage "1.0.13" :exclusions [org.clojure/clojure]]] } }' > $HOME/.lein/profiles.clj
- run: lein deps
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "project.clj" }}
- run:
name: Setup Code Climate test-reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- run:
name: 'Run tests'
command: |
./cc-test-reporter before-build
lein cloverage --lcov --no-text --no-html --no-summary -o $PWD
testRes=$?
mkdir -p converage
# fix paths generated by lcov reporter - it doesn't include 'src'
# CC's test reporter expects coverage to be stored in coverage/ dir
sed 's/TF:/TF:src\//' lcov.info > coverage/lcov.info
./cc-test-reporter after-build --coverage-input-type lcov --exit-code $testRes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment