Skip to content

Commit 2499a02

Browse files
authored
Merge pull request #537 from Altinity/24.8_easier_versioning
24.8 Easier versioning
2 parents 3d29e79 + 1555ef7 commit 2499a02

File tree

7 files changed

+51
-30
lines changed

7 files changed

+51
-30
lines changed

.github/workflows/reusable_build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
env:
55
# Force the stdout and stderr streams to be unbuffered
66
PYTHONUNBUFFERED: 1
7-
CLICKHOUSE_STABLE_VERSION_SUFFIX: altinitystable
87
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
98
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
109
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

cmake/autogenerated_versions.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ SET(VERSION_MINOR 8)
88
SET(VERSION_PATCH 8)
99
SET(VERSION_GITHASH e28553d4f2ba78643f9ef47b698954a2c54e6bcc)
1010

11-
SET(VERSION_TWEAK 18)
11+
#1000 for altinitystable candidates
12+
#2000 for altinityedge candidates
13+
SET(VERSION_TWEAK 181000)
1214
SET(VERSION_FLAVOUR altinitystable)
1315

14-
SET(VERSION_DESCRIBE v24.8.8.18.altinitystable)
15-
SET(VERSION_STRING 24.8.8.18.altinitystable)
16+
SET(VERSION_DESCRIBE v24.8.8.181000.altinitystable)
17+
SET(VERSION_STRING 24.8.8.181000.altinitystable)
1618

1719
# end of autochange

cmake/version.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ include(${PROJECT_SOURCE_DIR}/cmake/autogenerated_versions.txt)
33
set(VERSION_EXTRA "" CACHE STRING "")
44
set(VERSION_TWEAK "" CACHE STRING "")
55

6-
if (VERSION_TWEAK)
7-
string(CONCAT VERSION_STRING ${VERSION_STRING} "." ${VERSION_TWEAK})
8-
endif ()
6+
# NOTE(vnemkov): we rely on VERSION_TWEAK portion to be already present in VERSION_STRING
7+
# if (VERSION_TWEAK)
8+
# string(CONCAT VERSION_STRING ${VERSION_STRING} "." ${VERSION_TWEAK})
9+
# endif ()
910

1011
if (VERSION_EXTRA)
1112
string(CONCAT VERSION_STRING ${VERSION_STRING} "." ${VERSION_EXTRA})

tests/ci/build_check.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
from ci_config import CI
1313
from env_helper import REPO_COPY, S3_BUILDS_BUCKET, TEMP_PATH, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY
1414
from git_helper import Git
15-
from pr_info import PRInfo
15+
from pr_info import PRInfo, EventType
1616
from report import FAILURE, SUCCESS, JobReport, StatusType
1717
from stopwatch import Stopwatch
1818
from tee_popen import TeePopen
1919
from version_helper import (
2020
ClickHouseVersion,
21+
VersionType,
2122
get_version_from_repo,
2223
update_version_local,
2324
)
@@ -164,16 +165,31 @@ def main():
164165
version = get_version_from_repo(git=Git(True))
165166
logging.info("Got version from repo %s", version.string)
166167

167-
official_flag = pr_info.number == 0
168+
# official_flag = pr_info.number == 0
168169

169-
version_type = "testing"
170-
if is_release_pr(pr_info):
171-
version_type = "stable"
172-
official_flag = True
170+
# version_type = "testing"
171+
# if is_release_pr(pr_info):
172+
# version_type = "stable"
173+
# official_flag = True
174+
175+
# NOTE(vnemkov): For Altinity Stable builds, version flavor
176+
# (last part of version, like 'altinitystable') is obtained from tag.
177+
# If there is no tag, then version is considered to be 'testing'
178+
version_type = version._flavour = VersionType.TESTING
179+
official_flag = True
180+
181+
if pr_info.event_type == EventType.PUSH \
182+
and pr_info.ref.startswith('/ref/tags/'):
183+
tag_name = pr_info.ref.removeprefix('/ref/tags/')
184+
version_type = tag_name.split('.')[-1]
185+
version._flavour = version_type
186+
logging.info("Using version from tag: %s => %s", tag_name, version)
187+
188+
# TODO(vnemkov): make sure tweak part is incremented by 1 each time we merge a PR
173189

