CI: modify CI from PR body

#do_not_test
 #job_style_check
This commit is contained in:
Max Kainov 2024-03-21 17:20:08 +00:00
parent 9afe096ff5
commit d6b515b6bf
4 changed files with 49 additions and 7 deletions

View File

@ -40,3 +40,33 @@ At a minimum, the following information should be added (but add more as needed)
> Information about CI checks: https://clickhouse.com/docs/en/development/continuous-integration/
---
### Modify your CI run:
##### NOTE:
- if your merge the PR with modified CI you **MUST** know what you are doing.
- modifiers can be applied only if set before CI starts
- remove `!` to apply
- return all `!` to restore defaults
```
!#ci_set_<SET_NAME> - to run only preconfigured set of tests, e.g.:
!#ci_set_arm - to run only integration tests on ARM
!#ci_set_integration - to run only integration tests on AMD
!#ci_set_analyzer - to run only tests for analyzer
NOTE: you can configure your own ci set
```
```
!#job_<JOB NAME> - to run only specified job, e.g.:
!#job_stateless_tests_release
!#job_package_debug
!#job_style_check
!#job_integration_tests_asan
```
```
!#batch_2 - to run only 2nd batch for all multi-batch jobs
!#btach_1_2_3 - to run only 1, 2, 3rd batch for all multi-batch jobs
```
```
!#no_merge_commit - to disable merge commit (no merge from master)
!#do_not_test - to disable whole CI (except style check)
```

View File

@ -26,4 +26,4 @@
## To run only specified batches for multi-batch job(s)
#batch_2
#btach_1_2_3
#batch_1_2_3

View File

@ -1407,15 +1407,25 @@ def _update_gh_statuses_action(indata: Dict, s3: S3Helper) -> None:
print("... CI report update - done")
def _fetch_commit_tokens(message: str) -> List[str]:
pattern = r"#[\w-]+"
matches = [match[1:] for match in re.findall(pattern, message)]
def _fetch_commit_tokens(message: str, pr_info: PRInfo) -> List[str]:
pattern = r"([^!]|^)#(\w+)"
matches = [match[-1] for match in re.findall(pattern, message)]
res = [
match
for match in matches
if match in Labels or match.startswith("job_") or match.startswith("batch_")
]
return res
print(f"CI modifyers from commit message: [{res}]")
res_2 = []
if pr_info.is_pr():
matches = [match[-1] for match in re.findall(pattern, pr_info.body)]
res_2 = [
match
for match in matches
if match in Labels or match.startswith("job_") or match.startswith("batch_")
]
print(f"CI modifyers from PR body: [{res_2}]")
return list(set(res + res_2))
def _upload_build_artifacts(
@ -1701,8 +1711,7 @@ def main() -> int:
message = args.commit_message or git_runner.run(
f"{GIT_PREFIX} log {pr_info.sha} --format=%B -n 1"
)
tokens = _fetch_commit_tokens(message)
print(f"Commit message tokens: [{tokens}]")
tokens = _fetch_commit_tokens(message, pr_info)
if Labels.NO_MERGE_COMMIT in tokens and CI:
git_runner.run(f"{GIT_PREFIX} checkout {pr_info.sha}")
git_ref = git_runner.run(f"{GIT_PREFIX} rev-parse HEAD")

View File

@ -316,6 +316,9 @@ class PRInfo:
def is_release_branch(self) -> bool:
return self.number == 0
def is_pr(self):
return self.event_type == EventType.PULL_REQUEST
def is_scheduled(self):
return self.event_type == EventType.SCHEDULE