Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stateless cmake version #46821

Merged
merged 2 commits into from
Feb 24, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 21 additions & 20 deletions tests/ci/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ def do(
raise ValueError(
"The relese type must be 'major' for minor versions>=12"
)
if self._version.minor < 12 and self.release_type == "major":
raise ValueError(
"The relese type must be 'minor' for minor versions<12"
)

with self._checkout(self.release_commit, True):
# Checkout to the commit, it will provide the correct current version
Expand Down Expand Up @@ -265,7 +269,11 @@ def check_branch(self):
f"for {self.release_type} release"
)

def _commit_cmake_contributors(self, version: ClickHouseVersion) -> None:
def _update_cmake_contributors(
self, version: ClickHouseVersion, reset_tweak: bool = True
) -> None:
if reset_tweak:
version = version.reset_tweak()
update_cmake_version(version)
update_contributors(raise_error=True)
if self.dry_run:
Expand All @@ -274,9 +282,15 @@ def _commit_cmake_contributors(self, version: ClickHouseVersion) -> None:
self.run(f"git diff '{self.CMAKE_PATH}' '{self.CONTRIBUTORS_PATH}'"),
)
self.run(f"git checkout '{self.CMAKE_PATH}' '{self.CONTRIBUTORS_PATH}'")

def _commit_cmake_contributors(
self, version: ClickHouseVersion, reset_tweak: bool = True
antonio2368 marked this conversation as resolved.
Show resolved Hide resolved
) -> None:
if reset_tweak:
version = version.reset_tweak()
self.run(
f"git commit -m 'Update version to {version.string}' "
f"'{self.CMAKE_PATH}' '{self.CONTRIBUTORS_PATH}'",
f"git commit '{self.CMAKE_PATH}' '{self.CONTRIBUTORS_PATH}' "
f"-m 'Update autogenerated version to {version.string} and contributors'",
dry_run=self.dry_run,
)

Expand Down Expand Up @@ -321,27 +335,12 @@ def stable(self):
with self._create_gh_release(False):
self.version = self.version.update(self.release_type)
self.version.with_description(version_type)
update_cmake_version(self.version)
update_contributors(raise_error=True)
if self.dry_run:
logging.info(
"Dry running, resetting the following changes in the repo:\n%s",
self.run(
f"git diff '{self.CMAKE_PATH}' '{self.CONTRIBUTORS_PATH}'"
),
)
self.run(f"git checkout '{self.CMAKE_PATH}' '{self.CONTRIBUTORS_PATH}'")

self._update_cmake_contributors(self.version)
# Checkouting the commit of the branch and not the branch itself,
# then we are able to skip rollback
with self._checkout(f"{self.release_branch}^0", False):
current_commit = self.run("git rev-parse HEAD")
self.run(
f"git commit -m "
f"'Update version to {self.version.string}' "
f"'{self.CMAKE_PATH}' '{self.CONTRIBUTORS_PATH}'",
dry_run=self.dry_run,
)
self._commit_cmake_contributors(self.version)
with self._push(
"HEAD", with_rollback_on_fail=False, remote_ref=self.release_branch
):
Expand Down Expand Up @@ -406,6 +405,7 @@ def _bump_release_branch(self):
if version_type == VersionType.LTS:
pr_labels += " --label release-lts"
new_version.with_description(version_type)
self._update_cmake_contributors(new_version)
self._commit_cmake_contributors(new_version)
with self._push(self.release_branch):
with self._create_gh_label(
Expand Down Expand Up @@ -434,6 +434,7 @@ def _bump_testing_version(self, helper_branch: str) -> Iterator[None]:
self.read_version()
self.version = self.version.update(self.release_type)
self.version.with_description(VersionType.TESTING)
self._update_cmake_contributors(self.version)
self._commit_cmake_contributors(self.version)
with self._push(helper_branch):
body_file = get_abs_path(".github/PULL_REQUEST_TEMPLATE.md")
Expand Down
7 changes: 7 additions & 0 deletions tests/ci/version_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ def patch_update(self) -> "ClickHouseVersion":
self.major, self.minor, self.patch + 1, self.revision, self._git
)

def reset_tweak(self) -> "ClickHouseVersion":
if self._git is not None:
self._git.update()
return ClickHouseVersion(
self.major, self.minor, self.patch, self.revision, self._git, "1"
)

@property
def major(self) -> int:
return self._major
Expand Down