-
Notifications
You must be signed in to change notification settings - Fork 8
207 lines (186 loc) · 9.59 KB
/
unit_test.yml
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
name: Unit test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
# Trigger on pull requests.
pull_request:
# Trigger on pushes to the mainline branches. This prevents building commits twice when the pull
# request source branch is in the same repository.
push:
branches:
- "trunk"
# Trigger on request.
workflow_dispatch:
# 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 installation directory
# 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.
# Copy and paste the matrix from `build_linux` to `test_linux`. The list in `test_linux` must be a
# subset of the list in `build_linux`.
jobs:
build_linux:
name: Build [${{ matrix.image }}]
runs-on: ubuntu-latest
container:
image: ${{ matrix.repository }}/ci:2023.11.27-${{ matrix.image }}
credentials:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
strategy:
matrix:
include:
- {repository: glotzerlab, image: clang16_py311, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: true }
- {repository: glotzerlab, image: clang15_py311, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: true }
- {repository: glotzerlab, image: clang14_py311, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: true }
- {repository: glotzerlab, image: clang13_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: clang12_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: clang11_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: clang10_py38, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: gcc13_py312, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: gcc12_py311, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: gcc11_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: gcc10_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: gcc9_py39, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: joaander, image: optix65_cuda118_py310, test_runner: [self-hosted,GPU,optix], test_docker_options: '-e NVIDIA_DRIVER_CAPABILITIES=compute,graphics --gpus=all', render_gallery: false }
steps:
- uses: actions/checkout@v4.1.4
with:
path: code
submodules: true
- name: Configure
run: |
mkdir -p build
cd build
cmake ../code -GNinja \
-DENABLE_EMBREE=${ENABLE_EMBREE:-"ON"} \
-DENABLE_OPTIX=${ENABLE_OPTIX:-"OFF"} \
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install
env:
ENABLE_OPTIX: ${{ contains(matrix.image, 'optix') }}
ENABLE_EMBREE: ${{ !contains(matrix.image, 'optix') }}
- name: Build
run: ninja install
working-directory: build
# Tar the installation directory to preserve permissions and reduce HTTP requests on upload.
- name: 'Tar install'
run: tar --use-compress-program='zstd -10 -T0' -cvf install.tar install
# Upload the tarball. Retain the file for a limited time in case developers need to download
# and run tests locally for further debugging.
- uses: actions/upload-artifact@v4.3.3
name: 'Upload install'
with:
name: install-${{ matrix.image }}-${{ github.sha }}
path: install.tar
retention-days: 7
test_linux:
needs: build_linux
runs-on: ${{ matrix.test_runner }}
container:
image: ${{ matrix.repository }}/ci:2023.11.27-${{ matrix.image }}
options: ${{ matrix.test_docker_options }} -e CUDA_VISIBLE_DEVICES
credentials:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
strategy:
matrix:
include:
- {repository: glotzerlab, image: clang16_py311, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: true }
- {repository: glotzerlab, image: clang15_py311, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: true }
- {repository: glotzerlab, image: clang14_py311, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: true }
- {repository: glotzerlab, image: clang13_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: clang12_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: clang11_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: clang10_py38, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: gcc13_py312, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: gcc12_py311, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: gcc11_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: gcc10_py310, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: glotzerlab, image: gcc9_py39, test_runner: ubuntu-latest, test_docker_options: '', render_gallery: false }
- {repository: joaander, image: optix65_cuda118_py310, test_runner: [self-hosted,GPU,optix], test_docker_options: '-e NVIDIA_DRIVER_CAPABILITIES=compute,graphics --gpus=all', render_gallery: false }
steps:
- name: Clean workspace
run: ( shopt -s dotglob nullglob; rm -rf ./* )
shell: bash
- uses: actions/download-artifact@v4.1.7
with:
name: install-${{ matrix.image }}-${{ github.sha }}
- name: Untar install
run: tar --use-compress-program='zstd -10 -T0' -xvf install.tar
- name: Run tests
run: python3 -m pytest --pyargs fresnel -v --log-level=DEBUG --durations=0 --durations-min=0.1
env:
PYTHONPATH: ${{ github.workspace }}/install
- uses: actions/checkout@v4.1.4
if: ${{ matrix.render_gallery }}
with:
submodules: true
path: code
- name: Render gallery images
if: ${{ matrix.render_gallery }}
run: for i in *.py; do echo "Rendering $i" && python3 $i || exit 1; done
working-directory: code/doc/gallery
env:
PYTHONPATH: ${{ github.workspace }}/install
- name: Clean workspace
run: ( shopt -s dotglob nullglob; rm -rf ./* )
shell: bash
- name: Clean HOME
run: ( shopt -s dotglob nullglob; rm -rf $HOME/* )
shell: bash
build_test_windows:
name: Build and test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- {os: windows-2019, cmake_generator: "Visual Studio 16 2019"}
- {os: windows-2022, cmake_generator: "Visual Studio 17 2022"}
steps:
- uses: actions/checkout@v4.1.4
with:
path: code
submodules: true
- name: Create conda environment
uses: conda-incubator/setup-miniconda@v3.0.4
with:
environment-file: code/.github/workflows/environments/conda.yml
activate-environment: ${{ github.workspace }}/env
python-version: 3.11
miniforge-variant: Mambaforge
miniforge-version: "latest"
use-mamba: true
env:
CONDA: ${{ github.workspace }}\miniconda
- name: Add environment to system path
# these are all needed because miniconda installs libraries to a variety of paths
run: |
echo "$env:GITHUB_WORKSPACE\env" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "$env:GITHUB_WORKSPACE\env\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "$env:GITHUB_WORKSPACE\env\Scripts" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "$env:GITHUB_WORKSPACE\env\Library\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Configure
run: >
cmake -S code -B build
-DENABLE_EMBREE=ON
-DENABLE_OPTIX=OFF
-DPYTHON_EXECUTABLE="$env:GITHUB_WORKSPACE"\env\python.exe
-DCMAKE_INSTALL_PREFIX="$env:GITHUB_WORKSPACE"\install
-G "${{ matrix.cmake_generator }}"
env:
CMAKE_PREFIX_PATH: ${{ github.workspace }}\env
- name: Build
run: cmake --build build --config Release -j
- name: Install
run: cmake --install build --config Release
- name: Run tests
run: python -m pytest --pyargs fresnel -v --log-level=DEBUG --durations=0 --durations-min=0.1
env:
PYTHONPATH: ${{ github.workspace }}\install
# This job is used to provide a single requirement for branch merge conditions.
tests_complete:
name: Unit test
needs: [build_linux, test_linux, build_test_windows]
runs-on: ubuntu-latest
steps:
- run: echo "Done!"