diff --git a/.github/workflows/testsuite.yml b/.github/workflows/testsuite.yml index ecc3bd5..b1e5669 100644 --- a/.github/workflows/testsuite.yml +++ b/.github/workflows/testsuite.yml @@ -1,4 +1,4 @@ -name: run tests +name: testsuite on: push: @@ -34,8 +34,9 @@ jobs: module restore pymbe source venv/bin/activate make pylint - make tests + make unit_tests COVERAGE=1 make docs + make coverage_xml shell: bash - name: Upload artifact uses: actions/upload-artifact@v4 @@ -44,3 +45,14 @@ jobs: name: documentation retention-days: 2 if-no-files-found: error + - name: Upload coverage to Codecov + if: ${{ github.repository == 'pyMBE-dev/pyMBE' }} + uses: codecov/codecov-action@v4 + with: + file: "./coverage.xml" + disable_search: true + env_vars: OS,PYTHON + fail_ci_if_error: false + flags: unittests + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true diff --git a/Makefile b/Makefile index e041649..87f6939 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,17 @@ .PHONY: visual .PHONY: clean +# whether to run unit tests with code coverage +COVERAGE = 0 + +# output directory for the code coverage HTML files +COVERAGE_HTML = coverage + +# Python executable or launcher, possibly with command line arguments PYTHON = python3 +ifeq ($(COVERAGE),1) +PYTHON := ${PYTHON} -m coverage run --parallel-mode --source=$(CURDIR) +endif docs: mkdir -p ./documentation @@ -30,6 +40,15 @@ functional_tests: tests: unit_tests functional_tests +coverage_xml: + ${PYTHON} -m coverage combine . + ${PYTHON} -m coverage report + ${PYTHON} -m coverage xml + +coverage_html: + ${PYTHON} -m coverage combine . + ${PYTHON} -m coverage html --directory="${COVERAGE_HTML}" + sample: ${PYTHON} samples/peptide.py diff --git a/README.md b/README.md index 39ea0dc..45c9656 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # pyMBE: the Python-based Molecule Builder for ESPResSo +![GitHub Actions](https://github.com/pyMBE-dev/pyMBE/actions/workflows/testsuite.yml/badge.svg) +[![codecov](https://codecov.io/gh/pyMBE-dev/pyMBE/branch/codecov/graph/badge.svg)](https://codecov.io/gh/pyMBE-dev/pyMBE) + pyMBE provides tools to facilitate building up molecules with complex architectures in the Molecular Dynamics software [ESPResSo](https://espressomd.org/wordpress/). Some examples of molecules that can be set up with pyMBE are polyelectrolytes, peptides and proteins. pyMBE bookkeeps all the information about the molecule topology, permitting to link each particle to its corresponding residue and molecule. pyMBE uses the [Pint](https://pint.readthedocs.io/en/stable/) library to enable input parameters in any arbitrary unit system, which is later transformed in the reduced unit system used in ESPResSo. ## Dependencies