diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..fe5977e --- /dev/null +++ b/.coveragerc @@ -0,0 +1,4 @@ +[run] +branch = True +source = muspinsim +omit = muspinsim/tests/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5066304..4a428da 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -94,17 +94,32 @@ jobs: # Default compiler on macOS doesn't support OpenMP, so force the usage # of homebrew's llvm see # https://github.com/actions/runner-images/blob/main/images/macos/macos-11-Readme.md + # Even when installed, clang++ may not be able to find the OMP library when installed + # To resolve this, export the environment variables suggested by brew to $GITHUB_ENV - name: Add optional environment variables run: | if [ "$RUNNER_OS" == 'macOS' ]; then echo "CC=$(brew --prefix llvm@15)/bin/clang" >> "$GITHUB_ENV" echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> "$GITHUB_ENV" + brew info libomp + echo "LDFLAGS=-L/usr/local/opt/libomp/lib" >> "$GITHUB_ENV" + echo "CPPFLAGS=-I/usr/local/opt/libomp/include" >> "$GITHUB_ENV" fi shell: bash + - name: Install package with -e + env: + MUSPINSIM_WITH_OPENMP: 1 + if: matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' + run: pip install -e . - name: Install package env: MUSPINSIM_WITH_OPENMP: 1 + if: matrix.python-version != '3.10' || matrix.os != 'ubuntu-latest' run: pip install . + - name: Test with pytest - run: pytest --pyargs muspinsim + run: pytest --cov --cov-report xml --pyargs muspinsim + - name: Upload to Codecov + if: matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' + uses: codecov/codecov-action@v3 diff --git a/README.md b/README.md index c5308b9..0ef819a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![Build Status](https://github.com/muon-spectroscopy-computational-project/muspinsim/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/muon-spectroscopy-computational-project/muspinsim/actions/workflows/test.yml) +[![Codecov](https://codecov.io/gh/muon-spectroscopy-computational-project/muspinsim/branch/main/graph/badge.svg)](https://codecov.io/gh/muon-spectroscopy-computational-project/muspinsim) + # muspinsim MuSpinSim is a Python software meant to simulate muon spectroscopy experiments. In particular, it simulates the spin dynamics of a system of a muon plus other spins, namely electrons and atomic nuclei. It can simulate various common experimental setups and account for hyperfine, dipolar and quadrupolar couplings. It is also able to fit its simulations diff --git a/requirements-dev.txt b/requirements-dev.txt index 48ee14c..c4f21bc 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -33,6 +33,7 @@ pycodestyle==2.10.0 pyflakes==3.0.1 pyparsing==3.0.9 pytest==7.2.1 +pytest-cov==4.1.0 python-dateutil==2.8.2 PyYAML==6.0 qutip==4.7.1