174190
update_version_local(version, version_type)
175191

176-
logging.info("Updated local files with version")
192+
logging.info("Updated local files with version %s", version)
177193

178194
logging.info("Build short name %s", build_name)
179195

tests/ci/git_helper.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@
1111

1212
logger = logging.getLogger(__name__)
1313

14+
class VersionType:
15+
LTS = "lts"
16+
NEW = "new"
17+
PRESTABLE = "altinityedge"
18+
STABLE = "altinitystable"
19+
TESTING = "altinitytest"
20+
21+
VALID = (NEW, TESTING, PRESTABLE, STABLE, LTS,
22+
# NOTE (vnemkov): we don't use those directly, but it is used in unit-tests
23+
"stable",
24+
"prestable",
25+
"testing",
26+
)
27+
1428
# ^ and $ match subline in `multiple\nlines`
1529
# \A and \Z match only start and end of the whole string
1630
# NOTE (vnemkov): support both upstream tag style: v22.x.y.z-lts and Altinity tag style: v22.x.y.z.altinitystable
@@ -19,7 +33,7 @@
1933
TAG_REGEXP = (
2034
r"\Av\d{2}" # First two digits of major part
2135
r"([.][1-9]\d*){3}" # minor.patch.tweak parts
22-
r"-(new|testing|prestable|stable|lts|altinitystable)\Z" # suffix with a version type
36+
fr"[.-]({'|'.join(VersionType.VALID)})\Z" # suffix with a version type
2337
)
2438
SHA_REGEXP = re.compile(r"\A([0-9]|[a-f]){40}\Z")
2539

tests/ci/pr_info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ def __init__(
132132
ref = github_event.get("ref", "refs/heads/master")
133133
if ref and ref.startswith("refs/heads/"):
134134
ref = ref[11:]
135+
self.ref = ref # type: str e.g. "refs/pull/509/merge" or "refs/tags/v24.3.12.76.altinitystable"
135136
# Default values
136-
self.base_ref = "" # type: str
137+
self.base_ref = github_event.get("base_ref","") # type: str
137138
self.base_name = "" # type: str
138139
self.head_ref = "" # type: str
139140
self.head_name = "" # type: str

tests/ci/version_helper.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55
from typing import Any, Dict, Iterable, List, Literal, Optional, Set, Tuple, Union
66

7-
from git_helper import TWEAK, Git, get_tags, git_runner, removeprefix
7+
from git_helper import TWEAK, Git, get_tags, git_runner, removeprefix, VersionType
88

99
FILE_WITH_VERSION_PATH = "cmake/autogenerated_versions.txt"
1010
CHANGELOG_IN_PATH = "debian/changelog.in"
@@ -250,20 +250,8 @@ def __repr__(self):
250250

251251
ClickHouseVersions = List[ClickHouseVersion]
252252

253-
254-
class VersionType:
255-
LTS = "lts"
256-
NEW = "new"
257-
PRESTABLE = "prestable"
258-
STABLE = "altinitystable"
259-
TESTING = "testing"
260-
VALID = (NEW, TESTING, PRESTABLE, STABLE, LTS,
261-
"stable" # NOTE (vnemkov): we don't use that directly, but it is used in unit-tests
262-
)
263-
264-
265253
def validate_version(version: str) -> None:
266-
# NOTE(vnemkov): minor but imporant fixes, so versions with 'flavour' are threated as valid (e.g. 22.8.8.4.altinitystable)
254+
# NOTE(vnemkov): minor but important fixes, so versions with 'flavour' are threated as valid (e.g. 22.8.8.4.altinitystable)
267255
parts = version.split(".")
268256
if len(parts) < 4:
269257
raise ValueError(f"{version} does not contain 4 parts")

0 commit comments

Comments
 (0)