Skip to content

Commit dd741e7

Browse files
committed
script/ptl-tool: add options to set distros/flavors/archs
See: https://github.com/ceph/ceph-build/tree/main/ceph-trigger-build#git-trailer-parameters Signed-off-by: Patrick Donnelly <[email protected]>
1 parent a350a5b commit dd741e7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/script/ptl-tool.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,16 @@ def build_branch(args):
440440
sys.exit(1)
441441
log.info("Labeled PR #{pr} {label}".format(pr=pr, label=label))
442442

443+
if args.distros or args.archs:
444+
message = "ceph-dev-pipeline: configure\n\n"
445+
if args.distros:
446+
message += f"DISTROS: {' '.join(args.distros)}\n"
447+
if args.archs:
448+
message += f"ARCHS: {' '.join(args.archs)}\n"
449+
if args.flavors:
450+
message += f"FLAVORS: {' '.join(args.flavors)}\n"
451+
G.git.commit('--allow-empty', '-m', message)
452+
443453
if args.stop_at_built:
444454
log.warning("Stopping execution (SIGSTOP) with built branch for further modification. Foreground when execution should resume (typically `fg`).")
445455
old_head = G.head.commit
@@ -540,6 +550,24 @@ def build_branch(args):
540550
r = session.post(endpoint, auth=gitauth(), data=json.dumps({'body':body}))
541551
log.debug(f"= {r}")
542552

553+
class SplitCommaAppendAction(argparse.Action):
554+
"""
555+
Custom action to split comma-separated values and append each
556+
part to the destination list. Handles multiple uses of the argument.
557+
"""
558+
559+
def __call__(self, parser, namespace, values, option_string=None):
560+
# 1. Get the list that's already stored in the namespace.
561+
# 'default=[]' in add_argument ensures this is always a list.
562+
current_list = getattr(namespace, self.dest)
563+
564+
# 2. Split the new value(s) by comma
565+
# Use strip() to remove any whitespace around items
566+
new_items = [item.strip() for item in values.split(',')]
567+
568+
# 3. Extend the existing list with the new items
569+
current_list.extend(new_items)
570+
543571
def main():
544572
parser = argparse.ArgumentParser(description="Ceph PTL tool")
545573
default_base = 'main'
@@ -557,6 +585,9 @@ def main():
557585
parser.add_argument('--branch-release', dest='branch_release', action='store', help='release name to embed in branch (for shaman)')
558586
parser.add_argument('--create-qa', dest='create_qa', action='store_true', help='create QA run ticket')
559587
parser.add_argument('--debug', dest='debug', action='store_true', help='turn debugging on')
588+
parser.add_argument('--distros', dest='distros', action=SplitCommaAppendAction, default=[], help='add distro(s) to build. Specify one or more times. Comma separated values are split.')
589+
parser.add_argument('--archs', dest='archs', action=SplitCommaAppendAction, default=[], help='add arch(s) to build. Specify one or more times. Comma separated values are split.')
590+
parser.add_argument('--flavors', dest='flavors', action=SplitCommaAppendAction, default=[], help='add flavors(s) to build. Specify one or more times. Comma separated values are split.')
560591
parser.add_argument('--debug-build', dest='debug_build', action='store_true', help='append -debug to branch name prompting ceph-build to build with CMAKE_BUILD_TYPE=Debug')
561592
parser.add_argument('--branch-name-append', dest='branch_append', action='store', help='append string to branch name')
562593
parser.add_argument('--git-dir', dest='git', action='store', default=git_dir, help='git directory')

0 commit comments

Comments
 (0)