Skip to content

Commit 2543245

Browse files
authored
Merge pull request ClickHouse#80180 from ClickHouse/ci_praktika_support_for_wf_choice_input
CI: praktika to support choice type in workflow input
2 parents 475f706 + fd0236b commit 2543245

File tree

6 files changed

+33
-10
lines changed

6 files changed

+33
-10
lines changed

ci/praktika/info.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ def is_merge_queue_event(self):
113113
def is_push_event(self):
114114
return self.env.EVENT_TYPE == "push"
115115

116+
@property
117+
def is_dispatch_event(self):
118+
return self.env.EVENT_TYPE == "dispatch"
119+
116120
@property
117121
def instance_lifecycle(self):
118122
return self.env.INSTANCE_LIFE_CYCLE

ci/praktika/job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def parametrize(
9292
== len(timeout)
9393
== len(provides)
9494
== len(requires)
95-
), f"Parametrization lists must be of the same size [{len(parameter)}, {len(runs_on)}, {len(timeout)}, {len(provides)}, {len(requires)}]"
95+
), f"Parametrization lists for job [{self.name}] must be of the same size [{len(parameter)}, {len(runs_on)}, {len(timeout)}, {len(provides)}, {len(requires)}]"
9696

9797
res = []
9898
for parameter_, runs_on_, timeout_, provides_, requires_ in zip(

ci/praktika/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def generate_local_run_environment(workflow, job, pr=None, sha=None):
3636
BRANCH="branch_name",
3737
SHA=sha or Shell.get_output("git rev-parse HEAD"),
3838
PR_NUMBER=pr or -1,
39-
EVENT_TYPE="",
39+
EVENT_TYPE=workflow.event,
4040
JOB_OUTPUT_STREAM="",
4141
EVENT_FILE_PATH="",
4242
CHANGE_URL="",

ci/praktika/validator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def validate(cls):
5656
for job in workflow.jobs:
5757
cls.evaluate_check(
5858
isinstance(job, Job.Config),
59-
f"Invalid job type [{job}]",
59+
f"Invalid job type [{job}]: type [{type(job)}]",
6060
workflow.name,
6161
)
6262

@@ -158,7 +158,7 @@ def validate(cls):
158158
artifact.is_s3_artifact()
159159
), f"All artifacts must be of S3 type if enable_cache|enable_html=True, artifact [{artifact.name}], type [{artifact.type}], workflow [{workflow.name}]"
160160

161-
if workflow.dockers:
161+
if workflow.dockers and not workflow.disable_dockers_build:
162162
assert (
163163
Settings.DOCKERHUB_USERNAME
164164
), f"Settings.DOCKERHUB_USERNAME must be provided if workflow has dockers, workflow [{workflow.name}]"

ci/praktika/workflow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,4 @@ class InputConfig:
107107
description: str
108108
is_required: bool
109109
default_value: str
110+
options: Optional[List] = None

ci/praktika/yaml_generator.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ class Templates:
112112
default: {DEFAULT_VALUE}\
113113
"""
114114

115+
TEMPLATE_OPTIONS_INPUT = """
116+
{NAME}:
117+
description: {DESCRIPTION}
118+
type: choice
119+
options: {OPTIONS}
120+
default: {DEFAULT_VALUE}\
121+
"""
122+
115123
TEMPLATE_SECRET_CONFIG = """\
116124
{SECRET_NAME}:
117125
required: true
@@ -378,12 +386,22 @@ def generate(self):
378386
# for dispatch workflows only
379387
dispatch_inputs = ""
380388
for input_item in self.workflow_config.dispatch_inputs:
381-
dispatch_inputs += YamlGenerator.Templates.TEMPLATE_INPUT.format(
382-
NAME=input_item.name,
383-
DESCRIPTION=input_item.description,
384-
IS_REQUIRED="true" if input_item.is_required else "false",
385-
DEFAULT_VALUE=input_item.default_value or "''",
386-
)
389+
if not input_item.options:
390+
dispatch_inputs += YamlGenerator.Templates.TEMPLATE_INPUT.format(
391+
NAME=input_item.name,
392+
DESCRIPTION=input_item.description,
393+
IS_REQUIRED="true" if input_item.is_required else "false",
394+
DEFAULT_VALUE=input_item.default_value or "''",
395+
)
396+
else:
397+
dispatch_inputs += (
398+
YamlGenerator.Templates.TEMPLATE_OPTIONS_INPUT.format(
399+
NAME=input_item.name,
400+
DESCRIPTION=input_item.description,
401+
OPTIONS=input_item.options,
402+
DEFAULT_VALUE=input_item.default_value or "''",
403+
)
404+
)
387405

388406
if self.workflow_config.event in (
389407
Workflow.Event.PULL_REQUEST,

0 commit comments

Comments
 (0)