Skip to content

Commit 81bbfd2

Browse files
committed
[ci] Simplify definition of builds requiring special configurations
Builds requiring special configurations can now be defined in the workflow definition file through the parameter "platform_config". The parsing of such options has been enhanced. In a nutshell: 1. If "platform_config" is not specified, the platform name is considered instead and the configuration file <platform>.txt is read. This is for compatibility with the previous behaviour. 2. If "platform_config" is specified, the file <platform_config>.txt file is read. 3. If the "minimal" option is specified in a platform configuration file, the global configuration (global.txt) is ignored. 4. If the option CMAKE_GENERATOR is specified in a platform configuration file, it will be properly passed through the "-G" CMake switch. Previously the value had to be specified as a workflow parameter and passed as an environment variable.
1 parent 3d01f17 commit 81bbfd2

File tree

9 files changed

+110
-56
lines changed

9 files changed

+110
-56
lines changed

.github/workflows/root-ci-config/build_root.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,36 @@ def main():
7474

7575
# Compute CMake build options:
7676
# - Get global options
77-
# - Override with options from .github/workflows/root-ci-config/buildconfig/[platform].txt
77+
# - Read options from .github/workflows/root-ci-config/buildconfig/[platform_config].txt
78+
# + If minimal is off, override the global options with the platform ones
79+
# + If minimal is on, ignore global options. The minimal options takes priority
7880
# - Apply overrides from command line if necessary
7981
options_dict = build_utils.load_config(f"{this_script_dir}/buildconfig/global.txt")
80-
last_options = dict(options_dict)
82+
last_options = dict(options_dict) # We need a copy
8183

82-
options_dict.update(build_utils.load_config(f"{this_script_dir}/buildconfig/{args.platform}.txt"))
83-
print(f"Build option overrides for {args.platform}:")
84-
build_utils.print_options_diff(options_dict, last_options)
84+
print(f"Loading configuration from file {args.platform_config}.txt")
85+
platform_options = build_utils.load_config(f"{this_script_dir}/buildconfig/{args.platform_config}.txt")
86+
87+
print("Platform options")
88+
for key, val in sorted(platform_options.items()):
89+
print(f"\t{key: <30}{val}")
90+
91+
if "minimal" in platform_options and platform_options["minimal"] == "ON":
92+
options_dict = platform_options
93+
print(f"Minimal build detected in the platform options. Ignoring global configuration.")
94+
else:
95+
options_dict.update(platform_options)
96+
print(f"Build option overrides for {args.platform_config}:")
97+
build_utils.print_options_diff(options_dict, last_options)
8598

8699
if args.overrides is not None:
87100
print("Build option overrides from command line:")
88101
last_options = dict(options_dict)
89-
options_dict.update((arg.split("=", maxsplit=1) for arg in args.overrides))
102+
def splitAndLowerCase(arg):
103+
key, val = arg.split("=", maxsplit=1)
104+
lowerVal = val.upper()
105+
return (key, lowerVal if lowerVal in ["ON", "OFF"] else val)
106+
options_dict.update(map(splitAndLowerCase , args.overrides))
90107
build_utils.print_options_diff(options_dict, last_options)
91108

92109
options = build_utils.cmake_options_from_dict(options_dict)
@@ -131,7 +148,7 @@ def main():
131148

132149
git_pull("src", args.repository, args.base_ref)
133150

134-
benchmark: bool = 'rootbench' in options_dict and options_dict['rootbench'].lower() == "on"
151+
benchmark: bool = 'rootbench' in options_dict and options_dict['rootbench'] == "ON"
135152
if benchmark:
136153
git_pull("rootbench", "https://github.com/root-project/rootbench", "master")
137154

@@ -143,7 +160,7 @@ def main():
143160

144161
rebase("src", "origin", base_head_sha, head_ref_dst, args.head_sha)
145162

146-
testing: bool = options_dict['testing'].lower() == "on"
163+
testing: bool = options_dict['testing'] == "ON"
147164

148165
if not WINDOWS:
149166
show_node_state()
@@ -201,6 +218,7 @@ def parse_args():
201218
# true/false for boolean arguments instead.
202219
parser = argparse.ArgumentParser()
203220
parser.add_argument("--platform", help="Platform to build on")
221+
parser.add_argument("--platform_config", default=None, help="The configuration for the platform", nargs='?', const='')
204222
parser.add_argument("--dockeropts", default=None, help="Extra docker options, if any")
205223
parser.add_argument("--incremental", default="false", help="Do incremental build")
206224
parser.add_argument("--buildtype", default="Release", help="Release|Debug|RelWithDebInfo")
@@ -226,6 +244,9 @@ def parse_args():
226244
if not args.base_ref:
227245
die(os.EX_USAGE, "base_ref not specified")
228246

247+
if not args.platform_config: # If nothing special, we take the standard platform configuration, called as the platform
248+
args.platform_config = args.platform
249+
229250
return args
230251

231252

