Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Codecov for testing code coverage in the CI #301

Merged
merged 9 commits into from
Aug 14, 2020
Merged
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
omit =
*/tests/*
2 changes: 1 addition & 1 deletion .github/workflows/ci-master.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build (Master Only)
name: build (master only)

on:
push:
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: build

on:
pull_request:
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Lint with flake8
run: make check-style

# runs all the unit tests (including pyQuil/Qiskit) on ubuntu and py36/37/38
# runs all the unit tests (on Ubuntu, py36/37/38) and measures code coverage
test:
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -83,5 +83,11 @@ jobs:
run: |
docker run --rm -idt -p 5000:5000 rigetti/qvm -S
docker run --rm -idt -p 5555:5555 rigetti/quilc -R
- name: Run all the unit tests via pytest
- name: Run all the unit tests & generate coverage report with pytest
run: make test-all
- name: Submit coverage report to Codecov
# only submit to Codecov once
if: ${{ matrix.python-version == 3.8 }}
uses: codecov/codecov-action@v1.0.12
with:
fail_ci_if_error: true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.vscode
.python-version
.idea/
.coverage*
.coverage
*.dat
*.ipynp
*.ipynb_checkpoints
Expand All @@ -12,3 +12,4 @@ docs/build/
mitiq.egg-info/
dist/
build/
coverage.xml
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ requirements: requirements.txt

.PHONY: test
test:
pytest -v --cov=mitiq mitiq/tests mitiq/benchmarks/tests
pytest -v --cov=mitiq --cov-report=term --cov-report=xml mitiq/tests mitiq/benchmarks/tests

.PHONY: test-pyquil
test-pyquil:
pytest -v --cov=mitiq mitiq/mitiq_pyquil/tests
pytest -v --cov=mitiq --cov-report=term --cov-report=xml mitiq/mitiq_pyquil/tests

.PHONY: test-qiskit
test-qiskit:
pytest -v --cov=mitiq mitiq/mitiq_qiskit/tests
pytest -v --cov=mitiq --cov-report=term --cov-report=xml mitiq/mitiq_qiskit/tests

.PHONY: test-all
test-all:
pytest --cov=mitiq
pytest --cov=mitiq --cov-report=term --cov-report=xml
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Python Build](https://github.com/unitaryfund/mitiq/workflows/Python%20Build/badge.svg?branch=master)
[![build](https://github.com/unitaryfund/mitiq/workflows/build/badge.svg)](https://github.com/unitaryfund/mitiq/actions)
[![codecov](https://codecov.io/gh/unitaryfund/mitiq/branch/master/graph/badge.svg)](https://codecov.io/gh/unitaryfund/mitiq)
[![PyPI version](https://badge.fury.io/py/mitiq.svg)](https://badge.fury.io/py/mitiq)
[![Unitary Fund](https://img.shields.io/badge/Supported%20By-UNITARY%20FUND-brightgreen.svg?style=for-the-badge)](http://unitary.fund)

Expand Down