diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a0adf768..8cf7d526 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,11 +92,57 @@ jobs: name: "python bindings" steps: - uses: actions/checkout@v3 + - uses: mozilla-actions/sccache-action@v0.0.3 - name: Install stable toolchain uses: dtolnay/rust-toolchain@stable + - uses: actions/setup-python@v4 with: - components: rustfmt, clippy + python-version: '3.11' + cache: 'pip' + - name: Build pyo3 bindings + run: | + pip install -r requirements.txt + cd pyrs + maturin build + pip install ../target/wheels/*.whl + - name: Test pyo3 bindings + run: | + cd pyrs + pytest + + coverage: + if: github.event_name != 'merge_group' + needs: [tests, check] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - uses: mozilla-actions/sccache-action@v0.0.3 + - uses: dtolnay/rust-toolchain@nightly + with: + components: llvm-tools-preview + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: Run tests with coverage instrumentation + run: | + cargo llvm-cov clean --workspace + cargo llvm-cov --doctests --all-features + cargo llvm-cov report --codecov --output-path coverage.json + - name: Upload rust coverage to codecov.io + uses: codecov/codecov-action@v3 + with: + files: coverage.json + name: rust + token: ${{ secrets.CODECOV_TOKEN }} + + py-coverage: + if: github.event_name != 'merge_group' + needs: [py-tests, check] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: mozilla-actions/sccache-action@v0.0.3 + - name: Install stable toolchain + uses: dtolnay/rust-toolchain@stable - uses: actions/setup-python@v4 with: python-version: '3.11' @@ -104,10 +150,17 @@ jobs: - name: Build pyo3 bindings run: | pip install -r requirements.txt + pip install pytest-cov cd pyrs maturin build pip install ../target/wheels/*.whl - - name: Test pyo3 bindings + - name: Run python tests with coverage instrumentation run: | cd pyrs - pytest \ No newline at end of file + pytest --cov=./ --cov-report=xml + - name: Upload python coverage to codecov.io + uses: codecov/codecov-action@v3 + with: + files: pyrs/coverage.xml + name: python + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index 02cc737e..daf3c96b 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,13 @@ [![build_status][]](https://github.com/CQCL-DEV/tket2/actions) ![msrv][] +[![codecov][]](https://codecov.io/gh/CQCL/tket2) Version 2 of the TKET compiler. [build_status]: https://github.com/CQCL-DEV/hugr/workflows/Continuous%20integration/badge.svg?branch=main [msrv]: https://img.shields.io/badge/rust-1.70.0%2B-blue.svg + [codecov]: https://img.shields.io/codecov/c/gh/CQCL/tket2?logo=codecov ## Features