mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 11:02:08 +00:00
Use docker images cache from merged PRs in master and release branches
This commit is contained in:
parent
4081a5f9e9
commit
9584487a1e
@ -441,11 +441,15 @@ def main():
|
||||
|
||||
result_images = {}
|
||||
images_processing_result = []
|
||||
additional_cache = ""
|
||||
if pr_info.release_pr or pr_info.merged_pr:
|
||||
additional_cache = str(pr_info.release_pr or pr_info.merged_pr)
|
||||
|
||||
for image in changed_images:
|
||||
# If we are in backport PR, then pr_info.release_pr is defined
|
||||
# We use it as tag to reduce rebuilding time
|
||||
images_processing_result += process_image_with_parents(
|
||||
image, image_versions, pr_info.release_pr, args.push
|
||||
image, image_versions, additional_cache, args.push
|
||||
)
|
||||
result_images[image.repo] = result_version
|
||||
|
||||
|
@ -64,6 +64,7 @@ def get_pr_for_commit(sha, ref):
|
||||
class PRInfo:
|
||||
default_event = {
|
||||
"commits": 1,
|
||||
"head_commit": {"message": "commit_message"},
|
||||
"before": "HEAD~",
|
||||
"after": "HEAD",
|
||||
"ref": None,
|
||||
@ -86,7 +87,9 @@ class PRInfo:
|
||||
self.changed_files = set() # type: Set[str]
|
||||
self.body = ""
|
||||
self.diff_urls = []
|
||||
# release_pr and merged_pr are used for docker images additional cache
|
||||
self.release_pr = 0
|
||||
self.merged_pr = 0
|
||||
ref = github_event.get("ref", "refs/heads/master")
|
||||
if ref and ref.startswith("refs/heads/"):
|
||||
ref = ref[11:]
|
||||
@ -158,6 +161,14 @@ class PRInfo:
|
||||
|
||||
self.diff_urls.append(github_event["pull_request"]["diff_url"])
|
||||
elif "commits" in github_event:
|
||||
# `head_commit` always comes with `commits`
|
||||
commit_message = github_event["head_commit"]["message"]
|
||||
if commit_message.startswith("Merge pull request #"):
|
||||
merged_pr = commit_message.split(maxsplit=4)[3]
|
||||
try:
|
||||
self.merged_pr = int(merged_pr[1:])
|
||||
except ValueError:
|
||||
logging.error("Failed to convert %s to integer", merged_pr)
|
||||
self.sha = github_event["after"]
|
||||
pull_request = get_pr_for_commit(self.sha, github_event["ref"])
|
||||
repo_prefix = f"{GITHUB_SERVER_URL}/{GITHUB_REPOSITORY}"
|
||||
|
Loading…
Reference in New Issue
Block a user