Skip to content

Commit 84e6040

Browse files
committed
move all ci tag logic into parse_ci_tags
1 parent 3dc597a commit 84e6040

File tree

6 files changed

+21
-41
lines changed

6 files changed

+21
-41
lines changed

ci/jobs/scripts/workflow_hooks/filter_job.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import re
2-
from functools import lru_cache
3-
41
from ci.defs.defs import JobNames
52
from ci.defs.job_configs import JobConfigs
63
from ci.jobs.scripts.workflow_hooks.new_tests_check import (
@@ -52,15 +49,6 @@ def only_docs(changed_files):
5249
_info_cache = None
5350

5451

55-
@lru_cache
56-
def get_ci_exclude_tags(pr_body):
57-
pattern = r"(#|- \[x\] +<!---ci_exclude_)([|\w]+)"
58-
matches = []
59-
for match in re.findall(pattern, pr_body):
60-
matches.extend(match[-1].split("|"))
61-
return matches
62-
63-
6452
def should_skip_job(job_name):
6553
global _info_cache
6654
if _info_cache is None:
@@ -179,7 +167,7 @@ def should_skip_job(job_name):
179167
return False, ""
180168
return True, "Skipped, not labeled with 'pr-performance'"
181169

182-
ci_exclude_tags = get_ci_exclude_tags(_info_cache.pr_body)
170+
ci_exclude_tags = _info_cache.get_kv_data("ci_exclude_tags") or []
183171
for tag in ci_exclude_tags:
184172
if tag in job_name:
185173
return True, f"Skipped, job name includes excluded tag '{tag}'"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import re
2+
3+
from ci.praktika.info import Info
4+
5+
6+
def get_ci_tags(pr_body, tag_prefix):
7+
pattern = rf"(- \[x\] +<!---{tag_prefix}_)([|\w]+)"
8+
matches = []
9+
for match in re.findall(pattern, pr_body):
10+
matches.extend(match[-1].split("|"))
11+
return matches
12+
13+
14+
if __name__ == "__main__":
15+
info = Info()
16+
17+
info.store_kv_data("ci_exclude_tags", get_ci_tags(info.pr_body, "ci_exclude"))
18+
info.store_kv_data("ci_regression_jobs", get_ci_tags(info.pr_body, "ci_regression"))

ci/jobs/scripts/workflow_hooks/regression_config.py

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

ci/jobs/scripts/workflow_hooks/store_data.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import copy
2-
import re
32

43
from ci.defs.job_configs import JobConfigs
54
from ci.jobs.scripts.clickhouse_version import CHVersion
@@ -8,13 +7,6 @@
87
from ci.praktika.info import Info
98
from ci.praktika.utils import Shell
109

11-
def get_ci_exclude_tags(pr_body):
12-
pattern = r"(#|- \[x\] +<!---ci_exclude_)([|\w]+)"
13-
matches = []
14-
for match in re.findall(pattern, pr_body):
15-
matches.extend(match[-1].split("|"))
16-
return matches
17-
1810
if __name__ == "__main__":
1911
info = Info()
2012

@@ -31,9 +23,6 @@ def get_ci_exclude_tags(pr_body):
3123
digest = Digest().calc_job_digest(some_build_job, {}, {}).split("-")[0]
3224
info.store_kv_data("build_digest", digest)
3325

34-
# store ci exclude tags
35-
info.store_kv_data("ci_exclude_tags", get_ci_exclude_tags(info.pr_body))
36-
3726
if info.git_branch == "master" and info.repo_name == "ClickHouse/ClickHouse":
3827
# store previous commits for perf tests
3928
raw = Shell.get_output(

ci/workflows/master.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
pre_hooks=[
6464
"python3 ./ci/jobs/scripts/workflow_hooks/store_data.py",
6565
"python3 ./ci/jobs/scripts/workflow_hooks/version_log.py",
66-
"python3 ./ci/jobs/scripts/workflow_hooks/regression_config.py",
66+
"python3 ./ci/jobs/scripts/workflow_hooks/parse_ci_tags.py",
6767
# "python3 ./ci/jobs/scripts/workflow_hooks/merge_sync_pr.py", # NOTE (strtgbb): we don't do this
6868
],
6969
workflow_filter_hooks=[should_skip_job],

ci/workflows/pull_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
"python3 ./ci/jobs/scripts/workflow_hooks/version_log.py",
134134
# "python3 ./ci/jobs/scripts/workflow_hooks/quick_sync.py", # NOTE (strtgbb): we don't do this
135135
# "python3 ./ci/jobs/scripts/workflow_hooks/team_notifications.py",
136-
"python3 ./ci/jobs/scripts/workflow_hooks/regression_config.py",
136+
"python3 ./ci/jobs/scripts/workflow_hooks/parse_ci_tags.py",
137137
],
138138
workflow_filter_hooks=[should_skip_job],
139139
post_hooks=[

0 commit comments

Comments
 (0)