.github/workflows/root-ci-config/build_utils.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ def load_config(filename) -> dict:
189189
key = split_line[0]
190190
val = split_line[1]+'='+split_line[2]
191191

192-
if val.lower() in ["on", "off"]:
193-
val = val.lower()
192+
val_upper = val.upper()
193+
val = val_upper if val_upper in ["ON", "OFF"] else val
194194

195195
options[key] = val
196196

@@ -204,19 +204,27 @@ def cmake_options_from_dict(config: Dict[str, str]) -> str:
204204
example: {"builtin_xrootd"="on", "alien"="on"}
205205
->
206206
'"-Dalien=on" -Dbuiltin_xrootd=on"'
207+
The key CMAKE_GENERATOR is used to set the CMake generator.
207208
"""
208209

209210
if not config:
210211
return ''
211212

212213
output = []
213214

215+
cmake_generator = None
214216
for key, value in config.items():
215-
output.append(f'"-D{key}={value}"')
217+
if key == "CMAKE_GENERATOR":
218+
cmake_generator = value
219+
else:
220+
output.append(f'"-D{key}={value}"')
216221

217222
output.sort()
223+
cmake_options = ' '.join(output)
224+
if cmake_generator:
225+
cmake_options += f'" -G{cmake_generator}"'
218226

219-
return ' '.join(output)
227+
return cmake_options
220228

221229
def calc_options_hash(options: str) -> str:
222230
"""Calculate the hash of the options string. If "march=native" is in the
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CMAKE_CXX_STANDARD=20
2+
builtin_vdt=ON
3+
builtin_zlib=ON
4+
builtin_zstd=ON
5+
pythia8=ON
6+
r=OFF
7+
rootbench=ON
8+
tmva-sofie=ON
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CMAKE_C_COMPILER=clang
2+
CMAKE_CXX_COMPILER=clang++
3+
CMAKE_GENERATOR=Ninja
4+
builtin_vdt=ON
5+
builtin_zlib=ON
6+
builtin_zstd=ON
7+
pythia8=ON
8+
r=OFF
9+
tmva-sofie=ON
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
ccache=ON
12
builtin_vdt=ON
23
builtin_zlib=ON
34
builtin_zstd=ON
5+
fail-on-missing=ON
6+
minimal=ON
7+
roottest=ON
8+
testing=ON
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CMAKE_CXX_FLAGS=-march=native
2+
CMAKE_C_FLAGS=-march=native
3+
CMAKE_CXX_STANDARD=20
4+
builtin_vc=ON
5+
builtin_vdt=ON
6+
builtin_veccore=ON
7+
builtin_zlib=ON
8+
builtin_zstd=ON
9+
pythia8=ON
10+
tmva-sofie=ON
11+
veccore=ON
12+
vc=ON
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
builtin_vdt=ON
2+
pythia8=ON
3+
runtime_cxxmodules=OFF
4+
tmva-sofie=ON

.github/workflows/root-ci-config/buildconfig/global-minimal.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/root-ci.yml

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,13 @@ jobs:
398398
- image: alma9
399399
is_special: true
400400
property: modules_off
401-
overrides: ["runtime_cxxmodules=Off", "CMAKE_CXX_STANDARD=20"]
401+
platform_config: "alma9-modules_off"
402+
overrides: ["CMAKE_CXX_STANDARD=20"]
402403
- image: alma9
403404
is_special: true
404405
property: march_native
405-
overrides: ["CMAKE_BUILD_TYPE=RelWithDebInfo", "CMAKE_CXX_FLAGS=-march=native", "CMAKE_C_FLAGS=-march=native", "builtin_zlib=ON", "builtin_zstd=ON", "CMAKE_CXX_STANDARD=20", "builtin_vc=ON", "builtin_veccore=ON", "vc=ON", "veccore=ON"]
406+
platform_config: "alma9-march_native"
407+
overrides: ["CMAKE_BUILD_TYPE=RelWithDebInfo"]
406408
- image: alma10
407409
is_special: true
408410
property: arm64
@@ -411,8 +413,8 @@ jobs:
411413
- image: alma10
412414
is_special: true
413415
property: "clang Ninja"
414-
overrides: ["CMAKE_C_COMPILER=clang", "CMAKE_CXX_COMPILER=clang++", "CMAKE_CXX_STANDARD=20"]
415-
cmake_generator: Ninja
416+
platform_config: "alma10-clang_ninja"
417+
overrides: ["CMAKE_CXX_STANDARD=20"]
416418
# Fedora Rawhide with Python debug build
417419
- image: rawhide
418420
is_special: true
@@ -421,14 +423,14 @@ jobs:
421423
# Minimal build
422424
- image: alma10
423425
is_special: true
424-
minimal: true
426+
platform_config: "alma10-minimal"
425427
property: "minimal build"
426428
overrides: ["CMAKE_CXX_STANDARD=20"]
427429
# Benchmark build
428430
- image: alma10
429431
is_special: true
432+
platform_config: "alma10-benchmark"
430433
property: "benchmark build"
431-
overrides: ["CMAKE_CXX_STANDARD=20", "rootbench=ON"]
432434
# Disable GPU builds until the DNS problem is solved
433435
# - image: ubuntu2404-cuda
434436
# is_special: true
@@ -501,19 +503,6 @@ jobs:
501503
run: 'printf "%s@%s\\n" "$(whoami)" "$(hostname)";
502504
ls -la
503505
'
504-
- name: Apply option minimal request from matrix for this job
505-
if: ${{ matrix.minimal == true }}
506-
env:
507-
GLOBAL_CONFIG_DIR: '.github/workflows/root-ci-config/buildconfig'
508-
CONFIGFILE_STEM: '.github/workflows/root-ci-config/buildconfig/${{ matrix.image }}'
509-
run: |
510-
echo "Applying minimal request options"
511-
# Add commands to apply minimal request options here
512-
set -x
513-
cp "$GLOBAL_CONFIG_DIR/global-minimal.txt" "$GLOBAL_CONFIG_DIR/global.txt"
514-
if [ -f "${CONFIGFILE_STEM}-minimal.txt" ]; then
515-
cp "${CONFIGFILE_STEM}-minimal.txt" "${CONFIGFILE_STEM}.txt"
516-
fi
517506

