Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmake/autogenerated_versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ SET(VERSION_GITHASH c8a1e828dcf9832dc2d71adcbd50c698f93bb69b)

#10000 for altinitystable candidates
#20000 for altinityedge candidates
SET(VERSION_TWEAK 10500)
SET(VERSION_TWEAK 10545)
SET(VERSION_FLAVOUR altinitytest)

SET(VERSION_DESCRIBE v24.8.14.10500.altinitytest)
SET(VERSION_STRING 24.8.14.10500.altinitytest)
SET(VERSION_DESCRIBE v24.8.14.10545.altinitytest)
SET(VERSION_STRING 24.8.14.10545.altinitytest)

# end of autochange
42 changes: 25 additions & 17 deletions tests/ci/version_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
from pathlib import Path
from typing import Any, Dict, Iterable, List, Literal, Optional, Set, Tuple, Union

from pr_info import PRInfo # grype scan needs to know the PR number
try:
# grype scan needs to know the PR number
# But non-grype jobs might be missing dependencies
from pr_info import PRInfo
except ImportError:
PRInfo = None

from git_helper import TWEAK, Git, get_tags, git_runner, removeprefix, VersionType

Expand Down Expand Up @@ -86,6 +91,7 @@ def bump(self) -> "ClickHouseVersion":
self._tweak = 1
else:
self._major += 1
self._minor = 1
self._revision += 1
self._patch = 1
self._tweak = 1
Expand Down Expand Up @@ -310,30 +316,26 @@ def get_version_from_repo(
flavour=versions.get("flavour", None)
)

# if this commit is tagged, use tag's version instead of something stored in cmake
# If this commit is tagged, use tag's version instead of something stored in cmake
if git is not None and git.latest_tag:
version_from_tag = get_version_from_tag(git.latest_tag)
logging.debug(f'Git latest tag: {git.latest_tag} ({git.commits_since_latest} commits ago)\n'
f'"new" tag: {git.new_tag} ({git.commits_since_new})\n'
f'current commit: {git.sha}\n'
f'current brach: {git.branch}'
)
if git.commits_since_latest == 0:
if git.latest_tag and git.commits_since_latest == 0:
# Tag has a priority over the version written in CMake.
# Version must match (except tweak, flavour, description, etc.) to avoid accidental mess.
if not (version_from_tag.major == cmake_version.major \
and version_from_tag.minor == cmake_version.minor \
and version_from_tag.patch == cmake_version.patch):
raise RuntimeError(f"Version generated from tag ({version_from_tag}) should have same major, minor, and patch values as version generated from cmake ({cmake_version})")
and version_from_tag.minor == cmake_version.minor \
and version_from_tag.patch == cmake_version.patch \
and version_from_tag.tweak == cmake_version.tweak):
raise RuntimeError(f"Version generated from tag ({version_from_tag}) should have same major, minor, patch, and tweak values as version generated from cmake ({cmake_version})")

# Don't need to reset version completely, mostly because revision part is not set in tag, but must be preserved
logging.debug(f"Resetting TWEAK and FLAVOUR of version from cmake {cmake_version} to values from tag: {version_from_tag.tweak}.{version_from_tag._flavour}")
logging.debug(f"Resetting FLAVOUR of version from cmake {cmake_version} to values from tag: {version_from_tag._flavour}")
cmake_version._flavour = version_from_tag._flavour
cmake_version.tweak = version_from_tag.tweak
else:
# We've had some number of commits since the latest tag.
logging.debug(f"Bumping the TWEAK of version from cmake {cmake_version} by {git.commits_since_latest}")
cmake_version.tweak = cmake_version.tweak + git.commits_since_latest

return cmake_version

Expand Down Expand Up @@ -432,9 +434,14 @@ def get_supported_versions(
def update_cmake_version(
version: ClickHouseVersion,
versions_path: Union[Path, str] = FILE_WITH_VERSION_PATH,
preserve_sha: bool = False,
) -> None:
version_dict = version.as_dict()
if preserve_sha:
githash = read_versions(versions_path)["githash"]
version_dict["githash"] = githash
get_abs_path(versions_path).write_text(
VERSIONS_TEMPLATE.format_map(version.as_dict()), encoding="utf-8"
VERSIONS_TEMPLATE.format_map(version_dict), encoding="utf-8"
)


Expand Down Expand Up @@ -534,10 +541,11 @@ def main():
update_cmake_version(version)

# grype scan needs to know the PR number
pr_info = PRInfo()
print(f"PR_NUMBER={pr_info.number}")
if args.export:
print(f"export PR_NUMBER")
if PRInfo:
pr_info = PRInfo()
print(f"PR_NUMBER={pr_info.number}")
if args.export:
print(f"export PR_NUMBER")

for k, v in version.as_dict().items():
name = f"CLICKHOUSE_VERSION_{k.upper()}"
Expand Down
Loading