-
Notifications
You must be signed in to change notification settings - Fork 1
279 lines (243 loc) · 8.97 KB
/
build-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
name: Build and Test
on:
schedule:
- cron: 0 */24 * * *
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description:
Run the build with tmate debugging enabled
(https://github.com/marketplace/actions/debugging-with-tmate)
required: false
default: false
pull_request:
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-geant4:
name: "Geant4 Install - No Datasets"
runs-on: ${{ matrix.platform }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest]
geant4-version:
- 11.1.3
steps:
- name: Install additional dependencies (ubuntu)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y build-essential git
python -m pip install cmake
- name: Cache Xerces-C Installation
id: cache-xerces
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/xerces
key: xerces-${{ matrix.platform }}
- name: Build and Install Xerces-C
if: steps.cache-xerces.outputs.cache-hit != 'true'
run: |
git clone https://github.com/apache/xerces-c.git xerces-source
git -C xerces-source checkout tags/v3.2.4
mkdir -p ${{ github.workspace }}/xerces-source/build
cd ${{ github.workspace }}/xerces-source/build
cmake .. -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/xerces -DCMAKE_CXX_STANDARD=20 -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -Dnetwork-accessor=socket -Dtranscoder=iconv -DCMAKE_CXX_FLAGS=-fPIC -DCMAKE_C_FLAGS=-fPIC
make install -j$(nproc)
- name: Cache Geant4 Installation
id: cache-geant4
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/geant4
key: geant4-${{ matrix.geant4-version }}-${{ matrix.platform }}
- name: Build and Install Geant4 (without datasets)
if: steps.cache-geant4.outputs.cache-hit != 'true'
run: |
git clone https://github.com/Geant4/geant4.git ${{ github.workspace }}/geant4-source --depth 1 --branch v${{ matrix.geant4-version }}
mkdir -p ${{ github.workspace }}/geant4-source/build
cd ${{ github.workspace }}/geant4-source/build
cmake .. -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/geant4 -DXERCESC_ROOT_DIR=${{ github.workspace }}/xerces -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release -DGEANT4_USE_GDML=ON -DGEANT4_INSTALL_EXAMPLES=OFF -DGEANT4_INSTALL_DATA=OFF -DGEANT4_BUILD_TLS_MODEL=global-dynamic -DCMAKE_CXX_FLAGS=-fPIC -DCMAKE_C_FLAGS=-fPIC -DGEANT4_USE_SYSTEM_EXPAT=OFF -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF
make install -j$(nproc)
install-geant4-datasets:
name: "Geant4 Datasets"
needs: [build-geant4]
runs-on: ${{ matrix.platform }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest]
geant4-version:
- 11.1.3
steps:
- name: Cache Geant4 Installation
id: cache-geant4
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/geant4
key: geant4-${{ matrix.geant4-version }}-${{ matrix.platform }}
fail-on-cache-miss: true
- name: Cache Geant4 Datasets
id: cache-geant4-data
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/geant4-data
key: geant4-${{ matrix.geant4-version }}-data
enableCrossOsArchive: true
- name: Install Geant4 Datasets
if: steps.cache-geant4-data.outputs.cache-hit != 'true'
run: |
source ${{ github.workspace }}/geant4/bin/geant4.sh
geant4-config --install-datasets
geant4-config --check-datasets
mv ${{ github.workspace }}/geant4/share/Geant4/data ${{ github.workspace }}/geant4-data
build-test:
name: "Build and Test"
needs: [install-geant4-datasets]
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest]
geant4-version:
- 11.1.3
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install additional dependencies (ubuntu)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y build-essential
- name: Install cmake
run: |
python -m pip install cmake
- name: Cache Xerces-C Installation
id: cache-xerces
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/xerces
key: xerces-${{ matrix.platform }}
fail-on-cache-miss: true
- name: Cache Geant4 Installation
id: cache-geant4
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/geant4
key: geant4-${{ matrix.geant4-version }}-${{ matrix.platform }}
fail-on-cache-miss: true
- name: pip install the package
run: |
source ${{ github.workspace }}/geant4/bin/geant4.sh
python -m pip install .[test]
- name: Check import
run: |
python -c "import geant4_python_application; geant4_python_application.Application()"
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if:
${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled
}}
with:
limit-access-to-actor: false
- name: Save datasets location to env
run: |
GEANT4_DATA_DIR=$(python -c "import geant4_python_application; print(geant4_python_application.datasets.data_dir)")
echo "GEANT4_DATA_DIR=${GEANT4_DATA_DIR}" >> $GITHUB_ENV
- name: Cache Geant4 Datasets
id: cache-geant4-data
uses: actions/cache@v3
with:
path: ${{ github.env.GEANT4_DATA_DIR }}
key: geant4-${{ matrix.geant4-version }}-data
fail-on-cache-miss: true
enableCrossOsArchive: true
- name: Run tests
run: |
source ${{ github.workspace }}/geant4/bin/geant4.sh
find ./tests -name "test_*.py" -exec python -m pytest -vv --reruns 3 --reruns-delay 30 --only-rerun "(?i)http|timeout|connection|socket|resolve" {} \;
- name: Build Wheel
run: |
source ${{ github.workspace }}/geant4/bin/geant4.sh
python -m pip install build
python -m build --wheel .
- name: Upload Wheel
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/*.whl
- name: Cache Wheel
uses: actions/cache@v3
with:
path: dist
key:
dist-${{ matrix.python-version }}-${{ matrix.geant4-version }}-${{
matrix.platform }}-${{ github.run_id }}
wheel-test:
name: "Install wheel and test"
needs: [build-test]
timeout-minutes: 30
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest]
geant4-version:
- 11.1.3
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Restore wheel
uses: actions/cache@v3
with:
path: dist
key:
dist-${{ matrix.python-version }}-${{ matrix.geant4-version }}-${{
matrix.platform }}-${{ github.run_id }}
fail-on-cache-miss: true
- name: Install wheel
run: |
python -m pip install dist/*.whl
- name: Save datasets location to env
run: |
GEANT4_DATA_DIR=$(python -c "import geant4_python_application; print(geant4_python_application.datasets.data_dir)")
echo "GEANT4_DATA_DIR=${GEANT4_DATA_DIR}" >> $GITHUB_ENV
# test ability to download datasets in one job and use the cache in the others
- name: Cache Geant4 Datasets
if:
matrix.python-version != '3.11' || matrix.platform != 'ubuntu-latest'
id: cache-geant4-data
uses: actions/cache@v3
with:
path: ${{ github.env.GEANT4_DATA_DIR }}
key: geant4-${{ matrix.geant4-version }}-data
fail-on-cache-miss: true
enableCrossOsArchive: true
- name: Run tests
run: |
find ./tests -name "test_*.py" -exec python -m pytest -vv --reruns 3 --reruns-delay 30 --only-rerun "(?i)http|timeout|connection|socket|resolve" {} \;