Skip to content

Instantly share code, notes, and snippets.

@lukaszkorecki
Last active August 10, 2019 10:57
Show Gist options
  • Save lukaszkorecki/60093e57cbb4b178547e4a7ff23c703d to your computer and use it in GitHub Desktop.
Save lukaszkorecki/60093e57cbb4b178547e4a7ff23c703d 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.1.1" :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_FAST_TRAMPOLINE=1 lein trampoline cloverage --lcov --no-text --no-html --no-summary -o $PWD
testRes=$?
mkdir -p coverage
mv 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