Skip to content

Commit e36e5e2

Browse files
committed
ci: Deduplicate SCM checkouts
1 parent 0de23a3 commit e36e5e2

3 files changed

Lines changed: 112 additions & 89 deletions

File tree

FairRoot_doxygen_test.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
################################################################################
2-
# Copyright (C) 2020-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
2+
# Copyright (C) 2020-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
33
# #
44
# This software is distributed under the terms of the #
55
# GNU Lesser General Public Licence (LGPL) version 3, #
@@ -76,6 +76,6 @@ endif()
7676
ctest_submit()
7777

7878
if (web_url)
79-
file(WRITE "build/generated-doxygen.url" "${web_url}")
79+
file(WRITE "${CTEST_BINARY_DIRECTORY}/generated-doxygen.url" "${web_url}")
8080
message(STATUS " Created Doxygen URL ..: ${web_url}")
8181
endif()

Jenkinsfile

Lines changed: 103 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,83 @@
11
#!groovy
22

3-
def jobMatrix(String prefix, String type, List specs) {
3+
def macos_builds = [
4+
[os: "macos", ver: "13", arch: "x86_64", compiler: "apple-clang-14", fairsoft: "24.01"],
5+
[os: "macos", ver: "14", arch: "x86_64", compiler: "apple-clang-14", fairsoft: "24.01"],
6+
[os: "macos", ver: "14", arch: "arm64", compiler: "apple-clang-15", fairsoft: "24.01"],
7+
]
8+
9+
def linux_builds = [
10+
[os: "debian", ver: "10", compiler: "gcc-8", fairsoft: "jan24_patches", image: "jan24"],
11+
[os: "debian", ver: "10", compiler: "gcc-8", fairsoft: "jan24_patches_mt", image: "jan24"],
12+
[os: "debian", ver: "10", compiler: "gcc-8", fairsoft: "nov22_patches", image: "nov22"],
13+
[os: "debian", ver: "10", compiler: "gcc-8", fairsoft: "apr22_patches", image: "apr22"],
14+
[os: "debian", ver: "11", compiler: "gcc-10", fairsoft: "jan24_patches", image: "jan24"],
15+
[os: "debian", ver: "11", compiler: "gcc-10", fairsoft: "jan24_patches_mt", image: "jan24"],
16+
[os: "debian", ver: "11", compiler: "gcc-10", fairsoft: "nov22_patches", image: "nov22"],
17+
[os: "debian", ver: "11", compiler: "gcc-10", fairsoft: "apr22_patches", image: "apr22"],
18+
[os: "debian", ver: "12", compiler: "gcc-12", fairsoft: "jan24_patches", image: "jan24"],
19+
[os: "debian", ver: "12", compiler: "gcc-12", fairsoft: "jan24_patches_mt", image: "jan24"],
20+
[os: "debian", ver: "12", compiler: "gcc-12", fairsoft: "nov22_patches", image: "nov22"],
21+
[os: "fedora", ver: "39", compiler: "gcc-13", fairsoft: "jan24_patches", image: "jan24"],
22+
[os: "fedora", ver: "39", compiler: "gcc-13", fairsoft: "jan24_patches_mt", image: "jan24"],
23+
[os: "ubuntu", ver: "20.04", compiler: "gcc-9", fairsoft: "jan24_patches", image: "jan24"],
24+
[os: "ubuntu", ver: "20.04", compiler: "gcc-9", fairsoft: "jan24_patches_mt", image: "jan24"],
25+
[os: "ubuntu", ver: "20.04", compiler: "gcc-9", fairsoft: "nov22_patches", image: "nov22"],
26+
[os: "ubuntu", ver: "20.04", compiler: "gcc-9", fairsoft: "apr22_patches", image: "apr22"],
27+
[os: "ubuntu", ver: "22.04", compiler: "gcc-11", fairsoft: "jan24_patches", image: "jan24"],
28+
[os: "ubuntu", ver: "22.04", compiler: "gcc-11", fairsoft: "jan24_patches_mt", image: "jan24"],
29+
[os: "ubuntu", ver: "22.04", compiler: "gcc-11", fairsoft: "nov22_patches", image: "nov22"],
30+
[os: "ubuntu", ver: "22.04", compiler: "gcc-11", fairsoft: "apr22_patches", image: "apr22"],
31+
[os: "ubuntu", ver: "rolling", compiler: "current", fairsoft: "dev", check: "warnings",
32+
extra: "-DUSE_CLANG_TIDY=ON -DBUILD_MBS=OFF -DBUILD_PROOF_SUPPORT=OFF"],
33+
]
34+
35+
def linux_checks = [
36+
[os: 'ubuntu', ver: 'rolling', compiler: 'current', fairsoft: 'dev', check: 'doxygen'],
37+
]
38+
39+
if (env.CHANGE_ID != null) { // only run checks for PRs
40+
linux_checks += [
41+
[os: "ubuntu", ver: "rolling", compiler: "current", fairsoft: "dev", check: "format"]
42+
]
43+
}
44+
45+
def jobMatrix(String type, String sourcedir, List specs) {
446
def nodes = [:]
547
for (spec in specs) {
6-
def job = ''
48+
def arch = spec.getOrDefault("arch", "x86_64")
49+
def check = spec.getOrDefault("check", null)
50+
def extra = spec.getOrDefault("extra", null)
51+
def image = spec.getOrDefault("image", null)
52+
def fairsoft = spec.fairsoft
53+
def os = spec.os
54+
def ver = spec.ver
55+
def compiler = spec.compiler
56+
def selector = "${os}-${ver}-${arch}"
57+
def label = ""
758
switch(type) {
8-
case 'build':
9-
job = "${spec.os}-${spec.ver}-${spec.arch}-${spec.compiler}-fairsoft-${spec.fairsoft}"
59+
case "build":
60+
label = "${os}-${ver}-${arch} ${compiler} ${fairsoft}"
1061
break
11-
case 'check':
12-
job = spec.check
62+
case "check":
63+
label = "Check ${check}"
1364
break
1465
}
15-
def label = "${type}/${job}"
16-
def selector = "${spec.os}-${spec.ver}-${spec.arch}"
17-
def fairsoft = spec.fairsoft
18-
def os = spec.os
19-
def ver = spec.ver
20-
def arch = spec.arch
21-
def check = spec.getOrDefault("check", null)
22-
def extra = spec.getOrDefault("extra", null)
23-
def image = spec.getOrDefault("image", null)
2466

2567
nodes[label] = {
2668
node(selector) {
27-
githubNotify(context: "${prefix}/${label}", description: 'Building ...', status: 'PENDING')
28-
def logpattern = 'build/Testing/Temporary/*.log'
69+
githubNotify(context: "${label}", description: "Building ...", status: "PENDING")
2970
try {
30-
deleteDir()
31-
checkout scm
71+
if (!sourcedir) {
72+
deleteDir()
73+
checkout scm
74+
sourcedir = pwd()
75+
}
76+
def builddir = "build-${os}-${ver}-${arch}-${fairsoft}"
77+
def builddir_abs = "${pwd()}/${builddir}"
78+
echo "Source dir: ${sourcedir}"
79+
echo "Build dir: ${builddir_abs}"
80+
def logpattern = "${builddir}/Testing/Temporary/*.log"
3281

3382
if (check == "warnings" || check == "doxygen") {
3483
discoverGitReferenceBuild()
@@ -38,16 +87,17 @@ def jobMatrix(String prefix, String type, List specs) {
3887
// mineRepository()
3988
}
4089

41-
def jobscript = 'job.sh'
42-
def ctestcmd = "ctest -S FairRoot_${type}_test.cmake -V --output-on-failure"
90+
def jobscript = "${pwd()}/job.sh"
91+
def ctestcmd = "ctest -S ${sourcedir}/FairRoot_${type}_test.cmake -V --output-on-failure"
4392
sh "echo \"set -e\" >> ${jobscript}"
44-
if (type == 'check') {
45-
ctestcmd = "ctest -S FairRoot_${check}_test.cmake -VV"
93+
if (type == "check") {
94+
ctestcmd = "ctest -S ${sourcedir}/FairRoot_${check}_test.cmake -VV"
4695
sh "echo \"export FAIRROOT_FORMAT_BASE=origin/\${CHANGE_TARGET}\" >> ${jobscript}"
4796
}
4897
if (extra) {
4998
ctestcmd = ctestcmd + " " + extra
5099
}
100+
ctestcmd += " -DCTEST_SOURCE_DIRECTORY='${sourcedir}' -DCTEST_BINARY_DIRECTORY='${builddir_abs}'"
51101
if (selector =~ /^macos/) {
52102
// sh "echo \"export SIMPATH=\$(brew --prefix fairsoft)\" >> ${jobscript}"
53103
} else {
@@ -64,14 +114,17 @@ def jobMatrix(String prefix, String type, List specs) {
64114
container = "${os}.${ver}.${image}.sif"
65115
}
66116
sh(label: "Create Slurm Job Script", script: """
67-
exec tests/ci/slurm-create-jobscript.sh "${label}" "${container}" "${jobscript}" ${ctestcmd}
117+
exec ${sourcedir}/tests/ci/slurm-create-jobscript.sh "${label}" "${container}" "${jobscript}" ${ctestcmd}
68118
""")
69-
sh "./tests/ci/slurm-submit.sh \"FairRoot \${JOB_BASE_NAME} ${label}\" ${jobscript}"
119+
dir(sourcedir) {
120+
sh "tests/ci/slurm-submit.sh \"FairRoot \${JOB_BASE_NAME} ${label}\" ${jobscript}"
121+
}
70122
}
123+
71124
if (check == "warnings") {
72125
recordIssues(tools: [clangTidy(pattern: logpattern)],
73-
filters: [excludeFile('build/.*/G__.*[.]cxx'), excludeFile('third_party/.*')],
74-
qualityGates: [[threshold: 4, type: 'NEW', unstable: true]],
126+
filters: [excludeFile("build.*/.*/G__.*[.]cxx"), excludeFile("third_party/.*")],
127+
qualityGates: [[threshold: 4, type: "NEW", unstable: true]],
75128
ignoreFailedBuilds: false,
76129
skipBlames: true)
77130
archiveArtifacts(artifacts: logpattern, allowEmptyArchive: true, fingerprint: true)
@@ -80,20 +133,20 @@ def jobMatrix(String prefix, String type, List specs) {
80133
recordIssues(tools: [doxygen()],
81134
ignoreFailedBuilds: false,
82135
skipBlames: true)
83-
def result_url = readFile(file: 'build/generated-doxygen.url')
84-
publishChecks(name: 'Doxygen-Preview',
85-
title: 'Doxygen Preview',
136+
def result_url = readFile(file: "${builddir_abs}/generated-doxygen.url")
137+
publishChecks(name: "Doxygen-Preview",
138+
title: "Doxygen Preview",
86139
summary: result_url)
87140
}
88141

89142
deleteDir()
90-
githubNotify(context: "${prefix}/${label}", description: 'Success', status: 'SUCCESS')
143+
githubNotify(context: "${label}", description: "Success", status: "SUCCESS")
91144
} catch (e) {
92145
if (check == "warnings") {
93146
archiveArtifacts(artifacts: logpattern, allowEmptyArchive: true, fingerprint: true)
94147
}
95148
deleteDir()
96-
githubNotify(context: "${prefix}/${label}", description: 'Error', status: 'ERROR')
149+
githubNotify(context: "${label}", description: "Error", status: "ERROR")
97150
throw e
98151
}
99152
}
@@ -102,56 +155,22 @@ def jobMatrix(String prefix, String type, List specs) {
102155
return nodes
103156
}
104157

105-
pipeline{
106-
agent none
107-
stages {
108-
stage("Run CI Matrix") {
109-
steps{
110-
script {
111-
def builds = jobMatrix('alfa-ci', 'build', [
112-
[os: 'debian', ver: '10', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'jan24_patches', image: 'jan24'],
113-
[os: 'debian', ver: '10', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'jan24_patches_mt', image: 'jan24'],
114-
[os: 'debian', ver: '10', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'nov22_patches', image: 'nov22'],
115-
[os: 'debian', ver: '10', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'apr22_patches', image: 'apr22'],
116-
[os: 'debian', ver: '11', arch: 'x86_64', compiler: 'gcc-10', fairsoft: 'jan24_patches', image: 'jan24'],
117-
[os: 'debian', ver: '11', arch: 'x86_64', compiler: 'gcc-10', fairsoft: 'jan24_patches_mt', image: 'jan24'],
118-
[os: 'debian', ver: '11', arch: 'x86_64', compiler: 'gcc-10', fairsoft: 'nov22_patches', image: 'nov22'],
119-
[os: 'debian', ver: '11', arch: 'x86_64', compiler: 'gcc-10', fairsoft: 'apr22_patches', image: 'apr22'],
120-
[os: 'debian', ver: '12', arch: 'x86_64', compiler: 'gcc-12', fairsoft: 'jan24_patches', image: 'jan24'],
121-
[os: 'debian', ver: '12', arch: 'x86_64', compiler: 'gcc-12', fairsoft: 'jan24_patches_mt', image: 'jan24'],
122-
[os: 'debian', ver: '12', arch: 'x86_64', compiler: 'gcc-12', fairsoft: 'nov22_patches', image: 'nov22'],
123-
[os: 'fedora', ver: '39', arch: 'x86_64', compiler: 'gcc-13', fairsoft: 'jan24_patches', image: 'jan24'],
124-
[os: 'fedora', ver: '39', arch: 'x86_64', compiler: 'gcc-13', fairsoft: 'jan24_patches_mt', image: 'jan24'],
125-
[os: 'ubuntu', ver: '20.04', arch: 'x86_64', compiler: 'gcc-9', fairsoft: 'jan24_patches', image: 'jan24'],
126-
[os: 'ubuntu', ver: '20.04', arch: 'x86_64', compiler: 'gcc-9', fairsoft: 'jan24_patches_mt', image: 'jan24'],
127-
[os: 'ubuntu', ver: '20.04', arch: 'x86_64', compiler: 'gcc-9', fairsoft: 'nov22_patches', image: 'nov22'],
128-
[os: 'ubuntu', ver: '20.04', arch: 'x86_64', compiler: 'gcc-9', fairsoft: 'apr22_patches', image: 'apr22'],
129-
[os: 'ubuntu', ver: '22.04', arch: 'x86_64', compiler: 'gcc-11', fairsoft: 'jan24_patches', image: 'jan24'],
130-
[os: 'ubuntu', ver: '22.04', arch: 'x86_64', compiler: 'gcc-11', fairsoft: 'jan24_patches_mt', image: 'jan24'],
131-
[os: 'ubuntu', ver: '22.04', arch: 'x86_64', compiler: 'gcc-11', fairsoft: 'nov22_patches', image: 'nov22'],
132-
[os: 'ubuntu', ver: '22.04', arch: 'x86_64', compiler: 'gcc-11', fairsoft: 'apr22_patches', image: 'apr22'],
133-
[os: 'ubuntu', ver: 'rolling', arch: 'x86_64', compiler: 'current', fairsoft: 'dev',
134-
check: 'warnings',
135-
extra: '-DUSE_CLANG_TIDY=ON -DBUILD_MBS=OFF -DBUILD_PROOF_SUPPORT=OFF'],
136-
[os: 'macos', ver: '13', arch: 'x86_64', compiler: 'apple-clang-14', fairsoft: '24.01'],
137-
[os: 'macos', ver: '14', arch: 'x86_64', compiler: 'apple-clang-14', fairsoft: '24.01'],
138-
[os: 'macos', ver: '14', arch: 'arm64', compiler: 'apple-clang-15', fairsoft: '24.01'],
139-
])
158+
def linux_source = ""
140159

141-
def checks = jobMatrix('alfa-ci', 'check', [
142-
[os: 'ubuntu', ver: 'rolling', arch: 'x86_64', compiler: 'current', fairsoft: 'dev',
143-
check: 'doxygen'],
144-
])
145-
if (env.CHANGE_ID != null) { // only run checks for PRs
146-
checks += jobMatrix('alfa-ci', 'check', [
147-
[os: 'ubuntu', ver: 'rolling', arch: 'x86_64', compiler: 'current', fairsoft: 'dev',
148-
check: 'format'],
149-
])
150-
}
151-
152-
parallel(checks + builds)
153-
}
154-
}
155-
}
156-
}
157-
}
160+
pipeline {
161+
agent none
162+
options { skipDefaultCheckout() }
163+
stages { stage("CI") { parallel {
164+
stage("Linux") {
165+
agent { label "slurm" }
166+
stages {
167+
stage("SCM Checkout") {
168+
steps {
169+
checkout scm
170+
script { linux_source = pwd() }
171+
echo "Source dir: ${linux_source}" } }
172+
stage("Builds and Checks") {
173+
steps { script { parallel( jobMatrix("check", linux_source, linux_checks)
174+
+ jobMatrix("build", linux_source, linux_builds)) } }
175+
post { always { dir(linux_source) { deleteDir() } } } } } }
176+
stage("macOS") { steps { script { parallel(jobMatrix("build", null, macos_builds)) } } } } } } }

cmake/private/Testlib.cmake

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
################################################################################
2-
# Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
2+
# Copyright (C) 2020-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
33
# #
44
# This software is distributed under the terms of the #
55
# GNU Lesser General Public Licence (LGPL) version 3, #
@@ -9,8 +9,12 @@
99
macro(fairroot_ctest_setup)
1010
cmake_host_system_information(RESULT fqdn QUERY FQDN)
1111

12-
set(CTEST_SOURCE_DIRECTORY .)
13-
set(CTEST_BINARY_DIRECTORY build)
12+
if(NOT CTEST_SOURCE_DIRECTORY)
13+
set(CTEST_SOURCE_DIRECTORY .)
14+
endif()
15+
if(NOT CTEST_BINARY_DIRECTORY)
16+
set(CTEST_BINARY_DIRECTORY build)
17+
endif()
1418
set(CTEST_PROJECT_NAME "FairRoot")
1519
set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
1620
set(CTEST_USE_LAUNCHERS ON)

0 commit comments

Comments
 (0)