-
-
Notifications
You must be signed in to change notification settings - Fork 4
292 lines (289 loc) · 13.8 KB
/
Copy pathci.yml
File metadata and controls
292 lines (289 loc) · 13.8 KB
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
name: CI
on:
push:
branches:
- "**"
pull_request:
branches:
- main
schedule:
- cron: "0 5 * * *"
workflow_dispatch:
workflow_call:
inputs:
ref:
description: "The branch, tag or SHA to checkout"
type: string
index:
description: "The package index, e.g. PyPI or TestPyPI, from which to install the package. If empty, the package will not be installed from any package index, but from the current git clone"
type: string
index_version:
description: "The version of the package to be installed from the package index. If empty, the latest compatible version will be installed. Only used when index is non empty."
type: string
expected_index_version:
description: "The expected version of the package when installed from the package index. If emtpy, no check is carried out. Only used when index is non empty."
type: string
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- backend: none-real
container: debian:testing
petsc_arch: real
- backend: none-complex
container: debian:testing
petsc_arch: complex
- backend: dolfinx-v0.11.0-real
container: ghcr.io/fenics/dolfinx/dolfinx:v0.11.0
petsc_arch: real
- backend: dolfinx-v0.11.0-complex
container: ghcr.io/fenics/dolfinx/dolfinx:v0.11.0
petsc_arch: complex
- backend: dolfinx-stable-real
container: ghcr.io/fenics/dolfinx/dolfinx:stable
petsc_arch: real
- backend: dolfinx-stable-complex
container: ghcr.io/fenics/dolfinx/dolfinx:stable
petsc_arch: complex
- backend: dolfinx-nightly-real
container: ghcr.io/fenics/dolfinx/dolfinx:nightly
petsc_arch: real
- backend: dolfinx-nightly-complex
container: ghcr.io/fenics/dolfinx/dolfinx:nightly
petsc_arch: complex
fail-fast: false
container: ${{ matrix.container }}
steps:
- name: Install git
run: |
export DEBIAN_FRONTEND="noninteractive"
apt update -y -q
apt install -y -qq ca-certificates git
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ inputs.ref }}
- name: Setup container
run: |
export DEBIAN_FRONTEND="noninteractive"
apt update -y -q
apt install -y -qq libegl1 libgl1-mesa-dri
if [[ "${{ matrix.backend }}" == "dolfinx"* ]]; then
pip install pkgconfig
HDF5_MPI=ON python3 -m pip install h5py --no-build-isolation --no-binary=h5py
. /usr/local/bin/dolfinx-${{ matrix.petsc_arch }}-mode
echo "PETSC_ARCH=$PETSC_ARCH" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
echo "CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" >> $GITHUB_ENV
rm -f /dolfinx-env/lib/python3.*/site-packages/ufl/py.typed
else
apt install -y -qq cmake gcc g++ python3-mpi4py python3-nanobind python3-dev python3-pip python3-scikit-build-core python3-setuptools wget
echo "OMPI_ALLOW_RUN_AS_ROOT=1" >> $GITHUB_ENV
echo "OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1" >> $GITHUB_ENV
rm /usr/lib/python3.*/EXTERNALLY-MANAGED
apt install -y -qq libpetsc-${{ matrix.petsc_arch }}-dev libslepc-${{ matrix.petsc_arch }}-dev python3-petsc4py-${{ matrix.petsc_arch }} python3-slepc4py-${{ matrix.petsc_arch }}
PETSC_DIR=/usr/lib/petscdir/petsc-${{ matrix.petsc_arch }}
echo "PETSC_DIR=$PETSC_DIR" >> $GITHUB_ENV
SLEPC_DIR=/usr/lib/slepcdir/slepc-${{ matrix.petsc_arch }}
echo "SLEPC_DIR=$SLEPC_DIR" >> $GITHUB_ENV
fi
shell: bash
- name: Wait for package index availability (PyPI and TestPyPI only)
if: inputs.index != '' && inputs.index_version != ''
run: |
INDEX=${{ inputs.index }}
INDEX_VERSION=${{ inputs.index_version }}
PACKAGE_NAME="RBniCSx"
if [[ "${INDEX}" == "TestPyPI" ]]; then
INDEX_URL=https://test.pypi.org
elif [[ "${INDEX}" == "PyPI" ]]; then
INDEX_URL=https://pypi.org
else
echo "Invalid package index" && exit 1
fi
COUNTER=0
INDEX_VERSION_FOUND=0
while [[ ${INDEX_VERSION_FOUND} -ne 1 ]]; do
python3 -m pip install --no-cache-dir --index-url ${INDEX_URL}/simple/ ${PACKAGE_NAME}==0 2> all_${PACKAGE_NAME}_versions || true
if grep -q ${INDEX_VERSION} all_${PACKAGE_NAME}_versions; then
INDEX_VERSION_FOUND=1
fi
[[ ${INDEX_VERSION_FOUND} -ne 1 && ${COUNTER} -eq 5 ]] && echo "Giving up on finding version ${INDEX_VERSION} on ${INDEX_URL}" && exit 1
[[ ${INDEX_VERSION_FOUND} -ne 1 ]] && echo "Cannot find version ${INDEX_VERSION} on ${INDEX_URL}, attempt ${COUNTER}: trying again after a short pause" && sleep 10
[[ ${INDEX_VERSION_FOUND} -eq 1 ]] && echo "Found version ${INDEX_VERSION} on ${INDEX_URL}, attempt ${COUNTER}"
COUNTER=$((COUNTER+1))
done
shell: bash
- name: Install RBniCSx (PyPI and TestPyPI only)
if: inputs.index != ''
run: |
INDEX=${{ inputs.index }}
INDEX_VERSION=${{ inputs.index_version }}
EXPECTED_INDEX_VERSION=${{ inputs.expected_index_version }}
PACKAGE_NAME="RBniCSx"
if [[ "${INDEX}" == "TestPyPI" ]]; then
INDEX_FLAGS="--no-cache-dir --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/"
elif [[ "${INDEX}" == "PyPI" ]]; then
INDEX_FLAGS="--no-cache-dir"
else
echo "Invalid package index" && exit 1
fi
if [[ -n "${INDEX_VERSION}" ]]; then
PACKAGE_VERSION="==${INDEX_VERSION}"
echo "Installing version ${INDEX_VERSION} from ${INDEX}"
else
PACKAGE_VERSION=""
echo "Installing latest compatible version from ${INDEX}"
fi
if [[ "${{ matrix.backend }}" == "dolfinx"* ]]; then
PACKAGE_EXTRAS="docs,lint,tests,tutorials"
else
PACKAGE_EXTRAS="docs,lint,tests"
fi
python3 -m pip install ${INDEX_FLAGS} --no-build-isolation --config-settings=build-dir="build" --config-settings=cmake.build-type="Debug" --verbose ${PACKAGE_NAME}[${PACKAGE_EXTRAS}]${PACKAGE_VERSION}
if [[ -n "${EXPECTED_INDEX_VERSION}" ]]; then
ACTUAL_INDEX_VERSION=$(python3 -c 'import importlib.metadata; print(importlib.metadata.version("RBniCSx"))')
if [[ "${ACTUAL_INDEX_VERSION}" != "${EXPECTED_INDEX_VERSION}" ]]; then
echo "Error: installed ${PACKAGE_NAME} version is ${ACTUAL_INDEX_VERSION}, while expected version is ${EXPECTED_INDEX_VERSION}"
exit 1
fi
fi
shell: bash
- name: Install RBniCSx (git clone only)
if: inputs.index == ''
run: |
if [[ "${{ matrix.backend }}" == "dolfinx"* ]]; then
PACKAGE_EXTRAS="docs,lint,tests,tutorials"
else
PACKAGE_EXTRAS="docs,lint,tests"
fi
python3 -m pip install --check-build-dependencies --no-build-isolation --config-settings=build-dir="build" --config-settings=cmake.build-type="Debug" --verbose .[${PACKAGE_EXTRAS}]
shell: bash
- name: Clean build files (git clone only)
if: inputs.index == ''
run: |
git config --global --add safe.directory $PWD
git clean -xdf
- name: Update mypy configuration
run: |
if [[ "${{ matrix.backend }}" == none* ]]; then
sed -i 's@\[tool\.mypy\]@[tool.mypy]\nexclude = "(^rbnicsx/backends|^tests/unit/backends)"@g' pyproject.toml
sed -i 's@ # "dolfinx",@ "dolfinx",@g' pyproject.toml
sed -i 's@ # "dolfinx.*",@ "dolfinx.*",@g' pyproject.toml
fi
shell: bash
- name: Run ruff on python files
run: |
python3 -m ruff check .
- name: Run isort on python files
run: |
python3 -m isort --check --diff .
- name: Run mypy on python files
if: startsWith(matrix.backend, 'dolfinx') == true
run: |
python3 -m mypy --exclude=conftest.py .
python3 -m mypy tests/unit/conftest.py
python3 -m mypy tutorials/conftest.py
- name: Run yamllint on workflows
run: |
python3 -m yamllint -d "{extends: default, rules: {document-start: {present: false}, line-length: disable, truthy: {check-keys: false}}}" .
- name: Run clang-format on C++ files
run: |
wget https://raw.githubusercontent.com/FEniCS/dolfinx/main/.clang-format
find . -type f \( -name "*.cpp" -o -name "*.h" \) | xargs clang-format --dry-run --Werror
- name: Run cmake-format on cmake files
run: |
wget https://raw.githubusercontent.com/FEniCS/dolfinx/main/.cmake-format
find . -type f \( -name "*.cmake" -o -name "*.cmake.in" -o -name "CMakeLists.txt" \) | xargs cmake-format --check
- name: Run documentation generation
run: |
cd docs
if [[ "${{ matrix.backend }}" == none* ]]; then
sed -i "s@rbnicsx.backends@@g" api.rst
fi
python3 -m sphinx -W -b html . build/html
shell: bash
- name: Remove source directory to ensure that package from installation directory is used
run: |
rm -rf rbnicsx
- name: Determine coverage and pytest options for unit tests
id: unit_options
run: |
if [[ "${{ matrix.backend }}" == none* ]]; then
COVERAGE_UNIT_OMIT="*/rbnicsx/backends/*.py,*/rbnicsx/_cpp/backends/*.py"
PYTEST_UNIT_OPTIONS="--skip-backends"
else
COVERAGE_UNIT_OMIT=""
PYTEST_UNIT_OPTIONS=""
fi
echo "coverage_omit=${COVERAGE_UNIT_OMIT}" >> ${GITHUB_OUTPUT}
echo "pytest_options=${PYTEST_UNIT_OPTIONS}" >> ${GITHUB_OUTPUT}
shell: bash
- name: Run unit tests (serial)
run: |
COVERAGE_UNIT_OMIT="${{ steps.unit_options.outputs.coverage_omit }}"
PYTEST_UNIT_OPTIONS="${{ steps.unit_options.outputs.pytest_options }}"
COVERAGE_FILE=.coverage_unit_serial python3 -m coverage run --source=rbnicsx --omit="${COVERAGE_UNIT_OMIT}" -m pytest ${PYTEST_UNIT_OPTIONS} tests/unit
- name: Run unit tests (parallel)
run: |
COVERAGE_UNIT_OMIT="${{ steps.unit_options.outputs.coverage_omit }}"
PYTEST_UNIT_OPTIONS="${{ steps.unit_options.outputs.pytest_options }}"
COVERAGE_FILE=.coverage_unit_parallel mpirun -n 2 python3 -m coverage run --source=rbnicsx --parallel-mode --omit="${COVERAGE_UNIT_OMIT}" -m pytest ${PYTEST_UNIT_OPTIONS} tests/unit
- name: Combine coverage reports
run: |
python3 -m coverage combine .coverage*
python3 -m coverage report --fail-under=100 --show-missing --skip-covered
- name: Generate tutorial files
if: startsWith(matrix.backend, 'dolfinx') == true
run: |
NO_TESTS_COLLECTED=5
python3 -m pytest --ipynb-action=create-notebooks tutorials || (($?==$NO_TESTS_COLLECTED))
python3 -m pytest --ipynb-action=create-notebooks --collapse tutorials || (($?==$NO_TESTS_COLLECTED))
python3 -m pytest --ipynb-action=create-notebooks --np=2 tutorials || (($?==$NO_TESTS_COLLECTED))
python3 -m pytest --ipynb-action=create-notebooks --collapse --np=2 tutorials || (($?==$NO_TESTS_COLLECTED))
shell: bash
- name: Run ruff on tutorial files
if: startsWith(matrix.backend, 'dolfinx') == true
run: |
python3 -m nbqa ruff .
- name: Run isort on tutorial files
if: startsWith(matrix.backend, 'dolfinx') == true
run: |
python3 -m nbqa isort --check --diff .
- name: Run mypy on tutorial files
if: startsWith(matrix.backend, 'dolfinx') == true
run: |
python3 -m nbqa mypy .
- name: Check for stray outputs, counts and metadata in tutorial files
if: startsWith(matrix.backend, 'dolfinx') == true
uses: RBniCS/check-jupyter-metadata-action@6df653e5d45f7620d888c6a1bd85d07b4f903045 # v1.0.0
with:
pattern: "tutorials/**/*.ipynb"
- name: Run tutorials (serial)
if: startsWith(matrix.backend, 'dolfinx') == true
run: |
VISKEX_PYVISTA_BACKEND="static" python3 -m pytest --collapse --durations=0 --durations-min=1.0 tutorials
- name: Run tutorials (parallel)
if: startsWith(matrix.backend, 'dolfinx') == true
run: |
VISKEX_PYVISTA_BACKEND="static" python3 -m pytest --collapse --np=2 --durations=0 --durations-min=1.0 tutorials
- name: Upload tutorials logs as an artifact in case of failure
if: startsWith(matrix.backend, 'dolfinx') == true && (failure() || cancelled())
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: "tutorials-logs-${{ matrix.backend }}"
path: |
tutorials/**/.ipynb_pytest/**/*.log*
include-hidden-files: true
warn:
runs-on: ubuntu-latest
if: github.repository == 'RBniCS/RBniCSx' && github.ref == 'refs/heads/main' && github.event_name == 'schedule'
steps:
- name: Warn if scheduled workflow is about to be disabled
uses: fem-on-colab/warn-workflow-about-to-be-disabled-action@58c6022d9aeb22accfa8df9bf5b58c3d8867208c # v1.0.0
with:
workflow-filename: ci.yml
days-elapsed: 55