-
Notifications
You must be signed in to change notification settings - Fork 18
203 lines (176 loc) · 7.08 KB
/
continuous-integration.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# This workflow will install Python dependencies and run tests with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Run tests
on:
push:
branches: [ devel ]
pull_request:
branches: [ devel ]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
python-version: [ 3.9, '3.10', '3.11', '3.12' ]
isMerge:
- ${{ github.event_name == 'push' && github.ref == 'refs/heads/devel' }}
exclude:
- { isMerge: false, python-version: '3.10' }
- { isMerge: false, python-version: '3.11' }
include:
- os: macos-latest
python-version: '3.10'
- os: macos-latest
python-version: '3.11'
name: ${{ matrix.os }} / Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
pyproject.toml
requirements.txt
requirements_extra.txt
- name: Install non-Python dependencies on Ubuntu
if: matrix.os == 'ubuntu-latest'
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: gfortran openmpi-bin libopenmpi-dev libhdf5-openmpi-dev
version: 1.0
execute_install_scripts: true
# When loading cached apt packages, the default MPI compiler isn't set.
# Workaround is to 'reinstall' openmpi-bin, which doesn't actually perform
# installation (since openmpi-bin already exists), but instead reruns
# `update-alternatives` which fixes the symlinks to mpicc/mpif90.
- name: Set default MPI and HDF5 C compilers on Ubuntu
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install --reinstall openmpi-bin libhdf5-openmpi-dev
- name: Install non-Python dependencies on macOS
if: matrix.os == 'macos-latest'
run: |
brew install open-mpi
brew install hdf5-mpi
brew install libomp
GFORTRAN_HOME=$(which gfortran || true)
echo "GFORTRAN_HOME : $GFORTRAN_HOME"
if [[ ! -f "$GFORTRAN_HOME" ]]; then
gfort=$(find ${PATH//:/\/ } -name 'gfortran-*' -exec basename {} \; | sort | tail -n 1 || true)
echo "Found $gfort"
gfort_path=$(which ${gfort})
folder=$(dirname ${gfort_path})
ln -s ${gfort_path} ${folder}/gfortran
fi
echo "MPI_OPTS=--oversubscribe" >> $GITHUB_ENV
- name: Print information on MPI and HDF5 libraries
run: |
ompi_info
h5pcc -showconfig -echo || true
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
- name: Determine directory of parallel HDF5 library
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
HDF5_DIR=$(dpkg -L libhdf5-openmpi-dev | grep libhdf5.so | xargs dirname)
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
HDF5_DIR=$(brew list hdf5-mpi | grep "libhdf5.dylib" | xargs dirname | xargs dirname)
fi
echo $HDF5_DIR
echo "HDF5_DIR=$HDF5_DIR" >> $GITHUB_ENV
- name: Cache PETSc
uses: actions/cache@v4
id: cache-petsc
env:
cache-name: cache-PETSc
with:
path: "./petsc"
key: cache-${{ matrix.os }}-${{ matrix.python-version }}
- if: steps.cache-petsc.outputs.cache-hit != 'true'
name: Download a specific release of PETSc
run: |
git clone --depth 1 --branch v3.21.4 https://gitlab.com/petsc/petsc.git
- if: steps.cache-petsc.outputs.cache-hit != 'true'
name: Install PETSc with complex support
working-directory: ./petsc
run: |
export PETSC_DIR=$(pwd)
export PETSC_ARCH=petsc-cmplx
./configure --with-scalar-type=complex --with-fortran-bindings=0 --have-numpy=1
make all
echo "PETSC_DIR=$PETSC_DIR" > petsc.env
echo "PETSC_ARCH=$PETSC_ARCH" >> petsc.env
# This step is not really necessary and could be combined with PETSc install
# step; however it's good to verify if the cached PETSc installation really works!
- name: Test PETSc installation
working-directory: ./petsc
run: |
source petsc.env
make check
echo "PETSC_DIR=$PETSC_DIR" >> $GITHUB_ENV
echo "PETSC_ARCH=$PETSC_ARCH" >> $GITHUB_ENV
- name: Install petsc4py
working-directory: ./petsc
run: |
python -m pip install wheel Cython numpy
python -m pip install src/binding/petsc4py
- name: Install Python dependencies
run: |
export CC="mpicc"
export HDF5_MPI="ON"
python -m pip install -r requirements.txt
python -m pip install -r requirements_extra.txt --no-build-isolation
python -m pip list
- name: Check parallel h5py installation
run: |
python -c "
from mpi4py import MPI
import h5py
# This particular instantiation of h5py.File will fail if parallel h5py isn't installed
f = h5py.File('parallel_test.hdf5', 'w', driver='mpio', comm=MPI.COMM_WORLD)
print(f)"
- name: Install project
run: |
python -m pip install .
python -m pip freeze
- name: Test Pyccel optimization flags
run: |
pytest --pyargs psydac -m pyccel --capture=no
- name: Initialize test directory
run: |
mkdir pytest
cp mpi_tester.py pytest
#- name: Run single-process tests with Pytest
# working-directory: ./pytest
# run: |
# export PSYDAC_MESH_DIR=$GITHUB_WORKSPACE/mesh
# export OMP_NUM_THREADS=2
# python -m pytest -n auto --pyargs psydac -m "not parallel and not petsc"
- name: Run MPI tests with Pytest
working-directory: ./pytest
run: |
export PSYDAC_MESH_DIR=$GITHUB_WORKSPACE/mesh
export OMP_NUM_THREADS=2
python mpi_tester.py --mpirun="mpiexec -n 4 ${MPI_OPTS}" --pyargs psydac -m "parallel and not petsc"
- name: Run single-process PETSc tests with Pytest
working-directory: ./pytest
run: |
export PSYDAC_MESH_DIR=$GITHUB_WORKSPACE/mesh
export OMP_NUM_THREADS=2
python -m pytest -n auto --pyargs psydac -m "not parallel and petsc"
- name: Run MPI PETSc tests with Pytest
working-directory: ./pytest
run: |
export PSYDAC_MESH_DIR=$GITHUB_WORKSPACE/mesh
export OMP_NUM_THREADS=2
python mpi_tester.py --mpirun="mpiexec -n 4 ${MPI_OPTS}" --pyargs psydac -m "parallel and petsc"
- name: Remove test directory
if: ${{ always() }}
run: |
rm -rf pytest