-
Notifications
You must be signed in to change notification settings - Fork 35
251 lines (247 loc) · 8.83 KB
/
build-spack.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
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
# Build directly on the GitHub runner with caching
name: build-spack
on:
workflow_dispatch:
workflow_call:
concurrency:
group: build-spack-${{github.ref}}-${{github.event.pull_request.number || github.run_number}}-${{github.workflow}}
env:
SPACK_REF: 5fe93fee1eec46a0750bd340198bffcb92ff9eec # v0.22.0
jobs:
spack:
name: >-
${{format('{0}{1}{2}{3}{4}',
matrix.geometry,
matrix.special && '-' || '',
matrix.special,
matrix.geant && '-g4@' || '',
matrix.geant)}}
strategy:
fail-fast: false
matrix:
geometry: ["vecgeom"]
special: [null]
geant: ["10.5", "10.6", "10.7", "11.0", "11.1", "11.2"]
include:
- geometry: "orange"
special: "minimal"
geant: null
- geometry: "orange"
special: "float"
geant: "11.0"
- geometry: "orange"
special: "asanlite"
geant: null
- geometry: "vecgeom"
special: "clhep"
geant: "11.0"
- geometry: "geant4"
special: null
geant: "11.0"
- geometry: "vecgeom"
special: "clang-tidy"
geant: "11.2"
env:
CCACHE_DIR: "${{github.workspace}}/.ccache"
CCACHE_MAXSIZE: "100Mi"
CMAKE_PRESET: >-
${{format('reldeb-{0}{1}{2}',
matrix.geometry,
matrix.special && '-' || '',
matrix.special)}}
SPACK_VIEW: "/opt/spack-view"
SPACK_BUILDCACHE: "celer-buildcache" # see spack.yaml
CC: "clang-15"
CXX: "clang++-15"
CLANG_TIDY: "clang-tidy-15"
runs-on: ubuntu-22.04
continue-on-error: false
steps:
- name: Check out Celeritas
uses: actions/checkout@v4
with:
fetch-depth: ${{format('{0}', matrix.special != 'clang-tidy' && 383 || 0)}}
fetch-tags: true # to get version information
- name: Setup Spack
uses: spack/setup-spack@0ce61628ed8a32a5664cf01a0e0b5a4834a3b413 # 2024/03
with:
ref: ${{env.SPACK_REF}}
buildcache: true
color: true
path: spack-src
- name: Initialize spack environment
run: |
# TODO: https://github.com/spack/spack/pull/43136
curl -LfsS https://github.com/spack/spack/pull/43136.patch | git -C spack-src apply -
cp scripts/ci/spack.yaml .
if [ "${{matrix.geometry}}" == "vecgeom" ]; then
spack -e . add vecgeom
fi
if [ "${{matrix.special}}" != "minimal" ] && [ "${{matrix.special}}" != "asanlite" ] ; then
spack -e . add root
fi
if [ "${{matrix.geant}}" != "" ]; then
spack -e . add geant4@${{matrix.geant}}
fi
spack -e . config add packages:all:require:"'%clang@15 target=x86_64_v3'"
spack -e . compiler find
# Add the spack ref so that updating spack will reconcretize
echo "# Concretized with ${{env.SPACK_REF}}" >> spack.yaml
- name: Cache concretization
uses: actions/cache@v4
with:
path: spack.lock
key: lock-${{hashFiles('spack.yaml')}}-${{github.run_id}}
restore-keys: |
lock-${{hashFiles('spack.yaml')}}
- name: Concretize
run: |
spack -e . -v concretize
- name: Install dependencies with Spack
run: |
spack -e . env depfile -o Makefile
make -Orecurse -j $(($(nproc) + 1)) SPACK_INSTALL_FLAGS=--no-check-signature
- name: Save Spack installation to build cache
run: |
spack -e . mirror set --push --oci-username ${{github.actor}} --oci-password "${{secrets.GITHUB_TOKEN}}" ${SPACK_BUILDCACHE}
spack -e . buildcache push -j $(($(nproc) + 1)) --base-image ubuntu:22.04 --unsigned --update-index ${SPACK_BUILDCACHE}
if: ${{github.event_name == 'push' && !cancelled()}}
- name: Activate environment
run: |
test -d "${SPACK_VIEW}"
echo "${SPACK_VIEW}/bin" >> $GITHUB_PATH
echo "CMAKE_PREFIX_PATH=${SPACK_VIEW}:${CMAKE_PREFIX_PATH}" >> $GITHUB_ENV
spack env activate . --sh > "${SPACK_VIEW}/rc"
- name: Cache ccache
uses: actions/cache@v4
with:
path: ${{env.CCACHE_DIR}}
key: ccache-${{env.CMAKE_PRESET}}-${{matrix.geant}}-${{github.run_id}}
restore-keys: |
ccache-${{env.CMAKE_PRESET}}-${{matrix.geant}}
ccache-${{env.CMAKE_PRESET}}
- name: Zero ccache stats
run: |
ccache -z
- name: Configure Celeritas
run: |
ln -fs scripts/cmake-presets/ci-ubuntu-github.json CMakeUserPresets.json
if [ "${{matrix.geant}}" == "11.0" ]; then
# Test overriding of Geant4 environment variables
. ${SPACK_VIEW}/rc
test -n "${G4LEDATA}"
fi
cmake --preset=${CMAKE_PRESET} --log-level=VERBOSE
- name: Run incremental clang-tidy
id: clang-tidy
if: ${{matrix.special == 'clang-tidy'}}
env:
BASE_REF: "${{format('{0}', github.base_ref || 'develop')}}"
run: |
if [ "${{github.event_name}}" == "schedule" ]; then
echo "Full clang-tidy check on scheduled run."
ninja -Cbuild -k0
exit $?
fi
BASE=$(git merge-base origin/${BASE_REF} HEAD)
ALL_FILES=$(git diff --name-only --diff-filter=ACM "$BASE" HEAD)
set +e
CC_FILES=$(grep -E '^(src|app|example)/.*\.cc$' - <<< "$ALL_FILES")
set -e
if [ -z "$CC_FILES" ]; then
echo "No files to run clang-tidy on."
exit 0
fi
echo "Running clang-tidy on: $CC_FILES"
${{env.CLANG_TIDY}} -p build $CC_FILES
exit $?
- name: Build all
id: build
if: ${{matrix.special != 'clang-tidy'}}
working-directory: build
run: |
ninja -v -k0
- name: Regenerate ROOT test data
if: ${{matrix.geant == '11.0'}}
working-directory: build
run: |
ninja -v -k0 update-root-test-data
- name: Run unit tests
id: unittest
if: ${{matrix.special != 'clang-tidy'}}
continue-on-error: ${{fromJSON(matrix.geant || '0') < 11}} # TODO: fix failing tests
run: |
if [ "${{matrix.geant}}" == "11.0" ]; then
# Note this is ignored for geant4, float, clhep
export CELER_TEST_STRICT=1
fi
ctest -LE app --preset=spack-unit
- name: Run app tests
id: apptest
if: ${{!cancelled()
&& matrix.special != 'clang-tidy'
&& steps.build.outcome == 'success'}}
continue-on-error: ${{matrix.geant == '10.6'}} # TODO: rogue output from G4DeexPrecoParameters
run: |
ctest -L app --preset=spack-app
- name: Upload test results
uses: actions/upload-artifact@v4
if: >-
${{
always()
&& (steps.unittest.outcome == 'success'
|| steps.unittest.outcome == 'failure')
&& (!matrix.geant || fromJSON(matrix.geant) >= 11)
}}
with:
name: test-results-spack-${{env.CMAKE_PRESET}}-${{matrix.geant}}
path: "test-output/**/*.xml"
if-no-files-found: error
retention-days: 1
- name: Check using build directory as install
# TODO: ASAN requires flags downstream
if: >-
${{
(matrix.special != 'asanlite')
&& (matrix.special != 'clang-tidy')
}}
run: |
. ${SPACK_VIEW}/rc
CELER_INSTALL_DIR=${PWD}/build ./scripts/ci/test-examples.sh
- name: Install
id: install
if: ${{!cancelled() && steps.build.outcome == 'success' && matrix.special != 'clang-tidy'}}
working-directory: build
run: |
ninja install
- name: Check installation
if: ${{steps.install.outcome == 'success'}}
working-directory: install
run: |
for exe in orange-update celer-export-geant celer-dump-data \
celer-sim celer-g4; do
test -x "bin/${exe}"
done
./bin/celer-sim --version
- name: Build examples
# TODO: ASAN requires flags downstream
env:
CELER_DISABLE_ACCEL_EXAMPLES: >-
${{
( (matrix.special == 'minimal')
|| (matrix.special == 'float')
) && '1' || ''
}}
if: >-
${{
(matrix.special != 'asanlite')
&& (matrix.special != 'clang-tidy')
}}
run: |
. ${SPACK_VIEW}/rc
./scripts/ci/test-examples.sh
- name: Show ccache stats
if: ${{!cancelled()}}
run: |
ccache -s
# vim: set nowrap tw=100: