mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Support a dedicated repository for DOL sources
This commit is contained in:
parent
c05c72cb80
commit
dcd0d1acac
@ -17,10 +17,11 @@ from shutil import rmtree
|
|||||||
from textwrap import fill
|
from textwrap import fill
|
||||||
from typing import Dict, Iterable, List, Optional, Set
|
from typing import Dict, Iterable, List, Optional, Set
|
||||||
|
|
||||||
from env_helper import GITHUB_REPOSITORY
|
from env_helper import GITHUB_REPOSITORY, IS_CI
|
||||||
from git_helper import Git, git_runner
|
from git_helper import GIT_PREFIX, Git, git_runner
|
||||||
from version_helper import (
|
from version_helper import (
|
||||||
ClickHouseVersion,
|
ClickHouseVersion,
|
||||||
|
VersionType,
|
||||||
get_supported_versions,
|
get_supported_versions,
|
||||||
get_tagged_versions,
|
get_tagged_versions,
|
||||||
get_version_from_string,
|
get_version_from_string,
|
||||||
@ -31,6 +32,10 @@ UBUNTU_NAMES = {
|
|||||||
"22.04": "jammy",
|
"22.04": "jammy",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if not IS_CI:
|
||||||
|
GIT_PREFIX = "git"
|
||||||
|
|
||||||
|
DOCKER_LIBRARY_REPOSITORY = "ClickHouse/docker-library"
|
||||||
|
|
||||||
DOCKER_LIBRARY_NAME = {"server": "clickhouse"}
|
DOCKER_LIBRARY_NAME = {"server": "clickhouse"}
|
||||||
|
|
||||||
@ -224,7 +229,8 @@ def generate_docker_directories(
|
|||||||
|
|
||||||
def path_is_changed(path: Path) -> bool:
|
def path_is_changed(path: Path) -> bool:
|
||||||
logging.info("Checking if the path %s is changed", path)
|
logging.info("Checking if the path %s is changed", path)
|
||||||
return bool(git_runner(f"git status --porcelain -- '{path}'"))
|
path_dir = path.parent
|
||||||
|
return bool(git_runner(f"git -C {path_dir} status --porcelain -- '{path}'"))
|
||||||
|
|
||||||
|
|
||||||
def get_cmdline(width: int = 80) -> str:
|
def get_cmdline(width: int = 80) -> str:
|
||||||
@ -251,7 +257,7 @@ def get_cmdline(width: int = 80) -> str:
|
|||||||
def generate_tree(args: argparse.Namespace) -> None:
|
def generate_tree(args: argparse.Namespace) -> None:
|
||||||
if args.fetch_tags:
|
if args.fetch_tags:
|
||||||
# Fetch all tags to not miss the latest versions
|
# Fetch all tags to not miss the latest versions
|
||||||
git_runner("git fetch --tags --no-recurse-submodules")
|
git_runner(f"{GIT_PREFIX} fetch --tags --no-recurse-submodules")
|
||||||
if args.min_version:
|
if args.min_version:
|
||||||
versions = get_versions_greater(args.min_version)
|
versions = get_versions_greater(args.min_version)
|
||||||
else:
|
else:
|
||||||
@ -277,7 +283,7 @@ def generate_tree(args: argparse.Namespace) -> None:
|
|||||||
)
|
)
|
||||||
if args.commit and path_is_changed(directory):
|
if args.commit and path_is_changed(directory):
|
||||||
logging.info("Staging and committing content of %s", directory)
|
logging.info("Staging and committing content of %s", directory)
|
||||||
git_runner(f"git add {directory}")
|
git_runner(f"git -C {directory} add {directory}")
|
||||||
commit_message = "\n".join(
|
commit_message = "\n".join(
|
||||||
(
|
(
|
||||||
"Re-/Generated tags for official docker library",
|
"Re-/Generated tags for official docker library",
|
||||||
@ -289,7 +295,7 @@ def generate_tree(args: argparse.Namespace) -> None:
|
|||||||
f"{get_cmdline()}",
|
f"{get_cmdline()}",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
git_runner("git commit -F -", input=commit_message)
|
git_runner(f"{GIT_PREFIX} -C {directory} commit -F -", input=commit_message)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -308,15 +314,19 @@ def ldf_header(git: Git, directory: Path) -> List[str]:
|
|||||||
script_path = Path(__file__).relative_to(git.root)
|
script_path = Path(__file__).relative_to(git.root)
|
||||||
script_sha = git_runner(f"git log -1 --format=format:%H -- {script_path}")
|
script_sha = git_runner(f"git log -1 --format=format:%H -- {script_path}")
|
||||||
repo = f"https://github.com/{GITHUB_REPOSITORY}"
|
repo = f"https://github.com/{GITHUB_REPOSITORY}"
|
||||||
fetch_commit = git_runner(f"git log -1 --format=format:%H -- {directory}")
|
dl_repo = f"https://github.com/{DOCKER_LIBRARY_REPOSITORY}"
|
||||||
|
fetch_commit = git_runner(
|
||||||
|
f"git -C {directory} log -1 --format=format:%H -- {directory}"
|
||||||
|
)
|
||||||
|
dl_branch = git_runner(f"git -C {directory} branch --show-current")
|
||||||
return [
|
return [
|
||||||
f"# The file is generated by {repo}/blob/{script_sha}/{script_path}",
|
f"# The file is generated by {repo}/blob/{script_sha}/{script_path}",
|
||||||
"",
|
"",
|
||||||
"Maintainers: Misha f. Shiryaev <felixoid@clickhouse.com> (@Felixoid),",
|
"Maintainers: Misha f. Shiryaev <felixoid@clickhouse.com> (@Felixoid),",
|
||||||
" Max Kainov <max.kainov@clickhouse.com> (@mkaynov),",
|
" Max Kainov <max.kainov@clickhouse.com> (@mkaynov),",
|
||||||
" Alexander Sapin <alesapin@clickhouse.com> (@alesapin)",
|
" Alexander Sapin <alesapin@clickhouse.com> (@alesapin)",
|
||||||
f"GitRepo: {repo}.git",
|
f"GitRepo: {dl_repo}.git",
|
||||||
f"GitFetch: refs/heads/{git.branch}",
|
f"GitFetch: refs/heads/{dl_branch}",
|
||||||
f"GitCommit: {fetch_commit}",
|
f"GitCommit: {fetch_commit}",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -364,6 +374,10 @@ def generate_ldf(args: argparse.Namespace) -> None:
|
|||||||
if args.check_changed:
|
if args.check_changed:
|
||||||
assert not path_is_changed(directory)
|
assert not path_is_changed(directory)
|
||||||
git = Git(True)
|
git = Git(True)
|
||||||
|
# Support a few repositories
|
||||||
|
dir_git_root = (
|
||||||
|
args.directory / git_runner(f"git -C {args.directory} rev-parse --show-cdup")
|
||||||
|
).absolute()
|
||||||
lines = ldf_header(git, directory)
|
lines = ldf_header(git, directory)
|
||||||
tag_attrs = TagAttrs(versions[-1], {}, None)
|
tag_attrs = TagAttrs(versions[-1], {}, None)
|
||||||
for version in reversed(versions):
|
for version in reversed(versions):
|
||||||
@ -380,7 +394,7 @@ def generate_ldf(args: argparse.Namespace) -> None:
|
|||||||
break
|
break
|
||||||
lines.append(ldf_tags(version, distro, tag_attrs))
|
lines.append(ldf_tags(version, distro, tag_attrs))
|
||||||
lines.append("Architectures: amd64, arm64v8")
|
lines.append("Architectures: amd64, arm64v8")
|
||||||
lines.append(f"Directory: {tag_dir.relative_to(git.root)}")
|
lines.append(f"Directory: {tag_dir.relative_to(dir_git_root)}")
|
||||||
lines.append(f"File: {file.name}")
|
lines.append(f"File: {file.name}")
|
||||||
|
|
||||||
lines.append("")
|
lines.append("")
|
||||||
@ -389,12 +403,13 @@ def generate_ldf(args: argparse.Namespace) -> None:
|
|||||||
)
|
)
|
||||||
ldf_file.write_text("\n".join(lines))
|
ldf_file.write_text("\n".join(lines))
|
||||||
if args.commit and path_is_changed(ldf_file):
|
if args.commit and path_is_changed(ldf_file):
|
||||||
git_runner(f"git add {ldf_file}")
|
ldf_dir = ldf_file.parent
|
||||||
|
git_runner(f"git -C {ldf_dir} add {ldf_file}")
|
||||||
commit_message = (
|
commit_message = (
|
||||||
f"Re-/Generated docker LDF for {args.image_type} image\n\n"
|
f"Re-/Generated docker LDF for {args.image_type} image\n\n"
|
||||||
f"The file is generated and committed as following:\n{get_cmdline()}"
|
f"The file is generated and committed as following:\n{get_cmdline()}"
|
||||||
)
|
)
|
||||||
git_runner("git commit -F -", input=commit_message)
|
git_runner(f"{GIT_PREFIX} -C {ldf_dir} commit -F -", input=commit_message)
|
||||||
print("\n".join(lines))
|
print("\n".join(lines))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user