Skip to content

Commit 21d61fd

Browse files
authored
Split testing workflows (#56)
* split jobs into separate workflows * removed disabled workflow * renamed workflow * try using an action for installing prerequisites * move actions into correct place * forgot to checkout repo * add indent * add default run shell to action * add shell to each run in action * add concurrency settings to tests * run tests only on pull-request into devel-tiny * install Struphy from Github in test
1 parent ca70e1c commit 21d61fd

6 files changed

Lines changed: 409 additions & 607 deletions

File tree

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Install prerequisites
2+
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Set up Python ${{ matrix.python-version }}
7+
uses: actions/setup-python@v5
8+
with:
9+
python-version: ${{ matrix.python-version }}
10+
cache: 'pip'
11+
cache-dependency-path: |
12+
pyproject.toml
13+
requirements.txt
14+
15+
- name: Install non-Python dependencies on Ubuntu
16+
if: matrix.os == 'ubuntu-latest'
17+
uses: awalsh128/cache-apt-pkgs-action@latest
18+
with:
19+
packages: gfortran openmpi-bin libopenmpi-dev libhdf5-openmpi-dev g++ liblapack3 cmake cmake-curses-gui zlib1g-dev libnetcdf-dev libnetcdff-dev
20+
version: 1.0
21+
execute_install_scripts: true
22+
23+
# When loading cached apt packages, the default MPI compiler isn't set.
24+
# Workaround is to 'reinstall' openmpi-bin, which doesn't actually perform
25+
# installation (since openmpi-bin already exists), but instead reruns
26+
# `update-alternatives` which fixes the symlinks to mpicc/mpif90.
27+
- name: Reconfigure non-Python dependencies on Ubuntu
28+
if: matrix.os == 'ubuntu-latest'
29+
shell: bash
30+
run: |
31+
sudo apt-get update
32+
sudo apt-get install --reinstall openmpi-bin libhdf5-openmpi-dev liblapack-dev libblas-dev
33+
34+
- name: Install non-Python dependencies on macOS
35+
if: matrix.os == 'macos-14'
36+
shell: bash
37+
run: |
38+
brew install make
39+
brew install open-mpi
40+
brew install hdf5-mpi
41+
brew install libomp
42+
brew update
43+
brew install python3
44+
brew install gcc
45+
brew install openblas
46+
brew install lapack
47+
brew install git
48+
brew install pandoc
49+
brew install cmake
50+
brew install netcdf-fortran
51+
brew install pkgconf
52+
GFORTRAN_HOME=$(which gfortran || true)
53+
echo "GFORTRAN_HOME : $GFORTRAN_HOME"
54+
if [[ ! -f "$GFORTRAN_HOME" ]]; then
55+
gfort=$(find ${PATH//:/\/ } -name 'gfortran-*' -exec basename {} \; | sort | tail -n 1 || true)
56+
echo "Found $gfort"
57+
gfort_path=$(which ${gfort})
58+
folder=$(dirname ${gfort_path})
59+
ln -s ${gfort_path} ${folder}/gfortran
60+
fi
61+
echo "MPI_OPTS=--oversubscribe" >> $GITHUB_ENV
62+
echo "/opt/homebrew/opt/make/libexec/gnubin" >> $GITHUB_PATH
63+
64+
- name: Print information on MPI and HDF5 libraries
65+
shell: bash
66+
run: |
67+
ompi_info
68+
h5pcc -showconfig -echo || true
69+
70+
- name: Upgrade pip
71+
shell: bash
72+
run: |
73+
python -m pip install --upgrade pip
74+
75+
- name: Determine directory of parallel HDF5 library
76+
shell: bash
77+
run: |
78+
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
79+
HDF5_DIR=$(dpkg -L libhdf5-openmpi-dev | grep libhdf5.so | xargs dirname)
80+
elif [[ "${{ matrix.os }}" == "macos-14" ]]; then
81+
HDF5_DIR=$(brew list hdf5-mpi | grep "libhdf5.dylib" | xargs dirname | xargs dirname)
82+
fi
83+
echo $HDF5_DIR
84+
echo "HDF5_DIR=$HDF5_DIR" >> $GITHUB_ENV
85+
86+
- name: Cache PETSc
87+
uses: actions/cache@v4
88+
id: cache-petsc
89+
env:
90+
cache-name: cache-PETSc
91+
with:
92+
path: "./petsc"
93+
key: petsc-${{ matrix.os }}-${{ matrix.python-version }}
94+
95+
- if: steps.cache-petsc.outputs.cache-hit != 'true'
96+
name: Download a specific release of PETSc
97+
shell: bash
98+
run: |
99+
git clone --depth 1 --branch v3.23.3 https://gitlab.com/petsc/petsc.git
100+
101+
- if: steps.cache-petsc.outputs.cache-hit != 'true'
102+
name: Install PETSc with complex support
103+
working-directory: ./petsc
104+
shell: bash
105+
run: |
106+
export PETSC_DIR=$(pwd)
107+
export PETSC_ARCH=petsc-cmplx
108+
./configure --with-scalar-type=complex --with-fortran-bindings=0 --have-numpy=1 --download-fblaslapack=1
109+
make all
110+
echo "PETSC_DIR=$PETSC_DIR" > petsc.env
111+
echo "PETSC_ARCH=$PETSC_ARCH" >> petsc.env
112+
113+
# This step is not really necessary and could be combined with PETSc install
114+
# step; however it's good to verify if the cached PETSc installation really works!
115+
- name: Test PETSc installation
116+
working-directory: ./petsc
117+
shell: bash
118+
run: |
119+
source petsc.env
120+
make check
121+
echo "PETSC_DIR=$PETSC_DIR" >> $GITHUB_ENV
122+
echo "PETSC_ARCH=$PETSC_ARCH" >> $GITHUB_ENV
123+
124+
- name: Install petsc4py
125+
working-directory: ./petsc
126+
shell: bash
127+
run: |
128+
python -m pip install wheel Cython numpy
129+
python -m pip install src/binding/petsc4py
130+
131+
# - name: Check parallel h5py installation
132+
# run: |
133+
# python -c "
134+
# from mpi4py import MPI
135+
# import h5py
136+
# # This particular instantiation of h5py.File will fail if parallel h5py isn't installed
137+
# f = h5py.File('parallel_test.hdf5', 'w', driver='mpio', comm=MPI.COMM_WORLD)
138+
# print(f)"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Compile psydac w. pyccel devel
2+
3+
on:
4+
pull_request:
5+
branches: [devel-tiny]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
compile-with-pyccel-devel:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ ubuntu-latest ]
18+
# TODO: Make sure that struphy works with python > 3.11, keep the lower bound to 3.10
19+
python-version: [ '3.10', '3.12', '3.13' ]
20+
compile_language: ['c', 'fortran']
21+
isMerge:
22+
- ${{ github.event_name == 'push' && github.ref == 'refs/heads/devel' }}
23+
# exclude:
24+
# - { isMerge: false, python-version: '3.10' }
25+
# - { isMerge: false, python-version: '3.11' }
26+
# include:
27+
# - os: macos-14
28+
# python-version: '3.10'
29+
# - os: macos-14
30+
# python-version: '3.13'
31+
32+
name: Compile psydac w. pyccel devel on ${{ matrix.os }} / Python ${{ matrix.python-version }} / ${{ matrix.compile_language }}
33+
34+
steps:
35+
- name: Checkout repo
36+
uses: actions/checkout@v4
37+
38+
- name: Install prerequisites
39+
uses: ./.github/actions/install/psydac-req
40+
41+
- name: Install project
42+
run: |
43+
python -m pip install ".[test]" --no-cache-dir
44+
python -m pip freeze
45+
46+
- name: Set up environment variables
47+
run: |
48+
echo "PSYDAC_DIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV
49+
echo "PYCCEL_DIR=$GITHUB_WORKSPACE/pyccel" >> $GITHUB_ENV
50+
51+
- name: Clone pyccel from Github (devel branch)
52+
run: |
53+
git clone --recurse-submodules https://github.com/pyccel/pyccel.git $PYCCEL_DIR
54+
55+
- name: Install pyccel
56+
working-directory: ${{ env.PYCCEL_DIR }}
57+
run: |
58+
echo "Pyccel location for this branch"
59+
pip show pyccel
60+
pip uninstall pyccel -y
61+
python -m pip install ".[test]" --no-cache-dir
62+
echo "Pyccel location after reinstalling"
63+
pip show pyccel
64+
65+
- name: Compile psydac kernels
66+
run: |
67+
psydac-accelerate --language ${{ matrix.compile_language }}

.github/workflows/documentation.yml.disabled

Lines changed: 0 additions & 65 deletions
This file was deleted.

.github/workflows/test-psydac.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Test psydac
2+
3+
on:
4+
pull_request:
5+
branches: [devel-tiny]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
test_psydac:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ ubuntu-latest ]
18+
# TODO: Make sure that struphy works with python > 3.11, keep the lower bound to 3.10
19+
python-version: [ '3.10', '3.12', '3.13' ]
20+
compile_language: ['c', 'fortran']
21+
isMerge:
22+
- ${{ github.event_name == 'push' && github.ref == 'refs/heads/devel' }}
23+
# exclude:
24+
# - { isMerge: false, python-version: '3.10' }
25+
# - { isMerge: false, python-version: '3.11' }
26+
# include:
27+
# - os: macos-14
28+
# python-version: '3.10'
29+
# - os: macos-14
30+
# python-version: '3.13'
31+
32+
name: Test Psydac on ${{ matrix.os }} / Python ${{ matrix.python-version }} / ${{ matrix.compile_language }}
33+
34+
steps:
35+
- name: Checkout repo
36+
uses: actions/checkout@v4
37+
38+
- name: Install prerequisites
39+
uses: ./.github/actions/install/psydac-req
40+
41+
- name: Install project without mpi
42+
run: |
43+
python -m pip install ".[test]" --no-cache-dir
44+
python -m pip freeze
45+
46+
- name: Compile psydac kernels
47+
run: |
48+
psydac-accelerate --language ${{ matrix.compile_language }}
49+
50+
# - name: Test Pyccel optimization flags
51+
# run: |
52+
# pytest --pyargs psydac -m pyccel --capture=no
53+
54+
- name: Initialize test directory
55+
run: |
56+
mkdir pytest
57+
cp mpi_tester.py pytest
58+
59+
- name: Run coverage tests on macOS
60+
if: matrix.os == 'macos-14'
61+
working-directory: ./pytest
62+
run: >-
63+
python -m pytest -n auto
64+
--cov psydac
65+
--cov-config $GITHUB_WORKSPACE/pyproject.toml
66+
--cov-report xml
67+
--pyargs psydac -m "not parallel and not petsc"
68+
69+
- name: Run single-process tests with Pytest on Ubuntu
70+
if: matrix.os == 'ubuntu-latest'
71+
working-directory: ./pytest
72+
run: |
73+
python -m pytest -n auto --pyargs psydac -m "not parallel and not petsc"
74+
75+
- name: Run single-process PETSc tests with Pytest
76+
working-directory: ./pytest
77+
run: |
78+
python -m pytest -n auto --pyargs psydac -m "not parallel and petsc"
79+
80+
- name: Install project with mpi
81+
run: |
82+
python -m pip install ".[mpi]"
83+
python -m pip freeze
84+
85+
- name: Run MPI tests with Pytest
86+
working-directory: ./pytest
87+
run: |
88+
python mpi_tester.py --mpirun="mpiexec -n 4 ${MPI_OPTS}" --pyargs psydac -m "parallel and not petsc"
89+
90+
- name: Run MPI PETSc tests with Pytest
91+
working-directory: ./pytest
92+
run: |
93+
python mpi_tester.py --mpirun="mpiexec -n 4 ${MPI_OPTS}" --pyargs psydac -m "parallel and petsc"
94+
95+
- name: Remove test directory
96+
if: always()
97+
run: |
98+
rm -rf pytest
99+

0 commit comments

Comments
 (0)