|
4 | 4 | import bb.tinfoil
|
5 | 5 | import git
|
6 | 6 |
|
7 |
| -# TODO: add minor version numbers once we have them |
8 |
| -RE_VERSION_TAG = "v(?P<year>[0-9][0-9])\.(?P<month>[0-9][0-9])" |
9 |
| -RE_VERSION_BB = "(?P<year>[0-9][0-9])\.(?P<month>[0-9][0-9])(?P<dev>$|\+dev)" |
| 7 | +RE_VERSION_TAG = r"v(?P<year>[0-9][0-9])\.(?P<month>[0-9][0-9])(?:\.(?P<minor>[0-9]+))?" |
| 8 | +RE_VERSION_BB = r"(?P<year>[0-9][0-9])\.(?P<month>[0-9][0-9])(?:(?P<dev>$|\+dev)|(?:\.(?P<minor>[0-9]+))?)" |
10 | 9 |
|
11 | 10 |
|
12 | 11 | def bb_variables(names):
|
@@ -38,44 +37,53 @@ def git_prev_tag():
|
38 | 37 | return (tag, commit_is_tagged)
|
39 | 38 |
|
40 | 39 |
|
| 40 | +def version_tuple(version): |
| 41 | + year = int(version["year"]) |
| 42 | + month = int(version["month"]) |
| 43 | + minor = int(version["minor"] or "0") |
| 44 | + |
| 45 | + return (year, month, minor) |
| 46 | + |
| 47 | + |
41 | 48 | def check_version(distro_version):
|
42 | 49 | prev_tag, commit_is_tagged = git_prev_tag()
|
43 | 50 |
|
44 | 51 | print(f"Checking tag {prev_tag} against version {distro_version}")
|
45 | 52 |
|
46 | 53 | version_tag = re.fullmatch(RE_VERSION_TAG, prev_tag)
|
47 |
| - version_tag_numeric = int(version_tag["year"]) * 100 + int(version_tag["month"]) |
| 54 | + version_tag_tuple = version_tuple(version_tag) |
48 | 55 |
|
49 | 56 | version_bb = re.fullmatch(RE_VERSION_BB, distro_version)
|
50 |
| - version_bb_numeric = int(version_bb["year"]) * 100 + int(version_bb["month"]) |
| 57 | + version_bb_tuple = version_tuple(version_bb) |
51 | 58 |
|
52 | 59 | if commit_is_tagged:
|
53 | 60 | # The version in a tagged commit must match the version in the tag's name.
|
54 | 61 | assert version_bb["dev"] == ""
|
55 |
| - assert version_tag_numeric == version_bb_numeric |
56 |
| - |
57 |
| - elif version_bb["dev"] == "": |
58 |
| - # Release candidates already have the next release version set, |
59 |
| - # but it must be newer than any tag in the current commit's history. |
60 |
| - assert version_bb_numeric > version_tag_numeric |
| 62 | + assert version_tag_tuple == version_bb_tuple |
61 | 63 |
|
62 |
| - else: |
| 64 | + elif version_bb["dev"]: |
63 | 65 | # Non release candidate versions should have the previous tagged
|
64 | 66 | # version number plus the +dev suffix set.
|
65 |
| - assert version_bb_numeric == version_tag_numeric |
| 67 | + assert version_bb_tuple == version_tag_tuple |
| 68 | + |
| 69 | + else: |
| 70 | + # Release candidates already have the next release version set, |
| 71 | + # but it must be newer than any tag in the current commit's history. |
| 72 | + assert version_bb_tuple > version_tag_tuple |
66 | 73 |
|
67 | 74 |
|
68 | 75 | def check_codename(codename):
|
69 | 76 | base_ref = os.environ.get("GITHUB_BASE_REF")
|
70 | 77 | ref = os.environ.get("GITHUB_REF_NAME")
|
71 | 78 | ref_type = os.environ.get("GITHUB_REF_TYPE")
|
72 | 79 |
|
73 |
| - if base_ref: |
74 |
| - print(f"Checking codename {codename} against pull request into {base_ref}") |
75 |
| - assert codename == f"tacos-{base_ref}" |
76 |
| - elif ref and ref_type == "branch": |
77 |
| - print(f"Checking codename {codename} against branch {ref}") |
78 |
| - assert codename == f"tacos-{ref}" |
| 80 | + branch = base_ref or (ref if ref_type == "branch" else None) |
| 81 | + |
| 82 | + if branch and branch.startswith("stable-"): |
| 83 | + print("Running for a stable branch. Skipping codename check") |
| 84 | + elif branch: |
| 85 | + print(f"Checking codename {codename} against branch {branch}") |
| 86 | + assert codename == f"tacos-{branch}" |
79 | 87 | elif ref_type == "tag":
|
80 | 88 | print("Running for a tag. Skipping codename check")
|
81 | 89 | else:
|
|
0 commit comments