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

Use version from git describe in builds #31782

Merged
merged 2 commits into from
Nov 25, 2021
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
11 changes: 9 additions & 2 deletions tests/ci/build_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,15 @@ def build_clickhouse(packager_cmd, logs_path):
image_version = docker_image.version

version = get_version_from_repo(repo_path)
version.tweak_update()
update_version_local(repo_path, pr_info.sha, version)
logging.info("Got version from repo %s", version.get_version_string())

version_type = 'testing'
if 'release' in pr_info.labels or 'release-lts' in pr_info.labels:
version_type = 'stable'

update_version_local(repo_path, pr_info.sha, version, version_type)

logging.info("Updated local files with version")

build_name = build_config_to_string(build_config)
logging.info("Build short name %s", build_name)
Expand Down
16 changes: 15 additions & 1 deletion tests/ci/version_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,27 @@ def _get_version_from_line(line):
_, ver_with_bracket = line.strip().split(' ')
return ver_with_bracket[:-1]

def get_tweak_from_git_describe(repo_path):
# something like v21.12.1.8816-testing-358-g81942b8128
# or v21.11.4.14-stable-31-gd6aab025e0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have validators BTW?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No :)

output = subprocess.check_output(f"cd {repo_path} && git describe --long", shell=True).decode('utf-8')
commits_number = int(output.split('-')[-2])
# for testing releases we have to also add fourth number of
# the previous tag
if 'testing' in output:
previous_version = output.split('-')[0]
previous_version_commits = int(previous_version.split('.')[3])
commits_number += previous_version_commits

return commits_number


def get_version_from_repo(repo_path):
path_to_file = os.path.join(repo_path, FILE_WITH_VERSION_PATH)
major = 0
minor = 0
patch = 0
tweak = 0
tweak = get_tweak_from_git_describe(repo_path)
version_revision = 0
with open(path_to_file, 'r') as ver_file:
for line in ver_file:
Expand Down