Merge pull request #624 from bobmyhill/improve_calibrant_coverage #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CodeCoverage | |
| on: [push, pull_request, workflow_dispatch] | |
| jobs: | |
| run: | |
| runs-on: [ubuntu-24.04] | |
| strategy: | |
| matrix: | |
| python-versions: ['3.12'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-versions }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-versions }} | |
| - name: setup | |
| run: | | |
| sudo apt update && sudo apt install --yes \ | |
| libcdd-dev \ | |
| libgmp-dev \ | |
| numdiff \ | |
| texlive \ | |
| texlive-latex-extra | |
| python -m pip install --upgrade pip | |
| pip install pycddlib autograd # this is optional | |
| pip install coverage | |
| python --version | |
| - name: Generate Report | |
| run: | | |
| python -m pip install git+https://github.com/geodynamics/burnman@main | |
| mkdir main_tests | |
| cd main_tests | |
| git clone https://github.com/geodynamics/burnman | |
| cp burnman/tests/*.py . | |
| rm -fr burnman | |
| cd ../ | |
| coverage run -m unittest discover ./main_tests | |
| coverage report > main_coverage.tmp | |
| main_coverage=$(coverage report --precision=7 --format=total) | |
| rm -fr main_tests | |
| python -m pip install -q -e .[dev] | |
| coverage run -m unittest discover ./tests | |
| coverage report > new_coverage.tmp | |
| new_coverage=$(coverage report --precision=7 --format=total) | |
| echo "Main coverage: $main_coverage" | |
| echo "New coverage: $new_coverage" | |
| if (( $(echo "$new_coverage < $main_coverage" | bc -l) )); then | |
| diff main_coverage.tmp new_coverage.tmp | |
| echo "Coverage ($new_coverage %) decreased relative to main ($main_coverage %)" | |
| exit 1 | |
| fi |