Repository navigation
Expand file tree
/
Copy pathJenkinsfile
More file actions
305 lines (282 loc) · 9.99 KB
/
Copy pathJenkinsfile
File metadata and controls
305 lines (282 loc) · 9.99 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
//----------------------------------------------------------------------------------------------------------------------
// This declarative Jenkins pipeline encodes all the steps required for the nightly/continuous of a single platform.
// Other jobs may call this pipeline to execute the build, test and installation of a set platforms.
//
// Author: Pere Mato
// SPDX-FileCopyrightText: 2020 CERN
// SPDX-License-Identifier: Apache-2.0
//----------------------------------------------------------------------------------------------------------------------
pipeline {
parameters {
string(name: 'EXTERNALS', defaultValue: 'devAdePT/latest', description: 'LCG software stack in CVMFS')
choice(name: 'MODEL', choices: ['experimental', 'nightly', 'continuous'], description: 'CDash model')
choice(name: 'COMPILER', choices: ['gcc13', 'gcc11', 'gcc8', 'gcc10', 'clang10', 'native'])
choice(name: 'OS', choices: ['el9', 'centos7'])
choice(name: 'BUILDTYPE', choices: ['Release', 'Debug'])
string(name: 'LABEL', defaultValue: 'TeslaT4', description: 'Jenkins label for physical nodes or container image for docker')
string(name: 'ExtraCMakeOptions', defaultValue: '', description: 'CMake extra configuration options')
string(name: 'DOCKER_LABEL', defaultValue: 'docker-host-noafs', description: 'Label for the the nodes able to launch docker images')
string(name: 'ghprbActualCommit', description: 'Immutable PR commit SHA validated by GitHub Actions')
string(name: 'ghprbPullAuthorLogin', description: 'Author of the Pull Request (provided by GitHub)')
string(name: 'ghprbPullId', description: 'Pull Request id (provided by GitHub)')
}
environment {
CMAKE_SOURCE_DIR = 'AdePT'
CMAKE_BINARY_DIR = 'build'
CMAKE_INSTALL_PREFIX = 'install'
CUDA_CAPABILITY = '75'
BUILDTYPE = "${params.BUILDTYPE}"
}
agent none
options {
skipDefaultCheckout(true)
}
stages {
//------------------------------------------------------------------------------------------------------------------
//---Build & Test stages--------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
stage('Environment'){
steps {
setJobName()
}
}
stage('InDocker') {
when {
beforeAgent true
expression { params.LABEL =~ 'centos|ubuntu' }
}
agent {
docker {
image "gitlab-registry.cern.ch/sft/docker/$LABEL"
label "$DOCKER_LABEL"
args """-v /cvmfs:/cvmfs
-v /ec:/ec
-e SHELL
-e ghprbPullAuthorLogin
-e ghprbPullId
--net=host
--hostname ${LABEL}-docker
"""
}
}
stages {
stage('CheckoutPR') {
steps {
checkoutPrSource()
}
}
stage('CheckoutReference') {
when {
expression { params.ghprbPullId?.trim() }
}
steps {
checkoutReferenceSource()
}
}
stage('BuildPR') {
steps {
buildMatrixFromSource('build_pr_matrix', 'AdePT', 'BUILD')
}
}
stage('BuildReference') {
when {
expression { params.ghprbPullId?.trim() }
}
steps {
buildMatrixFromSource('build_master_reference_matrix', 'AdePT_master_reference', 'BUILD_MASTER_REFERENCE')
}
}
stage('Test') {
steps {
runTestsForBuiltMatrices()
}
}
}
post {
success {
deleteDir()
}
}
}
stage('InBareMetal') {
when {
beforeAgent true
expression { params.LABEL =~ 'cuda|physical|TeslaT4' }
}
agent {
label "$LABEL-$OS"
}
stages {
stage('PreCheckNode') {
steps {
preCheckNode()
}
}
stage('CheckoutPR') {
steps {
checkoutPrSource()
}
}
stage('CheckoutReference') {
when {
expression { params.ghprbPullId?.trim() }
}
steps {
checkoutReferenceSource()
}
}
stage('BuildPR') {
steps {
buildMatrixFromSource('build_pr_matrix', 'AdePT', 'BUILD')
}
}
stage('BuildReference') {
when {
expression { params.ghprbPullId?.trim() }
}
steps {
buildMatrixFromSource('build_master_reference_matrix', 'AdePT_master_reference', 'BUILD_MASTER_REFERENCE')
}
}
stage('Test') {
steps {
runTestsForBuiltMatrices()
}
}
}
post {
success {
deleteDir()
}
}
}
}
}
//----------------------------------------------------------------------------------------------------------------------
//---Common Functions---------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
def setJobName() {
if (params.ghprbPullId) {
currentBuild.displayName = "#${BUILD_NUMBER}" + '-' + params.ghprbPullAuthorLogin + '#' + params.ghprbPullId + '-' + params.COMPILER + '-' + params.BUILDTYPE
}
else {
currentBuild.displayName = "#${BUILD_NUMBER}" + ' ' + params.COMPILER + '-' + params.BUILDTYPE
}
}
def preCheckNode() {
def deviceQuery = '/usr/local/cuda/extras/demo_suite/deviceQuery'
sh (script: '/usr/bin/nvidia-smi')
if (fileExists(deviceQuery)) {
def dev_out = sh (script: deviceQuery, returnStdout: true)
env.CUDA_CAPABILITY = ( dev_out =~ 'CUDA Capability.*([0-9]+[.][0-9]+)')[0][1].replace('.','')
print('Cuda capability version is = ' + env.CUDA_CAPABILITY)
}
}
def withLcgEnvScript(String body) {
return """
set +x
source /cvmfs/sft.cern.ch/lcg/views/${EXTERNALS}/x86_64-${OS}-${COMPILER}-opt/setup.sh
set -x
export CUDA_CAPABILITY=${env.CUDA_CAPABILITY}
${body}
"""
}
def runWithLcgEnv(String stepLabel, String body) {
sh label: stepLabel, script: withLcgEnvScript(body)
}
def runWithLcgEnvStatus(String stepLabel, String body) {
return sh(label: stepLabel, returnStatus: true, script: withLcgEnvScript(body))
}
def runLabeledCiTest(String stepLabel, String binaryDir, String includeLabel) {
runWithLcgEnv(stepLabel, """
export CMAKE_SOURCE_DIR="\$PWD/AdePT"
export CMAKE_BINARY_DIR="${binaryDir}"
export CTEST_INCLUDE_LABEL="${includeLabel}"
ctest -V --output-on-failure -S "\$PWD/AdePT/jenkins/adept-ctest-ci.cmake,\$MODEL"
""")
}
def runBuildMatrix(String stepLabel, String sourceDir, String buildPrefix) {
runWithLcgEnv(stepLabel, """
run_build_slot() {
local source_dir=\$1
local binary_dir=\$2
shift 2
local extra_opts="\$*"
export CMAKE_SOURCE_DIR="\${source_dir}"
export CMAKE_BINARY_DIR="\${binary_dir}"
export ExtraCMakeOptions="-DADEPT_BUILD_TESTING=ON \${extra_opts}"
ctest -V --output-on-failure -S "\$PWD/AdePT/jenkins/adept-ctest-build.cmake,\$MODEL"
}
run_build_slot "${sourceDir}" "\$PWD/${buildPrefix}_MONOL"
run_build_slot "${sourceDir}" "\$PWD/${buildPrefix}_SPLIT_ON" "-DADEPT_USE_SPLIT_KERNELS=ON"
run_build_slot "${sourceDir}" "\$PWD/${buildPrefix}_MIXED_PRECISION" "-DADEPT_MIXED_PRECISION=ON"
""")
}
def checkoutPrSource() {
// `checkout scm` already carries the job-configured target dir (AdePT),
// so run it at workspace root to avoid nesting into AdePT/AdePT.
deleteDir()
checkout scm
dir('AdePT') {
sh 'git submodule update --init'
if (params.ghprbActualCommit?.trim()) {
sh """
actual_commit=\$(git rev-parse HEAD)
expected_commit="${params.ghprbActualCommit}"
echo "Checked out PR commit: \${actual_commit}"
echo "Expected PR commit: \${expected_commit}"
if [ "\${actual_commit}" != "\${expected_commit}" ]; then
echo "ERROR: Jenkins checked out a different PR commit than the one validated by GitHub Actions." >&2
exit 1
fi
"""
}
}
}
def checkoutReferenceSource() {
def remoteConfig = [url: scm.userRemoteConfigs[0].url]
if (scm.userRemoteConfigs[0].credentialsId) {
remoteConfig.credentialsId = scm.userRemoteConfigs[0].credentialsId
}
dir('AdePT_master_reference') {
deleteDir()
checkout([
$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
userRemoteConfigs: [remoteConfig]
])
sh 'git submodule update --init'
}
}
def buildMatrixFromSource(String stepLabel, String sourceSubdir, String buildPrefix) {
runBuildMatrix(stepLabel, "\$PWD/${sourceSubdir}", buildPrefix)
}
def runTestsForBuiltMatrices() {
boolean isPrBuild = params.ghprbPullId?.trim()
boolean runValidationTests = true
if (isPrBuild) {
def driftStatus = runWithLcgEnvStatus('physics_drift', """
bash "\$PWD/AdePT/jenkins/run_physics_drift_tests.sh" \\
"\$PWD" \\
"\$MODEL"
""")
if (driftStatus != 0) {
unstable('physics_drift differences detected against master (non-blocking)')
runValidationTests = true
} else if (params.MODEL == 'nightly') {
runValidationTests = true
echo 'physics_drift passed, but this is a nightly model: running validation.'
} else {
runValidationTests = false
echo 'physics_drift passed: skipping validation tests for this PR build.'
}
}
runLabeledCiTest('run_unit_tests', '$PWD/BUILD_MONOL', 'unit')
if (runValidationTests) {
runLabeledCiTest('run_validation_monol', '$PWD/BUILD_MONOL', 'validation')
runLabeledCiTest('run_validation_split', '$PWD/BUILD_SPLIT_ON', 'validation')
} else {
echo 'Validation tests skipped because PR physics drift matched master exactly.'
}
}