518507
- uses: root-project/gcc-problem-matcher-improved@main
519508
with:
@@ -524,11 +513,11 @@ jobs:
524513
env:
525514
INCREMENTAL: ${{ !contains(github.event.pull_request.labels.*.name, 'clean build') }}
526515
GITHUB_PR_ORIGIN: ${{ github.event.pull_request.head.repo.clone_url }}
527-
CMAKE_GENERATOR: ${{ matrix.cmake_generator }}
528516
OVERRIDES: ${{ join( matrix.overrides, ' ') }}
529517
run: ".github/workflows/root-ci-config/build_root.py
530518
--buildtype RelWithDebInfo
531519
--platform ${{ matrix.image }}
520+
--platform_config ${{ matrix.platform_config }}
532521
--dockeropts \"$CONTAINER_OPTIONS\"
533522
--incremental $INCREMENTAL
534523
--base_ref ${{ github.base_ref }}
@@ -543,37 +532,40 @@ jobs:
543532
- name: Workflow dispatch
544533
if: ${{ github.event_name == 'workflow_dispatch' && !matrix.is_special }}
545534
run: ".github/workflows/root-ci-config/build_root.py
546-
--buildtype ${{ inputs.buildtype }}
547-
--platform ${{ matrix.image }}
548-
--incremental ${{ inputs.incremental }}
549-
--base_ref ${{ inputs.base_ref }}
550-
--head_ref ${{ inputs.head_ref }}
551-
--binaries ${{ inputs.binaries }}
552-
--repository ${{ github.server_url }}/${{ github.repository }}
535+
--buildtype ${{ inputs.buildtype }}
536+
--platform ${{ matrix.image }}
537+
--platform_config ${{ matrix.platform_config }}
538+
--incremental ${{ inputs.incremental }}
539+
--base_ref ${{ inputs.base_ref }}
540+
--head_ref ${{ inputs.head_ref }}
541+
--binaries ${{ inputs.binaries }}
542+
--repository ${{ github.server_url }}/${{ github.repository }}
553543
"
554544

555545
- name: Nightly build
556546
if: github.event_name == 'schedule'
557547
run: ".github/workflows/root-ci-config/build_root.py
558-
--buildtype Release
559-
--platform ${{ matrix.image }}
560-
--incremental false
561-
--binaries true
562-
--base_ref ${{ inputs.ref_name }}
563-
--repository ${{ github.server_url }}/${{ github.repository }}
548+
--buildtype Release
549+
--platform ${{ matrix.image }}
550+
--platform_config ${{ matrix.platform_config }}
551+
--incremental false
552+
--binaries true
553+
--base_ref ${{ inputs.ref_name }}
554+
--repository ${{ github.server_url }}/${{ github.repository }}
564555
"
565556

566557
- name: Update build cache after push to release branch
567558
if: github.event_name == 'push'
568559
env:
569560
OVERRIDES: ${{ join( matrix.overrides, ' ') }}
570561
run: ".github/workflows/root-ci-config/build_root.py
571-
--buildtype RelWithDebInfo
572-
--platform ${{ matrix.image }}
573-
--incremental false
574-
--base_ref ${{ github.ref_name }}
575-
--binaries ${{ startsWith(github.ref, 'refs/tags/') }}
576-
--repository ${{ github.server_url }}/${{ github.repository }}
562+
--buildtype RelWithDebInfo
563+
--platform ${{ matrix.image }}
564+
--platform_config ${{ matrix.platform_config }}
565+
--incremental false
566+
--base_ref ${{ github.ref_name }}
567+
--binaries ${{ startsWith(github.ref, 'refs/tags/') }}
568+
--repository ${{ github.server_url }}/${{ github.repository }}
577569
--overrides ${GLOBAL_OVERRIDES} ${OVERRIDES}
578570
"
579571

0 commit comments

Comments
 (0)