-
Notifications
You must be signed in to change notification settings - Fork 133
324 lines (286 loc) · 13.2 KB
/
build_and_test.yaml
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
name: Build and test
on:
workflow_call:
inputs:
compiler_family:
type: string
required: true
compiler_version:
type: string
required: true
config:
type: string
required: true
build_runner:
type: string
required: true
python:
type: string
required: true
validate:
type: string
required: true
release:
type: boolean
required: true
defaults:
run:
shell: bash
env:
# allow mpirun to execute as root in the tests
OMPI_ALLOW_RUN_AS_ROOT: 1
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
# allow openmpi to oversubscribe cores
PRTE_MCA_rmaps_default_mapping_policy: ":oversubscribe"
OMPI_MCA_rmaps_base_oversubscribe: "true"
# prevent errors from mis-configured openib systems
OMPI_MCA_btl: "vader,self"
# skip running the CPU tests in GPU builds
_HOOMD_SKIP_CPU_TESTS_WHEN_GPUS_PRESENT_: 1
# Require GPU tests in GPU builds.
_HOOMD_REQUIRE_GPU_TESTS_IN_GPU_BUILDS_: 1
jobs:
prepare:
runs-on: ubuntu-24.04
outputs:
image: ${{ steps.set.outputs.image }}
test_runner: ${{ steps.set.outputs.test_runner }}
test_docker_options: ${{ steps.set.outputs.test_docker_options }}
steps:
- name: Set outputs
id: set
run: |
if [[ "${{ inputs.compiler_family }}" == "gcc" ]]
then
echo 'test_runner="ubuntu-24.04"' >> "$GITHUB_OUTPUT"
echo 'test_docker_options=-e _noop' >> "$GITHUB_OUTPUT"
case ${{ inputs.compiler_version }} in
10|11)
echo "image=glotzerlab/ci:ubuntu-22.04" >> "$GITHUB_OUTPUT";;
12|13|14)
echo "image=glotzerlab/ci:ubuntu-24.04" >> "$GITHUB_OUTPUT";;
*)
echo "Unknown compiler" && exit 1;;
esac
elif [[ "${{ inputs.compiler_family }}" == "clang" ]]
then
echo 'test_runner="ubuntu-24.04"' >> "$GITHUB_OUTPUT"
echo 'test_docker_options=-e _noop' >> "$GITHUB_OUTPUT"
case "${{ inputs.compiler_version }}" in
13|14|15)
echo "image=glotzerlab/ci:ubuntu-22.04" >> "$GITHUB_OUTPUT";;
16|17|18)
echo "image=glotzerlab/ci:ubuntu-24.04" >> "$GITHUB_OUTPUT";;
*)
echo "Unknown compiler" && exit 1;;
esac
elif [[ "${{ inputs.compiler_family }}" == "cuda" ]]
then
echo "cuda=cuda${{ inputs.compiler_version }}" >> "$GITHUB_OUTPUT"
echo 'test_runner=["self-hosted", "GPU"]' >> "$GITHUB_OUTPUT"
echo 'test_docker_options=--gpus=all' >> "$GITHUB_OUTPUT"
case "${{ inputs.compiler_version }}" in
125)
echo "image=nvidia/cuda:12.5.0-devel-ubuntu22.04" >> "$GITHUB_OUTPUT";;
*)
echo "Unknown compiler" && exit 1;;
esac
else
echo "Invalid compiler family"
exit 1
fi
build:
needs: prepare
runs-on: ${{ fromJson(inputs.build_runner) }}
container:
image: ${{ needs.prepare.outputs.image }}
steps:
- name: "Show inputs"
run: echo "${{ toJson(inputs) }}"
- name: Clean workspace
run: ( shopt -s dotglob nullglob; rm -rf ./* )
- name: Clean HOME
run: ( shopt -s dotglob nullglob; rm -rf $HOME/* )
- name: Install git
if: ${{ startsWith(needs.prepare.outputs.image, 'nvidia') }}
run: |
apt-get update
apt-get install git --yes
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
path: code
submodules: true
- name: Create Python Environment
uses: mamba-org/setup-micromamba@068f1ab4b37ed9b3d9f73da7db90a0cda0a48d29 # v2.0.3
with:
micromamba-version: '2.0.2-2'
environment-name: test
environment-file: code/.github/workflows/environments/py${{ inputs.python }}-conda-lock.yml
post-cleanup: all
micromamba-root-path: ${{ github.workspace }}/micromamba
- name: Configure conda environment variables
run: |
echo "PYTHONPATH=$GITHUB_WORKSPACE/install" >> $GITHUB_ENV
echo "CONDA_PREFIX=$MAMBA_ROOT_PREFIX/envs/test" >> $GITHUB_ENV
echo "CMAKE_PREFIX_PATH=$MAMBA_ROOT_PREFIX/envs/test" >> $GITHUB_ENV
echo "$MAMBA_ROOT_PREFIX/envs/test/bin" >> $GITHUB_PATH
- name: Set compiler
if: ${{ inputs.compiler_family != 'cuda' }}
run: |
echo "CC=${{ inputs.compiler_family == 'gcc' && 'gcc' || 'clang' }}-${{ inputs.compiler_version }}" >> "$GITHUB_ENV"
echo "CXX=${{ inputs.compiler_family == 'gcc' && 'g++' || 'clang++' }}-${{ inputs.compiler_version }}" >> "$GITHUB_ENV"
- name: Treat warnings as errors
if: ${{ !inputs.release }}
run: |
echo "CXXFLAGS=-Werror" >> $GITHUB_ENV
- name: Configure
run: |
if [[ ${BUILD_DEBUG} == "true" ]]; then BUILD_TYPE="Debug"; else BUILD_TYPE="Release"; fi
echo "BUILD_TYPE=${BUILD_TYPE}"
cmake -S code -B build -GNinja \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DENABLE_GPU=${ENABLE_GPU:-"OFF"} \
-DENABLE_MPI=${ENABLE_MPI:-"OFF"} \
-DBUILD_MD=${BUILD_MD:-"ON"} \
-DBUILD_MPCD=${BUILD_MD:-"ON"} \
-DBUILD_METAL=${BUILD_MD:-"ON"} \
-DBUILD_HPMC=${BUILD_HPMC:-"ON"} \
-DCUDA_ARCH_LIST="60;70" \
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install \
-DPLUGINS=""
env:
ENABLE_GPU: ${{ contains(inputs.config, 'cuda') }}
ENABLE_MPI: ${{ contains(inputs.config, 'mpi') }}
BUILD_MD: ${{ !contains(inputs.config, 'nomd') }}
BUILD_HPMC: ${{ !contains(inputs.config, 'nohpmc') }}
BUILD_DEBUG: ${{ contains(inputs.config, 'debug') }}
- name: Build
run: ninja install -j $(($(getconf _NPROCESSORS_ONLN) + 2)) -k 0
working-directory: build
- name: Remove object files
run: find build -type f -name '*.o' -delete
- name: 'Tar build'
run: tar --use-compress-program='zstd -10 -T0' -cvf build.tar build
- name: 'Tar install'
run: tar --use-compress-program='zstd -10 -T0' -cvf install.tar install
- name: 'Upload build'
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: build-${{ inputs.config }}-${{ github.sha }}
path: build.tar
retention-days: 7
- name: 'Upload install'
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: install-${{ inputs.config }}-${{ github.sha }}
path: install.tar
retention-days: 7
test:
needs: [prepare, build]
runs-on: ${{ fromJson(needs.prepare.outputs.test_runner) }}
container:
image: ${{ needs.prepare.outputs.image }}
options: ${{ needs.prepare.outputs.test_docker_options }}
steps:
- name: Clean workspace
run: ( shopt -s dotglob nullglob; rm -rf ./* )
- name: Clean HOME
run: ( shopt -s dotglob nullglob; rm -rf $HOME/* )
- name: Install git
if: ${{ startsWith(needs.prepare.outputs.image, 'nvidia') }}
run: |
apt-get update
apt-get install git --yes
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
path: code
- name: Create Python Environment
uses: mamba-org/setup-micromamba@068f1ab4b37ed9b3d9f73da7db90a0cda0a48d29 # v2.0.3
with:
micromamba-version: '2.0.2-2'
environment-name: test
environment-file: code/.github/workflows/environments/py${{ inputs.python }}-conda-lock.yml
post-cleanup: all
micromamba-root-path: ${{ github.workspace }}/micromamba
- name: Configure conda environment variables
run: |
echo "PYTHONPATH=$GITHUB_WORKSPACE/install" >> $GITHUB_ENV
echo "CONDA_PREFIX=$MAMBA_ROOT_PREFIX/envs/test" >> $GITHUB_ENV
echo "CMAKE_PREFIX_PATH=$MAMBA_ROOT_PREFIX/envs/test" >> $GITHUB_ENV
echo "$MAMBA_ROOT_PREFIX/envs/test/bin" >> $GITHUB_PATH
- name: Download install
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: install-${{ inputs.config }}-${{ github.sha }}
- name: Untar install
run: tar --use-compress-program='zstd -10 -T0' -xvf install.tar
# Install cupy from PyPI to avoid pulling in CUDA from conda-forge. This would conflict
# with the CUDA provided by the NVIDIA container image.
# cupy 12.3.0 is the latest version that supports our oldest test GPUs - however, 12.3.0 does
# not support numpy 2.0. Uncomment the next block after the old GPUs are removed from the
# test runner pool.
# - name: Install cupy
# if: ${{ contains(inputs.config, 'cuda') }}
# run: uv pip install --no-deps fastrlock==0.8.2 cupy-cuda12x==12.3.0
### Python unit tests
- name: Run pytest (serial)
run: python3 -m pytest --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1
- name: Run pytest (mpi)
if: ${{ contains(inputs.config, 'mpi') }}
run: mpirun --timeout 3000 -n 2 ${GITHUB_WORKSPACE}/install/hoomd/pytest/pytest-openmpi.sh --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 || (( cat pytest.out.1 && exit 1 ))
- name: Run pytest (serial without cupy)
if: ${{ contains(inputs.config, 'cuda') }}
run: python3 -m pytest --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 -m cupy_optional
env:
_HOOMD_DISALLOW_CUPY_: 1
- name: Run pytest (mpi without cupy)
if: ${{ contains(inputs.config, 'cuda') && contains(inputs.config, 'mpi') }}
run: mpirun --timeout 3000 -n 2 ${GITHUB_WORKSPACE}/install/hoomd/pytest/pytest-openmpi.sh --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 -m cupy_optional || (( cat pytest.out.1 && exit 1 ))
env:
_HOOMD_DISALLOW_CUPY_: 1
### compute-sanitizer checks: These checks are slow, so run them only when validation is
# requested, but no on the actual long validation tests. Every class's basic test should ensure
# that the GPU kernel is called for at least a few timesteps for these checks to be effective.
- name: Run memcheck
if: ${{ contains(inputs.config, 'cuda') && contains(github.event.pull_request.labels.*.name, 'validate') && inputs.validate == 'true' && !contains(inputs.config, 'mpi')}}
run: compute-sanitizer --tool memcheck --error-exitcode 1 python3 -m pytest --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1
- name: Run racecheck
if: ${{ contains(inputs.config, 'cuda') && contains(github.event.pull_request.labels.*.name, 'validate') && inputs.validate == 'true' && !contains(inputs.config, 'mpi')}}
run: compute-sanitizer --tool racecheck --error-exitcode 1 python3 -m pytest --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1
- name: Run synccheck
if: ${{ contains(inputs.config, 'cuda') && contains(github.event.pull_request.labels.*.name, 'validate') && inputs.validate == 'true' && !contains(inputs.config, 'mpi')}}
run: compute-sanitizer --tool synccheck --error-exitcode 1 python3 -m pytest --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1
### Validation tests
- name: Run pytest -m validate (serial)
if: ${{ !contains(inputs.config, 'mpi') && contains(github.event.pull_request.labels.*.name, 'validate') && inputs.validate == 'true' }}
run: python3 -m pytest --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 -p hoomd.pytest_plugin_validate -m validate --validate
- name: Run pytest -m validate (mpi)
if: ${{ contains(inputs.config, 'mpi') && contains(github.event.pull_request.labels.*.name, 'validate') && inputs.validate == 'true' }}
run: mpirun --timeout 3000 -n 2 ${GITHUB_WORKSPACE}/install/hoomd/pytest/pytest-openmpi.sh --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 -p hoomd.pytest_plugin_validate -m validate --validate || (( cat pytest.out.1 && exit 1 ))
- name: Run howto guides (serial)
if: ${{ contains(github.event.pull_request.labels.*.name, 'validate') && inputs.validate == 'true' }}
run: 'for i in *.py; do echo "Running howto: $i" && python3 $i || exit 1; done'
working-directory: code/sphinx-doc/howto
## C++ unit tests
# Ubuntu 24.04 provides a new libstdc++ than conda-forge (as of 2024-06). For unknown reasons,
# the HOOMD ctest tests find libstdc++ in the conda environment. Set LD_LIBRARY_PATH to force
# the use of the system library.
- name: Use the ubuntu-provided standard libraries
run: |
echo "LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu" >> $GITHUB_ENV
- name: Download build
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: build-${{ inputs.config }}-${{ github.sha }}
- name: Untar build
run: tar --use-compress-program='zstd -10 -T0' -xvf build.tar
- name: Run ctest
run: >-
ctest
--test-dir .
--output-on-failure
--test-output-size-failed 1048576
--test-output-size-passed 1048576
working-directory: build