Skip to content
Merged
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
8 changes: 6 additions & 2 deletions tests/ci/pr_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@ def get_pr_for_commit(sha, ref):
ref,
sha,
)
first_pr = our_prs[0]
return first_pr
if len(our_prs) != 0:
first_pr = our_prs[0]
return first_pr
else:
return None

except Exception as ex:
logging.error(
"Cannot fetch PR info from commit ref %s, sha %s, exception: %s",
Expand Down
62 changes: 35 additions & 27 deletions tests/ci/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ def test_version_arg(self):
("v31.1.1.2-testing", vh.get_version_from_string("31.1.1.2")),
("refs/tags/v31.1.1.2-testing", vh.get_version_from_string("31.1.1.2")),
)
for test_case in cases:
version = vh.version_arg(test_case[0])
self.assertEqual(test_case[1], version)
for i, test_case in enumerate(cases):
with self.subTest(test_case, i=i):
version = vh.version_arg(test_case[0])
self.assertEqual(test_case[1], version)
error_cases = (
"0.0.0",
"1.1.1.a",
Expand All @@ -48,33 +49,40 @@ class TestCase:
expected: CHV

cases = (
# TestCase(
# "v24.6.1.1-new",
# 15,
# "v24.4.1.2088-stable",
# 415,
# CHV(24, 5, 1, 54487, None, 415),
# ),
# TestCase(
# "v24.6.1.1-testing",
# 15,
# "v24.4.1.2088-stable",
# 415,
# CHV(24, 5, 1, 54487, None, 15),
# ),
# TestCase(
# "v24.6.1.1-stable",
# 15,
# "v24.4.1.2088-stable",
# 415,
# CHV(24, 5, 1, 54487, None, 15),
# ),
# TestCase(
# "v24.5.1.1-stable",
# 15,
# "v24.4.1.2088-stable",
# 415,
# CHV(24, 5, 1, 54487, None, 15),
# ),
TestCase(
"v24.6.1.1-new",
15,
"v24.5.1.100-stable",
0,
"v24.4.1.2088-stable",
415,
CHV(24, 5, 1, 54487, None, 415),
),
TestCase(
"v24.6.1.1-testing",
15,
"v24.4.1.2088-stable",
415,
CHV(24, 5, 1, 54487, None, 15),
),
TestCase(
"v24.6.1.1-stable",
15,
"v24.4.1.2088-stable",
415,
CHV(24, 5, 1, 54487, None, 15),
),
TestCase(
"v24.5.1.1-stable",
15,
"v24.4.1.2088-stable",
415,
CHV(24, 5, 1, 54487, None, 15),
CHV(24, 5, 1, 54487, None, 100),
),
)
git = Git(True)
Expand Down
37 changes: 24 additions & 13 deletions tests/ci/version_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,17 +300,21 @@ def get_version_from_repo(
tweak=versions.get("tweak", versions["revision"]),
flavour=versions.get("flavour", None)
)
# Since 24.5 we have tags like v24.6.1.1-new, and we must check if the release
# branch already has it's own commit. It's necessary for a proper tweak version
if git is not None and git.latest_tag:

# if this commit is tagged, use tag's version instead of something stored in cmake
if git is not None and git.latest_tag and git.commits_since_latest == 0:
version_from_tag = get_version_from_tag(git.latest_tag)
if (
version_from_tag.description == VersionType.NEW
and cmake_version < version_from_tag
):
# We are in a new release branch without existing release.
# We should change the tweak version to a `tweak_to_new`
cmake_version.tweak = git.tweak_to_new
# 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})")

# Don't need to reset version completely, mostly because revision part is not set in tag, but must be preserved
cmake_version._flavour = version_from_tag._flavour
cmake_version.tweak = version_from_tag.tweak

return cmake_version


Expand All @@ -333,9 +337,16 @@ def get_version_from_string(

def get_version_from_tag(tag: str) -> ClickHouseVersion:
Git.check_tag(tag)
tag, description = tag[1:].split("-", 1)
version = get_version_from_string(tag)
version.with_description(description)
tag = tag[1:] # strip initial 'v'
if '-' in tag:
# Upstream tags with dash
tag, description = tag.split("-", 1)
version = get_version_from_string(tag)
version.with_description(description)
else:
# Altinity's tags, with dots as separators between parts (handled properly down the road)
version = get_version_from_string(tag)

return version


Expand Down
Loading