-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathtest.yml
More file actions
240 lines (231 loc) · 9.1 KB
/
test.yml
File metadata and controls
240 lines (231 loc) · 9.1 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
<% extends "workflow.yml" %>
<% block name %>
name: Test
# Edit the `test.yml` in `.github/workflows/templates` and run `make_workflows.py` to update the
# workflow.
<% endblock %>
<% block on_pull_request %>
pull_request:
types: [opened, labeled, reopened, synchronize]
<% endblock %>
<% block env %>
env:
# prevent deadlocked MPI tests from causing the job to cancel
MPIEXEC_TIMEOUT: 3000
# 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
OMPI_MCA_rmaps_base_oversubscribe: 1
# 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
# import HOOMD out of the build directory
PYTHONPATH: ${{ github.workspace }}/install
<% endblock %>
<% set tar_command="tar --use-compress-program='zstd -10 -T0'" %>
<% macro job(name, use_gpu_runners, configurations, needs='') %>
name: << name >> [${{ join(matrix.config, '_') }}]
<% if needs != '' %>
needs: << needs >>
<% endif %>
<% if use_gpu_runners %>
runs-on: ${{ matrix.runner }}
container:
image: << container_prefix >>-${{ matrix.config[0] }}
options: ${{ matrix.docker_options }} -e CUDA_VISIBLE_DEVICES
<% else %>
runs-on: ubuntu-latest
container:
image: << container_prefix >>-${{ matrix.config[0] }}
<% endif %>
strategy:
matrix:
include:
<% for configuration in configurations %>
- {config: << configuration.config >>, runner: << configuration.runner >>, docker_options: '<< configuration.docker_options >>' }
<% endfor %>
<% endmacro %>
<% set build_steps %>
- name: Checkout
uses: actions/checkout@v2.3.4
with:
path: code
submodules: true
- name: Configure
run: |
mkdir -p build
cd build
cmake ../code -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_GPU=${ENABLE_GPU:-"OFF"} \
-DENABLE_MPI=${ENABLE_MPI:-"OFF"} \
-DENABLE_TBB=${ENABLE_TBB:-"OFF"} \
-DBUILD_JIT=${BUILD_JIT:-"OFF"} \
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install
env:
ENABLE_GPU: ${{ contains(matrix.config[0], 'cuda') }}
ENABLE_MPI: ${{ contains(matrix.config, 'mpi') }}
ENABLE_TBB: ${{ contains(matrix.config, 'tbb') }}
BUILD_JIT: ${{ contains(matrix.config, 'jit') }}
- name: Build
run: ninja install -j $(($(getconf _NPROCESSORS_ONLN) + 2))
working-directory: build
<% endset %>
<% set upload_steps %>
- name: Remove object files
run: find build -type f -name '*.o' -delete
# Tar the build directory to preserve permissions and reduce HTTP requests on upload.
- name: 'Tar build'
run: << tar_command >> -cvf build.tar build
- name: 'Tar install'
run: << tar_command >> -cvf install.tar install
# Upload the tarballs. Retain the file for a limited time in case developers need to download
# and run tests locally for further debugging.
- name: 'Upload build'
uses: actions/upload-artifact@v2.2.4
with:
name: build-${{ join(matrix.config, '_') }}-${{ github.sha }}
path: build.tar
retention-days: 7
- name: 'Upload install'
uses: actions/upload-artifact@v2.2.4
with:
name: install-${{ join(matrix.config, '_') }}-${{ github.sha }}
path: install.tar
retention-days: 7
<% endset %>
<% set download_build_steps %>
- name: Download build
uses: actions/download-artifact@v2.0.10
with:
name: build-${{ join(matrix.config, '_') }}-${{ github.sha }}
- name: Untar build
run: << tar_command >> -xvf build.tar
<% endset %>
<% set download_install_steps %>
- name: Download install
uses: actions/download-artifact@v2.0.10
with:
name: install-${{ join(matrix.config, '_') }}-${{ github.sha }}
- name: Untar install
run: << tar_command >> -xvf install.tar
<% endset %>
<% set pytest_options="--pyargs hoomd -v -ra --durations=0 --durations-min=0.1" %>
<% set pytest_validate_options="-p hoomd.pytest_plugin_validate -m validate --validate" %>
<% set invoke_pytest_serial="python3 -m pytest" %>
<% set invoke_pytest_mpi="mpirun -n 2 ${GITHUB_WORKSPACE}/install/hoomd/pytest/pytest-openmpi.sh -x" %>
<% set pytest_steps %>
- name: Run pytest (serial)
run: << invoke_pytest_serial >> << pytest_options >>
- name: Run pytest (mpi)
if: ${{ contains(matrix.config, 'mpi') }}
run: << invoke_pytest_mpi >> << pytest_options >> || (( cat pytest.out.1 && exit 1 ))
- name: Run pytest (serial without cupy)
if: ${{ contains(matrix.config[0], 'cuda') }}
run: << invoke_pytest_serial >> << pytest_options >> -m cupy_optional
env:
_HOOMD_DISALLOW_CUPY_: 1
- name: Run pytest (mpi without cupy)
if: ${{ contains(matrix.config[0], 'cuda') && contains(matrix.config, 'mpi') }}
run: << invoke_pytest_mpi >> << pytest_options >> -m cupy_optional || (( cat pytest.out.1 && exit 1 ))
env:
_HOOMD_DISALLOW_CUPY_: 1
<% endset %>
<% set ctest_steps %>
- name: Run tests
run: >-
ctest
-T test
--output-on-failure
--test-output-size-failed 1048576
--test-output-size-passed 1048576
working-directory: build
<% endset %>
<% set pytest_validate_steps %>
- name: Run pytest (serial)
if: ${{ !contains(matrix.config, 'mpi') }}
run: << invoke_pytest_serial >> << pytest_options >> << pytest_validate_options >>
- name: Run pytest (mpi)
if: ${{ contains(matrix.config, 'mpi') }}
run: << invoke_pytest_mpi >> << pytest_options >> << pytest_validate_options >> || (( cat pytest.out.1 && exit 1 ))
<% endset %>
<% set prepare_steps %>
steps:
- name: Clean workspace
run: rm -rf ./*
<% endset %>
<% block jobs %>
# Use multiple jobs to reduce the amount of time spent on GPU runners. Use GitHub Hosted runners for
# compiling all tests configurations (GPU and CPU), then upload the build directory (sans object
# files) as an artifact. Test jobs depend on the build job, download the install directory, and run
# the tests. Upload each build configuration to a separate artifact.
# Github Actions does not support any form of templating at this time, not even YAML anchors.
# To minimize the number of duplicated lines, encode the job configuration as an array in config:
# [image, (mpi), (tbb)]
jobs:
build:
<< job(name='Build', use_gpu_runners=False, configurations=unit_test_configurations) >>
env:
CXXFLAGS: '-Werror'
<< prepare_steps >>
<< build_steps >>
<< upload_steps >>
pytest:
<< job(name='Run pytest', use_gpu_runners=True, configurations=unit_test_configurations, needs='build') >>
<< prepare_steps >>
<< download_install_steps >>
<< pytest_steps >>
ctest:
<< job(name='Run ctest', use_gpu_runners=True, configurations=unit_test_configurations, needs='build') >>
<< prepare_steps >>
<< download_build_steps >>
<< ctest_steps >>
validate:
<< job(name='Validate', use_gpu_runners=True, configurations=validate_configurations, needs='build') >>
if: ${{ contains(github.event.pull_request.labels.*.name, 'validate') }}
<< prepare_steps >>
<< download_install_steps >>
<< pytest_validate_steps >>
build_release:
<< job(name='Build', use_gpu_runners=False, configurations=release_test_configurations) >>
if: ${{ contains(github.event.pull_request.labels.*.name, 'release') }}
<< prepare_steps >>
<< build_steps >>
<< upload_steps >>
pytest_release:
<< job(name='Run pytest', use_gpu_runners=True, configurations=release_test_configurations, needs='build_release') >>
if: ${{ contains(github.event.pull_request.labels.*.name, 'release') }}
<< prepare_steps >>
<< download_install_steps >>
<< pytest_steps >>
ctest_release:
<< job(name='Run ctest', use_gpu_runners=True, configurations=release_test_configurations, needs='build_release') >>
if: ${{ contains(github.event.pull_request.labels.*.name, 'release') }}
<< prepare_steps >>
<< download_build_steps >>
<< ctest_steps >>
# This job is used to provide a single requirement for branch merge conditions. GitHub considers
# the check passing even if it is skipped, so this job raises errors when required jobs were not
# run.
unit_tests_complete:
name: Unit test
needs: [pytest, ctest, validate]
if: ${{ always() && github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- name: Error if pytest did not succeed
if: needs.pytest.result != 'success'
run: echo "::error ::pytest tests failed." && exit 1
- name: Error if ctest did not succeed
if: needs.ctest.result != 'success'
run: echo "::error ::ctest tests failed." && exit 1
- name: Warn if validate did not run
if: needs.validate.result == 'skipped'
run: echo "::warning ::Skipped validation tests." && exit 1
- name: Error if validate did not succeed
if: needs.validate.result != 'success'
run: echo "::error ::Validation tests failed." && exit 1
- run: echo "Done!"
<% endblock %>