|
| 1 | +name: CodeCoverage |
| 2 | + |
| 3 | +on: [push, pull_request, workflow_dispatch] |
| 4 | + |
| 5 | +jobs: |
| 6 | + run: |
| 7 | + runs-on: [ubuntu-24.04] |
| 8 | + |
| 9 | + strategy: |
| 10 | + matrix: |
| 11 | + python-versions: ['3.12'] |
| 12 | + |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + - name: Set up Python ${{ matrix.python-versions }} |
| 16 | + uses: actions/setup-python@v4 |
| 17 | + with: |
| 18 | + python-version: ${{ matrix.python-versions }} |
| 19 | + - name: setup |
| 20 | + run: | |
| 21 | + sudo apt update && sudo apt install --yes \ |
| 22 | + libcdd-dev \ |
| 23 | + libgmp-dev \ |
| 24 | + numdiff \ |
| 25 | + texlive \ |
| 26 | + texlive-latex-extra |
| 27 | + python -m pip install --upgrade pip |
| 28 | + pip install pycddlib autograd # this is optional |
| 29 | + pip install coverage |
| 30 | + python --version |
| 31 | + - name: Generate Report |
| 32 | + run: | |
| 33 | + python -m pip install git+https://github.com/geodynamics/burnman@main |
| 34 | + mkdir main_tests |
| 35 | + cd main_tests |
| 36 | + git clone https://github.com/geodynamics/burnman |
| 37 | + cp burnman/tests/*.py . |
| 38 | + rm -fr burnman |
| 39 | + cd ../ |
| 40 | + coverage run -m unittest discover ./main_tests |
| 41 | + coverage report > main_coverage.tmp |
| 42 | + main_coverage=$(coverage report --precision=7 --format=total) |
| 43 | + rm -fr main_tests |
| 44 | + python -m pip install -q -e .[dev] |
| 45 | + coverage run -m unittest discover ./tests |
| 46 | + coverage report > new_coverage.tmp |
| 47 | + new_coverage=$(coverage report --precision=7 --format=total) |
| 48 | + echo "Main coverage: $main_coverage" |
| 49 | + echo "New coverage: $new_coverage" |
| 50 | + if (( $(echo "$new_coverage < $main_coverage" | bc -l) )); then |
| 51 | + diff main_coverage.tmp new_coverage.tmp |
| 52 | + echo "Coverage ($new_coverage %) decreased relative to main ($main_coverage %)" |
| 53 | + exit 1 |
| 54 | + fi |
0 commit comments