Skip to content

Commit

Permalink
Merge pull request ClickHouse#64950 from ClickHouse/ci_more_fixes_for…
Browse files Browse the repository at this point in the history
…_sync_prs

CI: Minor fixes in ci scripts
  • Loading branch information
maxknv authored Jun 7, 2024
2 parents 2da27f4 + 367d41e commit b618b80
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 11 deletions.
6 changes: 5 additions & 1 deletion tests/ci/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,11 @@ def _configure_jobs(

# filter jobs in accordance with ci settings
job_configs = ci_settings.apply(
job_configs, pr_info.is_release, is_pr=pr_info.is_pr, labels=pr_info.labels
job_configs,
pr_info.is_release,
is_pr=pr_info.is_pr,
is_mq=pr_info.is_merge_queue,
labels=pr_info.labels,
)

# check jobs in ci cache
Expand Down
16 changes: 13 additions & 3 deletions tests/ci/ci_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def _check_if_selected(
job_config: JobConfig,
is_release: bool,
is_pr: bool,
is_mq: bool,
labels: Iterable[str],
) -> bool: # type: ignore #too-many-return-statements
if self.do_not_test:
Expand Down Expand Up @@ -189,7 +190,7 @@ def _check_if_selected(

if job_config.release_only and not is_release:
return False
elif job_config.pr_only and not is_pr:
elif job_config.pr_only and not is_pr and not is_mq:
return False

return not to_deny
Expand All @@ -199,6 +200,7 @@ def apply(
job_configs: Dict[str, JobConfig],
is_release: bool,
is_pr: bool,
is_mq: bool,
labels: Iterable[str],
) -> Dict[str, JobConfig]:
"""
Expand All @@ -207,16 +209,24 @@ def apply(
res = {}
for job, job_config in job_configs.items():
if self._check_if_selected(
job, job_config, is_release=is_release, is_pr=is_pr, labels=labels
job,
job_config,
is_release=is_release,
is_pr=is_pr,
is_mq=is_mq,
labels=labels,
):
res[job] = job_config

add_parents = []
for job in list(res):
parent_jobs = CI_CONFIG.get_job_parents(job)
for parent_job in parent_jobs:
if parent_job not in res:
add_parents.append(parent_job)
print(f"Job [{job}] requires [{parent_job}] - add")
res[parent_job] = job_configs[parent_job]
for job in add_parents:
res[job] = job_configs[job]

for job, job_config in res.items():
batches = []
Expand Down
44 changes: 37 additions & 7 deletions tests/ci/test_ci_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ def test_options_applied(self):
)
filtered_jobs = list(
ci_options.apply(
jobs_configs, is_release=False, is_pr=True, labels=["TEST_LABEL"]
jobs_configs,
is_release=False,
is_pr=True,
is_mq=False,
labels=["TEST_LABEL"],
)
)
self.assertCountEqual(
Expand Down Expand Up @@ -212,17 +216,31 @@ def test_options_applied_2(self):
jobs_configs["fuzzers"].run_by_label = "TEST_LABEL"
# no settings are set
filtered_jobs = list(
CiSettings().apply(jobs_configs, is_release=False, is_pr=True, labels=[])
CiSettings().apply(
jobs_configs, is_release=False, is_pr=False, is_mq=True, labels=[]
)
)
self.assertCountEqual(
filtered_jobs,
[
"Fast test",
],
)
filtered_jobs = list(
CiSettings().apply(
jobs_configs, is_release=False, is_pr=True, is_mq=False, labels=[]
)
)
self.assertCountEqual(
filtered_jobs,
[
"Fast test",
],
)

filtered_jobs = list(
CiSettings().apply(jobs_configs, is_release=True, is_pr=False, labels=[])
CiSettings().apply(
jobs_configs, is_release=True, is_pr=False, is_mq=False, labels=[]
)
)
self.assertCountEqual(
filtered_jobs,
Expand All @@ -240,7 +258,11 @@ def test_options_applied_3(self):
# no settings are set
filtered_jobs = list(
ci_settings.apply(
jobs_configs, is_release=False, is_pr=True, labels=["TEST_LABEL"]
jobs_configs,
is_release=False,
is_pr=True,
is_mq=False,
labels=["TEST_LABEL"],
)
)
self.assertCountEqual(
Expand All @@ -253,7 +275,11 @@ def test_options_applied_3(self):
ci_settings.include_keywords = ["Fast"]
filtered_jobs = list(
ci_settings.apply(
jobs_configs, is_release=True, is_pr=False, labels=["TEST_LABEL"]
jobs_configs,
is_release=True,
is_pr=False,
is_mq=False,
labels=["TEST_LABEL"],
)
)
self.assertCountEqual(
Expand All @@ -277,7 +303,11 @@ def test_options_applied_4(self):
jobs_configs["Integration tests (asan)"].release_only = True
filtered_jobs = list(
ci_options.apply(
jobs_configs, is_release=False, is_pr=True, labels=["TEST_LABEL"]
jobs_configs,
is_release=False,
is_pr=True,
is_mq=False,
labels=["TEST_LABEL"],
)
)
self.assertCountEqual(
Expand Down

0 comments on commit b618b80

Please sign in to comment.