Skip to content

Commit 66205a5

Browse files
authored
CI Updates: Code coverage report, Ubuntu 24.04, PETSc 3.22 (#443)
Summary of changes: - Integrate Codacy reporting - Lock runner versions to `ubuntu-24.04` and `macos-14`. The [`*-latest` runner versions](https://github.com/actions/runner-images#available-images) are moving targets; we wish to avoid surprise failing tests caused by runner upgrades (e.g. see [macOS issue](#421) from last year) . - Upgrade PETSc to [v3.22](https://petsc.org/release/changes/322/).
1 parent 74c1271 commit 66205a5

2 files changed

Lines changed: 88 additions & 25 deletions

File tree

.github/workflows/continuous-integration.yml

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,25 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
os: [ ubuntu-latest ]
18+
os: [ ubuntu-24.04 ]
1919
python-version: [ 3.9, '3.10', '3.11', '3.12' ]
2020
isMerge:
2121
- ${{ github.event_name == 'push' && github.ref == 'refs/heads/devel' }}
2222
exclude:
2323
- { isMerge: false, python-version: '3.10' }
2424
- { isMerge: false, python-version: '3.11' }
2525
include:
26-
- os: macos-latest
26+
- os: macos-14
2727
python-version: '3.10'
28-
- os: macos-latest
28+
- os: macos-14
2929
python-version: '3.11'
3030

3131
name: ${{ matrix.os }} / Python ${{ matrix.python-version }}
3232

33+
env:
34+
PSYDAC_MESH_DIR: ${{ github.workspace }}/mesh
35+
OMP_NUM_THREADS: 2
36+
3337
steps:
3438
- uses: actions/checkout@v4
3539

@@ -44,7 +48,7 @@ jobs:
4448
requirements_extra.txt
4549
4650
- name: Install non-Python dependencies on Ubuntu
47-
if: matrix.os == 'ubuntu-latest'
51+
if: matrix.os == 'ubuntu-24.04'
4852
uses: awalsh128/cache-apt-pkgs-action@latest
4953
with:
5054
packages: gfortran openmpi-bin libopenmpi-dev libhdf5-openmpi-dev
@@ -55,14 +59,14 @@ jobs:
5559
# Workaround is to 'reinstall' openmpi-bin, which doesn't actually perform
5660
# installation (since openmpi-bin already exists), but instead reruns
5761
# `update-alternatives` which fixes the symlinks to mpicc/mpif90.
58-
- name: Set default MPI and HDF5 C compilers on Ubuntu
59-
if: matrix.os == 'ubuntu-latest'
62+
- name: Reconfigure non-Python dependencies on Ubuntu
63+
if: matrix.os == 'ubuntu-24.04'
6064
run: |
6165
sudo apt-get update
62-
sudo apt-get install --reinstall openmpi-bin libhdf5-openmpi-dev
66+
sudo apt-get install --reinstall openmpi-bin libhdf5-openmpi-dev liblapack-dev libblas-dev
6367
6468
- name: Install non-Python dependencies on macOS
65-
if: matrix.os == 'macos-latest'
69+
if: matrix.os == 'macos-14'
6670
run: |
6771
brew install open-mpi
6872
brew install hdf5-mpi
@@ -89,9 +93,9 @@ jobs:
8993
9094
- name: Determine directory of parallel HDF5 library
9195
run: |
92-
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
96+
if [[ "${{ matrix.os }}" == "ubuntu-24.04" ]]; then
9397
HDF5_DIR=$(dpkg -L libhdf5-openmpi-dev | grep libhdf5.so | xargs dirname)
94-
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
98+
elif [[ "${{ matrix.os }}" == "macos-14" ]]; then
9599
HDF5_DIR=$(brew list hdf5-mpi | grep "libhdf5.dylib" | xargs dirname | xargs dirname)
96100
fi
97101
echo $HDF5_DIR
@@ -104,12 +108,12 @@ jobs:
104108
cache-name: cache-PETSc
105109
with:
106110
path: "./petsc"
107-
key: cache-${{ matrix.os }}-${{ matrix.python-version }}
111+
key: petsc-${{ matrix.os }}-${{ matrix.python-version }}
108112

109113
- if: steps.cache-petsc.outputs.cache-hit != 'true'
110114
name: Download a specific release of PETSc
111115
run: |
112-
git clone --depth 1 --branch v3.21.4 https://gitlab.com/petsc/petsc.git
116+
git clone --depth 1 --branch v3.22.2 https://gitlab.com/petsc/petsc.git
113117
114118
- if: steps.cache-petsc.outputs.cache-hit != 'true'
115119
name: Install PETSc with complex support
@@ -157,7 +161,7 @@ jobs:
157161
158162
- name: Install project
159163
run: |
160-
python -m pip install .
164+
python -m pip install .[test]
161165
python -m pip freeze
162166
163167
- name: Test Pyccel optimization flags
@@ -169,35 +173,51 @@ jobs:
169173
mkdir pytest
170174
cp mpi_tester.py pytest
171175
172-
- name: Run single-process tests with Pytest
176+
- name: Run coverage tests on macOS
177+
if: matrix.os == 'macos-14'
178+
working-directory: ./pytest
179+
run: >-
180+
python -m pytest -n auto
181+
--cov psydac
182+
--cov-config $GITHUB_WORKSPACE/pyproject.toml
183+
--cov-report xml
184+
--pyargs psydac -m "not parallel and not petsc"
185+
186+
- name: Run single-process tests with Pytest on Ubuntu
187+
if: matrix.os == 'ubuntu-24.04'
173188
working-directory: ./pytest
174189
run: |
175-
export PSYDAC_MESH_DIR=$GITHUB_WORKSPACE/mesh
176-
export OMP_NUM_THREADS=2
177190
python -m pytest -n auto --pyargs psydac -m "not parallel and not petsc"
178191
192+
- name: Upload coverage report to Codacy
193+
if: matrix.os == 'macos-14'
194+
uses: codacy/codacy-coverage-reporter-action@v1.3.0
195+
with:
196+
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
197+
coverage-reports: ./pytest/coverage.xml
198+
199+
- name: Print detailed coverage results on macOS
200+
if: matrix.os == 'macos-14'
201+
working-directory: ./pytest
202+
run: |
203+
coverage report --ignore-errors --show-missing --sort=cover
204+
179205
- name: Run MPI tests with Pytest
180206
working-directory: ./pytest
181207
run: |
182-
export PSYDAC_MESH_DIR=$GITHUB_WORKSPACE/mesh
183-
export OMP_NUM_THREADS=2
184208
python mpi_tester.py --mpirun="mpiexec -n 4 ${MPI_OPTS}" --pyargs psydac -m "parallel and not petsc"
185209
186210
- name: Run single-process PETSc tests with Pytest
187211
working-directory: ./pytest
188212
run: |
189-
export PSYDAC_MESH_DIR=$GITHUB_WORKSPACE/mesh
190-
export OMP_NUM_THREADS=2
191213
python -m pytest -n auto --pyargs psydac -m "not parallel and petsc"
192214
193215
- name: Run MPI PETSc tests with Pytest
194216
working-directory: ./pytest
195217
run: |
196-
export PSYDAC_MESH_DIR=$GITHUB_WORKSPACE/mesh
197-
export OMP_NUM_THREADS=2
198218
python mpi_tester.py --mpirun="mpiexec -n 4 ${MPI_OPTS}" --pyargs psydac -m "parallel and petsc"
199219
200220
- name: Remove test directory
201-
if: ${{ always() }}
221+
if: always()
202222
run: |
203223
rm -rf pytest

pyproject.toml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ dependencies = [
2626
'scipy >= 1.12',
2727
'sympy >= 1.5',
2828
'matplotlib',
29-
'pytest >= 4.5',
30-
'pytest-xdist >= 1.16',
3129
'pyyaml >= 5.1',
3230
'packaging',
3331
'pyevtk',
@@ -53,6 +51,13 @@ dependencies = [
5351
'igakit @ https://github.com/dalcinl/igakit/archive/refs/heads/master.zip'
5452
]
5553

54+
[project.optional-dependencies]
55+
test = [
56+
"pytest-cov >= 5.0.0",
57+
'pytest >= 4.5',
58+
'pytest-xdist >= 1.16',
59+
]
60+
5661
[project.urls]
5762
Homepage = "https://github.com/pyccel/psydac"
5863
Documentation = "https://pyccel.github.io/psydac"
@@ -68,3 +73,41 @@ namespaces = false
6873

6974
[tool.setuptools.package-data]
7075
"*" = ["*.txt"]
76+
77+
[tool.coverage.run]
78+
branch = true
79+
omit = [
80+
# Exclude pyccelised kernels
81+
"*/__psydac__/*",
82+
83+
# Examples don't need to be covered
84+
"*/examples/*",
85+
86+
# Unit tests shouldn't be included
87+
"*/tests/*",
88+
]
89+
90+
[tool.coverage.report]
91+
# Regexes for lines to exclude from consideration
92+
exclude_also = [
93+
# Don't complain about missing debug-only code:
94+
"def __repr__",
95+
"if self\\.debug",
96+
97+
# Don't complain if tests don't hit defensive assertion code:
98+
"raise AssertionError",
99+
"raise NotImplementedError",
100+
101+
# Don't complain if non-runnable code isn't run:
102+
"if False:",
103+
"if __name__ == .__main__.:",
104+
105+
# Don't complain about abstract methods, they aren't run:
106+
"@(abc\\.)?abstractmethod",
107+
]
108+
109+
# Ignore source code that can’t be found, emitting a warning instead of an exception.
110+
ignore_errors = true
111+
112+
[tool.coverage.html]
113+
directory = "coverage_html_report"

0 commit comments

Comments
 (0)