Repository navigation
253 lines (245 loc) · 11.9 KB
/
Copy pathci.yml
File metadata and controls
253 lines (245 loc) · 11.9 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
# Lean GitHub Actions CI for the itpplasma/gvec fork.
# Mirrors the essentials of the upstream GitLab CI (.gitlab-ci.yml, CI_templates/):
# ubuntu-24 package set (CI_images/ubuntu-24), CMake presets, ctest, pytest -m unit.
name: CI
on:
push:
branches:
- develop
pull_request:
workflow_dispatch:
merge_group:
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
MPLBACKEND: Agg
PYTHON_VERSION: "3.12" # Ubuntu 24.04 system python, as in CI_images/ubuntu-24
# fbtools revision used for free-boundary GVEC (BIEST submodule is fetched by pip)
FBTOOLS_REV: 14a5c4a7c3ff7458780edf7ebb0bd76712b44fbf
jobs:
pre-commit:
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/setup-python@v5.6.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: actions/cache@v4.2.3
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- run: python -m pip install pre-commit
- run: pre-commit run --all-files --show-diff-on-failure
if: >-
github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.actor != 'github-merge-queue[bot]') || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'full-ci'))
fortran:
name: fortran (${{ matrix.preset }})
runs-on: ${{ github.event.pull_request.head.repo.fork && 'ubuntu-latest' || fromJSON('["self-hosted","itp-build"]') }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
preset:
- gvec_config_release # Release + OpenMP
- gvec_config_debug # Debug + OpenMP
- gvec_config_no-omp_release
steps:
- uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
persist-credentials: false
- name: Run native checks in the build container
if: ${{ !github.event.pull_request.head.repo.fork }}
env:
SCI_BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || github.event.before }}
SCI_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha || github.sha }}
SCI_MATRIX_PRESET: ${{ matrix.preset }}
run: |-
ci/run.sh ci-fortran
- name: Install system packages
run: |
sudo apt-get update
# packages from CI_images/ubuntu-24 (gcc/gfortran 13) plus ninja/ccache
sudo apt-get install -y --no-install-recommends \
cmake ninja-build ccache pkg-config gfortran g++ git liblapack-dev libblas-dev zlib1g-dev libnetcdf-dev libnetcdff-dev
if: ${{ github.event.pull_request.head.repo.fork }}
- uses: actions/setup-python@v5.6.0
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
cache-dependency-path: pyproject.toml
if: ${{ github.event.pull_request.head.repo.fork }}
- name: Python test dependencies (used by the registered ctest tests)
run: |
python -m pip install pytest numpy pyyaml f90nml netcdf4 xarray scipy \
matplotlib tabulate tomlkit tqdm pyevtk requests f90wrap
if: ${{ github.event.pull_request.head.repo.fork }}
- uses: hendrikmuhs/ccache-action@v1.2.18
with:
key: fortran-${{ matrix.preset }}
if: ${{ github.event.pull_request.head.repo.fork }}
- name: Configure
run: >-
cmake --preset ${{ matrix.preset }} -B build -G Ninja
-DPython_EXECUTABLE="$(which python)"
-DCMAKE_Fortran_COMPILER_LAUNCHER=ccache
-DCMAKE_C_COMPILER_LAUNCHER=ccache
if: ${{ github.event.pull_request.head.repo.fork }}
- name: Build
run: cmake --build build --parallel
if: ${{ github.event.pull_request.head.repo.fork }}
- name: Test (registered ctest tests)
# the tests share ctest_run/ctest_post directories, so run them serially
run: ctest --test-dir build --output-on-failure --no-tests=error
if: ${{ github.event.pull_request.head.repo.fork }}
if: >-
github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.actor != 'github-merge-queue[bot]') || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'full-ci'))
python:
name: python (${{ matrix.build_type }})
runs-on: ${{ github.event.pull_request.head.repo.fork && 'ubuntu-latest' || fromJSON('["self-hosted","itp-build"]') }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
build_type: [Release, Debug]
env:
# job-wide like upstream's exported variable: test_build_type compares it with the built library
SKBUILD_CMAKE_BUILD_TYPE: ${{ matrix.build_type }}
steps:
- uses: actions/checkout@v4.2.2
with:
fetch-depth: 0 # setuptools_scm needs tags
persist-credentials: false
- name: Run native checks in the build container
if: ${{ !github.event.pull_request.head.repo.fork }}
env:
SCI_BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || github.event.before }}
SCI_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha || github.sha }}
SCI_MATRIX_BUILD_TYPE: ${{ matrix.build_type }}
run: |-
ci/run.sh ci-python
- name: Install system packages
run: |
sudo apt-get update
# packages from CI_images/ubuntu-24 (gcc/gfortran 13) plus ninja/ccache
sudo apt-get install -y --no-install-recommends \
cmake ninja-build ccache pkg-config gfortran g++ git liblapack-dev libblas-dev zlib1g-dev libnetcdf-dev libnetcdff-dev
if: ${{ github.event.pull_request.head.repo.fork }}
- uses: actions/setup-python@v5.6.0
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
cache-dependency-path: pyproject.toml
if: ${{ github.event.pull_request.head.repo.fork }}
- uses: hendrikmuhs/ccache-action@v1.2.18
with:
key: python-${{ matrix.build_type }}
if: ${{ github.event.pull_request.head.repo.fork }}
- name: Build wheel (scikit-build-core, as upstream .script_build_py)
env:
SKBUILD_CMAKE_DEFINE: USE_OPENMP=On;USE_MPI=Off
CMAKE_Fortran_COMPILER_LAUNCHER: ccache
CMAKE_C_COMPILER_LAUNCHER: ccache
run: |
python -m pip install build
python -m build --wheel
ls dist/
if: ${{ github.event.pull_request.head.repo.fork }}
- name: Install wheel
run: |
python -m pip install dist/*.whl pytest
pygvec --version
if: ${{ github.event.pull_request.head.repo.fork }}
- name: Unit tests (upstream .script_unit)
run: python -m pytest -m unit -v -rA --require-pygvec --junitxml=pytest.xml
if: ${{ github.event.pull_request.head.repo.fork }}
if: >-
github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.actor != 'github-merge-queue[bot]') || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'full-ci'))
free-boundary:
name: ${{ github.event_name == 'workflow_dispatch' && format('free-boundary ({0})', matrix.repetition) || 'free-boundary' }}
runs-on: ubuntu-24.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
# Separate hosted runners exercise hardware/build roundoff as well as test order.
repetition: ${{ fromJSON(github.event_name == 'workflow_dispatch' && '[1,2,3]' || '[1]') }}
env:
# Small interior systems run faster serially; the FD pool uses all four CPUs.
OMP_NUM_THREADS: "1"
OPENBLAS_NUM_THREADS: "1"
MKL_NUM_THREADS: "1"
steps:
- uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
- name: Install system packages
run: |
sudo apt-get update
# packages from CI_images/ubuntu-24 (gcc/gfortran 13) plus ninja/ccache
sudo apt-get install -y --no-install-recommends \
cmake ninja-build ccache pkg-config gfortran g++ git liblapack-dev libblas-dev zlib1g-dev libnetcdf-dev libnetcdff-dev libfftw3-dev
- uses: actions/setup-python@v5.6.0
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
cache-dependency-path: pyproject.toml
- uses: hendrikmuhs/ccache-action@v1.2.18
with:
key: free-boundary
- name: Install fbtools and GVEC (no build isolation)
env:
CMAKE_Fortran_COMPILER_LAUNCHER: ccache
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache
run: |
python -m pip install scikit-build-core setuptools_scm numpy f90wrap \
pytest cmake ninja pybind11
# fbtools defaults to -march=native; rebuild on the CPU that loads it.
# pip's persistent wheel tag does not distinguish hosted runner ISAs.
# pip fetches the BIEST/SCTL submodules of fbtools recursively.
python -m pip install --no-build-isolation --no-cache-dir \
"fbtools @ git+https://gitlab.mpcdf.mpg.de/nmpp-mhd-group/fhindenlang/fbtools.git@${FBTOOLS_REV}"
# use the free_boundary extra once the branch defines it
if grep -q '^free_boundary *=' pyproject.toml; then spec='.[free_boundary]'; else spec='.'; fi
python -m pip install --no-build-isolation "$spec"
- name: Import check
run: |
lscpu
python -u -c "import numpy; print('numpy', numpy.__version__); numpy.show_runtime()"
python -u -c "import fbtools; print('fbtools', fbtools.__file__)"
python -u -c "import gvec; print('gvec', gvec.__version__)"
- name: Free-boundary tests
run: |
set -euo pipefail
# free-boundary tests are recognised by marker or by file name
marked=$(grep -rlE 'mark\.(free_boundary|freeboundary)' test-CI || true)
files=$(find test-CI -type f -name 'test_*.py' -ipath '*free*boundary*' | sort)
if [ -n "$marked" ]; then
echo "Marked free-boundary tests in:"; echo "$marked"
# no `|| true`: failures and "no tests collected" (exit 5) fail the job
python -m pytest -v -rA --tb=short --require-pygvec \
--durations=10 --junitxml=free-boundary.xml -o junit_family=legacy \
-m "(free_boundary or freeboundary) and not slow" test-CI
elif [ -n "$files" ]; then
echo "Free-boundary test files:"; echo "$files"
mapfile -t files_arr <<< "$files"
python -m pytest -v -rA --tb=short --require-pygvec \
--durations=10 --junitxml=free-boundary.xml -o junit_family=legacy \
-m "not slow" "${files_arr[@]}"
else
echo "::notice::No free-boundary tests on this branch; only the import check ran."
fi
- name: Upload free-boundary results
if: always()
uses: actions/upload-artifact@v4.6.2
with:
name: free-boundary-${{ matrix.repetition }}
path: free-boundary.xml
if-no-files-found: error
if: >-
github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.actor != 'github-merge-queue[bot]') || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'full-ci'))