-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
413 lines (378 loc) · 13.5 KB
/
.gitlab-ci.yml
File metadata and controls
413 lines (378 loc) · 13.5 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
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == "main"'
- if: '$CI_COMMIT_MESSAGE =~ /CI BUILD/'
- if: '$CI_COMMIT_MESSAGE =~ /SPACK BUILD/'
- if: '$FORCE_CI == "true"'
- if: '$FORCE_SPACK == "true"'
- when: never
stages:
- build
- test
- spack-test
variables:
CCACHE_BASEDIR: $CI_PROJECT_DIR
CCACHE_DIR: "${CI_BUILDS_DIR}/ccache"
GIT_CLEAN_FLAGS: none
cache:
- key: ccache-global
paths:
- $CCACHE_DIR
policy: pull-push
- key: spack-builds
paths:
- "${CI_BUILDS_DIR}/spack-cache"
when: on_success
# Check ccache integration first
check-ccache:
stage: build
script:
- |
echo "=== Checking ccache integration ==="
which ccache || echo "ccache not found in PATH"
ccache --version || echo "ccache not working"
echo "CMAKE_CXX_COMPILER_LAUNCHER: ${CMAKE_CXX_COMPILER_LAUNCHER:-not set}"
echo "CMAKE_C_COMPILER_LAUNCHER: ${CMAKE_C_COMPILER_LAUNCHER:-not set}"
echo "=== Checking Python version ==="
python3 --version || echo "python3 not found"
python3.11 --version || echo "python3.11 not found"
/usr/bin/python3.11 --version || echo "/usr/bin/python3.11 not found"
echo "=== Checking system info ==="
cat /etc/redhat-release
nproc
df -h ${CI_BUILDS_DIR}
rules:
- when: manual
allow_failure: true
build-job:
stage: build
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == "main"'
changes:
- "**/*"
- "!README.md"
- "!scripts/**/*"
- "!doc/**/*"
- "!spack-repo/**/*"
- if: '$CI_COMMIT_MESSAGE =~ /CI BUILD/'
- if: '$FORCE_CI == "true"'
- when: never
before_script:
# Ensure submodules are in sync with the index
- git submodule sync
- git submodule update --init --recursive
- export CCACHE_BASEDIR="$PWD"
- export CCACHE_COMPILERCHECK=content
- export CCACHE_MAXSIZE=5G
- mkdir -p $CCACHE_DIR
- if [ -d "$CCACHE_DIR" ] && [ "$(ls -A $CCACHE_DIR)" ]; then echo "Using existing ccache with $(ccache --show-stats | grep 'files in cache')"; else echo "Starting with empty ccache"; fi
- ccache --show-stats || true
- git clean -ffdx
# Create temporary Python virtual environment for building outside the Libra path
- export BUILD_VENV_DIR="${CI_BUILDS_DIR}/build_venv_${CI_PIPELINE_ID}"
- python3.11 --version
- python3.11 -m venv "${BUILD_VENV_DIR}"
- source "${BUILD_VENV_DIR}/bin/activate"
- pip install --upgrade pip setuptools wheel
- pip install pytest numpy
- python --version
- which python
script:
- echo "=== Compiling with ccache integration ==="
- source "${BUILD_VENV_DIR}/bin/activate"
- echo $PATH
- python --version
- nvidia-smi
- which nvcc
- mkdir -p build
- cd build
- cmake -DApps_BUILD_TESTS=ON -DNCORES=8 -DKokkos_CUDA_ARCH_NAME=Kokkos_ARCH_VOLTA70 ..
- make
after_script:
- echo "=== ccache statistics ==="
- ccache --show-stats || true
- ccache --show-config || true
test-job:
stage: test
needs:
- job: build-job
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == "main"'
changes:
- "**/*"
- "!README.md"
- "!scripts/**/*"
- "!doc/**/*"
- "!spack-repo/**/*"
- if: '$CI_COMMIT_MESSAGE =~ /CI BUILD/'
- if: '$FORCE_CI == "true"'
- when: never
script: |
# Ensure we are in the project root directory
cd "${CI_PROJECT_DIR}"
echo "Current working directory: $PWD"
base_path=$PWD
export LD_LIBRARY_PATH="${base_path}/install/lib:${LD_LIBRARY_PATH:-}"
export PYTHONPATH="${base_path}/install/lib:${PYTHONPATH:-}"
export BUILD_VENV_DIR="${CI_BUILDS_DIR}/build_venv_${CI_PIPELINE_ID}"
source "${BUILD_VENV_DIR}/bin/activate"
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
echo "PYTHONPATH: $PYTHONPATH"
mkdir -p ${base_path}/libra-python/reports
# Ensure libra-python is importable for pytest
export PYTHONPATH="${base_path}/libra-python:${PYTHONPATH:-}"
# Symlink test data if needed for both python and cpp tests
cd ${base_path}/libra-python
if [ -d "${base_path}/apps/src/tests/gold_standard" ] && [ ! -e "gold_standard" ]; then
ln -sf ../../apps/src/tests/gold_standard gold_standard
echo "Symlinked test data for tests"
fi
# --- C++ GTest section ---
cd ${base_path}/apps/src/tests/
# Run C++ gtest binaries if they exist
#test_binaries=("LibRATests" "test_roadrunner_robustMinus2" "test_roadrunner_robustPlus2" "test_roadrunner_snrpsf" "test_roadrunner_weight")
test_binaries=("LibRATests")
for test_binary in "${test_binaries[@]}"; do
if [ -x "${base_path}/install/bin/tests/${test_binary}" ]; then
echo "Running ${test_binary}..."
"${base_path}/install/bin/tests/${test_binary}" --gtest_output=xml:"${base_path}/libra-python/reports/cpp_${test_binary}_report.xml"
else
echo "C++ test binary not found: ${base_path}/install/bin/tests/${test_binary}"
fi
done
# --- Python pytest section ---
cd "${base_path}/apps/src/tests/"
pytest ${base_path}/libra-python/tests --junitxml=pytest_report.xml -v || echo "Pytest failed, but continuing for CI artifact collection"
artifacts:
when: always
reports:
junit:
- ${CI_PROJECT_DIR}/apps/src/tests/pytest_report.xml
- ${CI_PROJECT_DIR}/apps/src/tests/cpp_report.xml
expire_in: 1 week
after_script: |
echo "=== Test job completed ==="
echo "Current working directory: $PWD"
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
echo "PYTHONPATH: $PYTHONPATH"
echo "Python version: $(python --version)"
echo "CMake version: $(cmake --version)"
echo "ccache stats:"
ccache --show-stats || true
echo "=== Cleaning up venv ==="
rm -rf "${CI_BUILDS_DIR}/build_venv_${CI_PIPELINE_ID}"
rm -rf ${base_path}/libra-python/reports
rm -rf ${base_path}/cpp_test_dir
timeout: 1h
spack-test:
needs: []
stage: spack-test
variables:
SPACK_ROOT: "${CI_BUILDS_DIR}/spack-installs/spack-persistent"
SPACK_TEST_BASE_ENV: "spack-test-base"
LIBRA_TEST_ENV: "libra-test-${CI_PIPELINE_ID}"
SPACK_CACHE_DIR: "${CI_BUILDS_DIR}/spack-cache"
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- spack-repo/**/*
- if: '$CI_COMMIT_BRANCH == "main"'
changes:
- spack-repo/**/*
- when: manual
allow_failure: true
before_script:
# Ensure submodules are in sync with the index
- git submodule sync
- git submodule update --init --recursive
- echo "=== RHEL8 Spack Setup ==="
- cat /etc/redhat-release
- mkdir -p ${SPACK_ROOT}
- mkdir -p ${SPACK_CACHE_DIR}
- mkdir -p ${CI_BUILDS_DIR}/spack-installs
# Setup ccache for spack
- export CCACHE_DIR="${SPACK_CACHE_DIR}/ccache"
- export CCACHE_MAXSIZE=5G
- mkdir -p ${CCACHE_DIR}
# Create or reuse persistent Python virtual environment for spack
- export SPACK_VENV_DIR="${CI_BUILDS_DIR}/spack_venv_persistent"
- python3.11 --version
- |
if [ ! -d "${SPACK_VENV_DIR}" ]; then
echo "Creating persistent spack Python venv..."
python3.11 -m venv "${SPACK_VENV_DIR}"
source "${SPACK_VENV_DIR}/bin/activate"
pip install --upgrade pip setuptools wheel
else
echo "Using existing persistent spack Python venv..."
source "${SPACK_VENV_DIR}/bin/activate"
fi
- export PYTHON_CMD=$(which python)
- ${PYTHON_CMD} --version
# Clone spack if not exists
- |
if [ ! -d "${SPACK_ROOT}/.git" ]; then
echo "Cloning fresh spack..."
git clone --depth=1 --branch v1.0.0 https://github.com/spack/spack.git ${SPACK_ROOT}
else
echo "Using existing spack installation"
cd ${SPACK_ROOT} && git pull
fi
# Setup spack environment
- source ${SPACK_ROOT}/share/spack/setup-env.sh
# Use a minimal/vanilla spack config for RHEL8 (store config in ${SPACK_ROOT}/.spack, not ~/.spack)
- mkdir -p ${SPACK_ROOT}/.spack
- |
cat > ${SPACK_ROOT}/.spack/config.yaml << EOF
config: {}
EOF
- export SPACK_USER_CONFIG_PATH=${SPACK_ROOT}/.spack
# Show spack info
- spack debug report
script:
- source "${SPACK_VENV_DIR}/bin/activate"
- source ${SPACK_ROOT}/share/spack/setup-env.sh
# Add custom repo only if not already added
- |
if ! spack repo list | grep -q "${CI_PROJECT_DIR}/spack-repo"; then
spack repo add ${CI_PROJECT_DIR}/spack-repo
else
echo "Repo already added: ${CI_PROJECT_DIR}/spack-repo"
fi
- spack repo list
- spack list libra
# Check if persistent base environment exists, create if not
- |
if spack env list | grep -q "^${SPACK_TEST_BASE_ENV}$"; then
echo "Persistent base environment ${SPACK_TEST_BASE_ENV} already exists, reusing it"
else
echo "Creating persistent base environment ${SPACK_TEST_BASE_ENV}..."
spack env create ${SPACK_TEST_BASE_ENV}
spack env activate ${SPACK_TEST_BASE_ENV}
# Add all dependencies to base environment (everything except libra)
spack add kokkos+cuda+cuda_lambda+wrapper cuda_arch=70
spack add casacore~python
spack add cuda@12.2
spack add fftw@3.3.10:+openmp
spack add hpg@3.0.3:+cuda
spack add parafeed@1.1.4:
spack add py-pybind11@2.10.2:
spack add googletest@1.14.0:
spack add cmake@3.18:
spack add pkgconfig
spack add cfitsio
spack add blas
spack add lapack
spack add boost
spack add wcslib
spack add readline
spack add ncurses
# Concretize and install base environment
spack concretize -f
spack install --fail-fast --verbose --no-checksum
echo "Persistent base environment ${SPACK_TEST_BASE_ENV} created and installed"
fi
# Create job-specific libra test environment
- spack env create ${LIBRA_TEST_ENV}
- spack env activate ${LIBRA_TEST_ENV}
# Add only libra to this environment with appropriate CUDA constraint
- |
GCC_VERSION=$(gcc --version | head -n1 | grep -oP 'gcc \(.*\) \K[0-9]+')
if [ "$GCC_VERSION" = "8" ]; then
echo "Using CUDA 12.2 constraint for GCC 8.x"
spack add libra+cuda ^cuda@12.2
else
echo "Using latest CUDA for GCC $GCC_VERSION"
spack add libra+cuda
fi
# Concretize and install libra (fresh build each time)
- spack concretize -f
- spack install --fail-fast --verbose --no-checksum --no-cache
# Verify installation
- spack find libra
- spack find --deps libra
after_script: |
if [ -d "${SPACK_VENV_DIR}" ]; then
source "${SPACK_VENV_DIR}/bin/activate"
source ${SPACK_ROOT}/share/spack/setup-env.sh
fi
if [ "$CI_JOB_STATUS" = "success" ]; then
echo "=== Build succeeded - cleaning up job-specific test environment ==="
spack env remove --yes-to-all ${LIBRA_TEST_ENV} || true
echo "Spack environment ${LIBRA_TEST_ENV} removed"
echo "Persistent base environment ${SPACK_TEST_BASE_ENV} preserved for future runs"
else
echo "=== Build failed - preserving test environment for debugging ==="
echo "Test environment preserved: ${LIBRA_TEST_ENV}"
echo "To debug: source ${SPACK_ROOT}/share/spack/setup-env.sh && spack env activate ${LIBRA_TEST_ENV}"
fi
artifacts:
when: always
paths:
- ${SPACK_CACHE_DIR}
expire_in: 1 year
timeout: 3h
# Manual jobs (simplified)
manual-trigger:
stage: build
before_script:
# Ensure submodules are in sync with the index
- git submodule sync
- git submodule update --init --recursive
script:
- echo "Manual full build trigger initiated..."
- export CCACHE_BASEDIR="$PWD"
- export CCACHE_COMPILERCHECK=content
- export CCACHE_MAXSIZE=2G
- if [ -d "$CCACHE_DIR" ] && [ "$(ls -A $CCACHE_DIR)" ]; then echo "Using existing ccache"; else echo "No active ccache found"; fi
- mkdir -p $CCACHE_DIR
- ccache --show-stats || true
- git clean -ffdx
- mkdir -p build
- cd build
- cmake -DApps_BUILD_TESTS=ON -DKokkos_CUDA_ARCH_NAME=Kokkos_ARCH_VOLTA70 ..
- make -j$(nproc)
- ccache --show-stats || true
when: manual
only:
- branches
allow_failure: true
manual-cpu-only:
stage: build
rules:
- when: manual
allow_failure: true
before_script:
# Ensure submodules are in sync with the index
- git submodule sync
- git submodule update --init --recursive
- export CCACHE_BASEDIR="$PWD"
- export CCACHE_COMPILERCHECK=content
- export CCACHE_MAXSIZE=5G
- mkdir -p $CCACHE_DIR
- if [ -d "$CCACHE_DIR" ] && [ "$(ls -A $CCACHE_DIR)" ]; then echo "Using existing ccache with $(ccache --show-stats | grep 'files in cache')"; else echo "Starting with empty ccache"; fi
- ccache --show-stats || true
- git clean -ffdx
script:
- echo "=== CPU-only build with LIBRA_DISABLE_CUDA=ON ==="
- echo $PATH
- echo "=== System Info (CPU-only build) ==="
- nproc
- echo "=== Building without CUDA ==="
- mkdir -p build
- cd build
- cmake -DApps_BUILD_TESTS=ON -DNCORES=8 -DLIBRA_DISABLE_CUDA=ON ..
- make -j$(nproc)
after_script:
- echo "=== ccache statistics ==="
- ccache --show-stats || true
- ccache --show-config || true
manual-spack:
extends: spack-test
when: manual
rules:
- when: manual
allow_failure: true