.circleci/config.yml
# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2
defaults: &defaults
working_directory: ~/nomenclateapi
default-run: &default-run
steps:
- checkout
- attach_workspace:
at: ~/tmp
- restore-cache: &d2-restore-cache
keys:
- a1-dependencies-{{ checksum "requirements.txt" }}
- a1-dependencies-
- run: &d-install-deps
name: install deps
command: make install-deps
- save-cache: &d2-save-cache
paths:
- ~/nvenv/
key: a1-dependencies-{{ checksum "requirements.txt" }}
- run: &run-tests
name: run tests
command: make test-unit
- run:
name: convert coverage
command: |
cp nose2-junit.xml ~/tmp/test-results/noselog.${PYTHON_VERSION}.xml
cp coverage.xml ~/tmp/test-results/coverage.${PYTHON_VERSION}.xml
~/tmp/cc-test-reporter format-coverage -t coverage.py -o ~/tmp/test-results/coverage.${PYTHON_VERSION}.json ~/tmp/test-results/coverage.${PYTHON_VERSION}.xml
- store_test_results: &store-results
path: ~/tmp/test-results
- persist_to_workspace:
root: ~/tmp
paths:
- test-results/noselog.*.xml
- test-results/coverage.*.json
jobs:
build:
docker:
- image: circleci/python:3.6
<<: *defaults
steps:
- run:
name: Download cc-test-reporter
command: |
mkdir -p ~/tmp/test-results
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ~/tmp/cc-test-reporter
chmod +x ~/tmp/cc-test-reporter
- persist_to_workspace:
root: ~/tmp
paths:
- cc-test-reporter
- test-results
python27:
docker:
- image: circleci/python:2.7
<<: *defaults
<<: *default-run
python35:
docker:
- image: circleci/python:3.5
<<: *defaults
<<: *default-run
python36:
docker:
- image: circleci/python:3.6
<<: *defaults
<<: *default-run
python37:
docker:
- image: circleci/python:3.7
<<: *defaults
<<: *default-run
uploadcoverage:
docker:
- image: circleci/python:latest
<<: *defaults
steps:
- attach_workspace:
at: ~/tmp
- run:
name: Upload coverage results to Code Climate
command: |
~/tmp/cc-test-reporter sum-coverage ~/tmp/test-results/coverage.*.json -p 4 -o ~/tmp/codeclimate.json
~/tmp/cc-test-reporter upload-coverage -i ~/tmp/codeclimate.json
workflows:
version: 2
test_python_versions:
jobs:
- build
- python27:
requires:
- build
- python35:
requires:
- build
- python36:
requires:
- build
- python37:
requires:
- build
- uploadcoverage:
requires:
- python27
- python35
- python36
- python37