-
-
Notifications
You must be signed in to change notification settings - Fork 11
211 lines (208 loc) · 9.52 KB
/
Copy pathci.yml
File metadata and controls
211 lines (208 loc) · 9.52 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
name: CI
on:
push:
branches:
- "**"
pull_request:
branches:
- main
schedule:
- cron: "0 3 * * *"
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: 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:
image: ${{ matrix.container }}
options: --shm-size=1g
steps:
- 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
. /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 /dolfinx-env/lib/python3.*/site-packages/ufl/py.typed
- 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="multiphenicsx"
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 multiphenicsx (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="multiphenicsx"
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
python3 -m pip install ${INDEX_FLAGS} --no-build-isolation --config-settings=build-dir="build" --config-settings=cmake.build-type="Debug" --verbose ${PACKAGE_NAME}[docs,lint,tests,tutorials]${PACKAGE_VERSION}
if [[ -n "${EXPECTED_INDEX_VERSION}" ]]; then
ACTUAL_INDEX_VERSION=$(python3 -c 'import importlib.metadata; print(importlib.metadata.version("multiphenicsx"))')
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 multiphenicsx (git clone only)
if: inputs.index == ''
run: |
python3 -m pip install --check-build-dependencies --no-build-isolation --config-settings=build-dir="build" --config-settings=cmake.build-type="Debug" --verbose .[docs,lint,tests,tutorials]
- name: Clean build files (git clone only)
if: inputs.index == ''
run: |
git config --global --add safe.directory $PWD
git clean -xdf
- 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
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 && python3 -m sphinx -W -b html . build/html
- name: Remove source directory to ensure that package from installation directory is used
run: |
rm -rf multiphenicsx
- name: Run unit tests (serial)
run: |
COVERAGE_FILE=.coverage_unit_serial python3 -m coverage run --source=multiphenicsx -m pytest tests/unit
- name: Run unit tests (parallel)
run: |
COVERAGE_FILE=.coverage_unit_parallel mpirun -n 3 python3 -m coverage run --source=multiphenicsx --parallel-mode -m pytest tests/unit
- name: Combine coverage reports
run: |
python3 -m coverage combine .coverage*
python3 -m coverage report --fail-under=100 --show-missing --skip-covered
- name: Run ruff on tutorial files
run: |
python3 -m nbqa ruff .
- name: Run isort on tutorial files
run: |
python3 -m nbqa isort --check --diff .
- name: Run mypy on tutorial files
run: |
python3 -m nbqa mypy .
- name: Check for stray outputs, counts and metadata in tutorial files
uses: RBniCS/check-jupyter-metadata-action@6df653e5d45f7620d888c6a1bd85d07b4f903045 # v1.0.0
with:
pattern: "tutorials/**/*.ipynb"
- name: Run tutorials (serial)
run: |
VISKEX_PYVISTA_BACKEND="static" python3 -m pytest tutorials
- name: Run tutorials (parallel)
run: |
VISKEX_PYVISTA_BACKEND="static" python3 -m pytest --np 3 tutorials
- name: Upload tutorials logs as an artifact in case of failure
if: failure() || cancelled()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: "tutorials-logs-${{ matrix.petsc_arch }}"
path: |
tutorials/**/.ipynb_pytest/**/*.log*
include-hidden-files: true
warn:
runs-on: ubuntu-latest
if: github.repository == 'multiphenics/multiphenicsx' && 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