From bf28644de3dab757e4ca3604365bf6e16eb6fb42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Tue, 12 Nov 2024 10:59:58 +0100 Subject: [PATCH 1/5] CI: distribution-version: fix check for dev versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When no match for the `dev` match group is found by `re.fullmatch` then `version_bb["dev"]` will be `None` not `""`. Fix the check accordingly and turn the `elif`/`else` around so we do not need a `not`. Signed-off-by: Leonard Göhrs --- .github/workflows/distribution-version.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/distribution-version.py b/.github/workflows/distribution-version.py index bb801c70..d96c4268 100644 --- a/.github/workflows/distribution-version.py +++ b/.github/workflows/distribution-version.py @@ -54,16 +54,16 @@ def check_version(distro_version): assert version_bb["dev"] == "" assert version_tag_numeric == version_bb_numeric - elif version_bb["dev"] == "": - # Release candidates already have the next release version set, - # but it must be newer than any tag in the current commit's history. - assert version_bb_numeric > version_tag_numeric - - else: + elif version_bb["dev"]: # Non release candidate versions should have the previous tagged # version number plus the +dev suffix set. assert version_bb_numeric == version_tag_numeric + else: + # Release candidates already have the next release version set, + # but it must be newer than any tag in the current commit's history. + assert version_bb_numeric > version_tag_numeric + def check_codename(codename): base_ref = os.environ.get("GITHUB_BASE_REF") From eae433e80a229f80fed49c64c6c737b643c1923e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Tue, 12 Nov 2024 09:53:13 +0100 Subject: [PATCH 2/5] CI: distribution-version: handle minor version numbers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have always planned to support minor version numbers, but did not implement support for them in the checker script yet. This change allows stable version numbers like these: v24.09 v24.09.1 v24.09.123 And devel version numbers like this one: v24.09+dev But not the combination: v24.09.1+dev v24.09.123+dev Because "+dev" should only be used on the current development branch, while minor numbers should only be used on stable branches. There is no branch on which both may be used. Signed-off-by: Leonard Göhrs --- .github/workflows/distribution-version.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/distribution-version.py b/.github/workflows/distribution-version.py index d96c4268..b2db0daa 100644 --- a/.github/workflows/distribution-version.py +++ b/.github/workflows/distribution-version.py @@ -4,9 +4,8 @@ import bb.tinfoil import git -# TODO: add minor version numbers once we have them -RE_VERSION_TAG = "v(?P[0-9][0-9])\.(?P[0-9][0-9])" -RE_VERSION_BB = "(?P[0-9][0-9])\.(?P[0-9][0-9])(?P$|\+dev)" +RE_VERSION_TAG = r"v(?P[0-9][0-9])\.(?P[0-9][0-9])(?:\.(?P[0-9]+))?" +RE_VERSION_BB = r"(?P[0-9][0-9])\.(?P[0-9][0-9])(?:(?P$|\+dev)|(?:\.(?P[0-9]+))?)" def bb_variables(names): @@ -38,31 +37,39 @@ def git_prev_tag(): return (tag, commit_is_tagged) +def version_tuple(version): + year = int(version["year"]) + month = int(version["month"]) + minor = int(version["minor"] or "0") + + return (year, month, minor) + + def check_version(distro_version): prev_tag, commit_is_tagged = git_prev_tag() print(f"Checking tag {prev_tag} against version {distro_version}") version_tag = re.fullmatch(RE_VERSION_TAG, prev_tag) - version_tag_numeric = int(version_tag["year"]) * 100 + int(version_tag["month"]) + version_tag_tuple = version_tuple(version_tag) version_bb = re.fullmatch(RE_VERSION_BB, distro_version) - version_bb_numeric = int(version_bb["year"]) * 100 + int(version_bb["month"]) + version_bb_tuple = version_tuple(version_bb) if commit_is_tagged: # The version in a tagged commit must match the version in the tag's name. assert version_bb["dev"] == "" - assert version_tag_numeric == version_bb_numeric + assert version_tag_tuple == version_bb_tuple elif version_bb["dev"]: # Non release candidate versions should have the previous tagged # version number plus the +dev suffix set. - assert version_bb_numeric == version_tag_numeric + assert version_bb_tuple == version_tag_tuple else: # Release candidates already have the next release version set, # but it must be newer than any tag in the current commit's history. - assert version_bb_numeric > version_tag_numeric + assert version_bb_tuple > version_tag_tuple def check_codename(codename): From 5618adc050415a3f36ccc95a6b270a4a3b402324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Tue, 12 Nov 2024 10:03:59 +0100 Subject: [PATCH 3/5] CI: distribution-version: break out branch name determination logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The branch name we are interested in is stored in different variables for jobs triggered by a pull request and ones triggered by a push. Break out the selection to make code that uses the name easier. Signed-off-by: Leonard Göhrs --- .github/workflows/distribution-version.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/distribution-version.py b/.github/workflows/distribution-version.py index b2db0daa..3cb8a24f 100644 --- a/.github/workflows/distribution-version.py +++ b/.github/workflows/distribution-version.py @@ -77,12 +77,11 @@ def check_codename(codename): ref = os.environ.get("GITHUB_REF_NAME") ref_type = os.environ.get("GITHUB_REF_TYPE") - if base_ref: - print(f"Checking codename {codename} against pull request into {base_ref}") - assert codename == f"tacos-{base_ref}" - elif ref and ref_type == "branch": - print(f"Checking codename {codename} against branch {ref}") - assert codename == f"tacos-{ref}" + branch = base_ref or (ref if ref_type == "branch" else None) + + if branch: + print(f"Checking codename {codename} against branch {branch}") + assert codename == f"tacos-{branch}" elif ref_type == "tag": print("Running for a tag. Skipping codename check") else: From 9010553ffe72946b487936940642b79f01122972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Tue, 12 Nov 2024 09:58:46 +0100 Subject: [PATCH 4/5] CI: distribution-version: skip codename checks for stable branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For the development branch (e.g. scarthgap or styhead) the codename in the tacos distribution should match the branch name. This is however not the case for stable branches (e.g. stable-24.09). Signed-off-by: Leonard Göhrs --- .github/workflows/distribution-version.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/distribution-version.py b/.github/workflows/distribution-version.py index 3cb8a24f..ae182465 100644 --- a/.github/workflows/distribution-version.py +++ b/.github/workflows/distribution-version.py @@ -79,7 +79,9 @@ def check_codename(codename): branch = base_ref or (ref if ref_type == "branch" else None) - if branch: + if branch and branch.startswith("stable-"): + print("Running for a stable branch. Skipping codename check") + elif branch: print(f"Checking codename {codename} against branch {branch}") assert codename == f"tacos-{branch}" elif ref_type == "tag": From c779eff11db94f5bcc4e43f0b47fe77f587f6221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Tue, 12 Nov 2024 10:01:57 +0100 Subject: [PATCH 5/5] CI: build: also run for push/pull request against stable branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Leonard Göhrs --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 20cddb3f..49006028 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,9 +4,11 @@ on: pull_request: branches: - scarthgap + - stable-* push: branches: - scarthgap + - stable-* schedule: - cron: '10 21 * * 4'