Skip to content

Commit b84897f

Browse files
hugovkezio-melotti
andauthored
Require blurb >= 2.3 (#459)
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
1 parent bea981b commit b84897f

3 files changed

Lines changed: 55 additions & 19 deletions

File tree

‎requirements.in‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ paramiko
44
alive_progress>=3.3.0
55
python-gnupg
66
aiohttp
7-
blurb>=2.1.0
7+
blurb>=2.3.0
88
requests>=2.34
99
sigstore>=4.5.0

‎run_release.py‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
from buildbotapi import STALE_BUILDER_DAYS, BuildBotAPI, Builder
4040
from release import ReleaseShelf, Tag, Task, ask_question
4141

42+
BLURB_MIN_VERSION = (2, 3)
43+
SIGSTORE_MIN_VERSION = (4, 0)
44+
BLURB_VERSION_PATTERN = r"^blurb version ([0-9.]+)"
45+
SIGSTORE_VERSION_PATTERN = r"^sigstore ([0-9.]+)"
4246
API_KEY_REGEXP = re.compile(r"(?P<user>\w+):(?P<key>\w+)")
4347
RELEASE_REGEXP = re.compile(
4448
r"(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(?P<extra>.*)?"
@@ -286,7 +290,6 @@ def check_tool(db: ReleaseShelf, tool: str) -> None:
286290
check_gh = functools.partial(check_tool, tool="gh")
287291
check_git = functools.partial(check_tool, tool="git")
288292
check_make = functools.partial(check_tool, tool="make")
289-
check_blurb = functools.partial(check_tool, tool="blurb")
290293
check_autoconf = functools.partial(check_tool, tool="autoconf")
291294
check_docker = functools.partial(check_tool, tool="docker")
292295

@@ -335,20 +338,30 @@ def check_sigstore_client(db: ReleaseShelf) -> None:
335338
)
336339
_, stdout, _ = client.exec_command("python3 -m sigstore --version")
337340
sigstore_version = stdout.read(1000).decode()
338-
check_sigstore_version(sigstore_version)
341+
check_tool_version(
342+
"sigstore", sigstore_version, SIGSTORE_VERSION_PATTERN, SIGSTORE_MIN_VERSION
343+
)
344+
345+
346+
def check_blurb(db: ReleaseShelf) -> None:
347+
check_tool(db, tool="blurb")
348+
blurb_version = subprocess.check_output(["blurb", "--version"], text=True)
349+
check_tool_version("blurb", blurb_version, BLURB_VERSION_PATTERN, BLURB_MIN_VERSION)
339350

340351

341-
def check_sigstore_version(version: str) -> None:
342-
version_match = re.match("^sigstore ([0-9.]+)", version)
343-
if version_match:
352+
def check_tool_version(
353+
tool: str, version: str, pattern: str, minimum: tuple[int, ...]
354+
) -> None:
355+
if version_match := re.search(pattern, version):
344356
version_tuple = tuple(int(part) for part in version_match.group(1).split("."))
345-
if version_tuple >= (4, 0):
357+
if version_tuple >= minimum:
346358
# good version
347359
return
348360

361+
expected = ".".join(str(part) for part in minimum)
349362
raise ReleaseException(
350-
f"Sigstore version not detected or not valid. "
351-
f"Expecting >= 4.0.0, got: {version}"
363+
f"{tool} version not detected or not valid. "
364+
f"Expecting >= {expected}, got: {version}"
352365
)
353366

354367

‎tests/test_run_release.py‎

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,50 @@
1212

1313
import run_release
1414
from release import ReleaseShelf, Tag
15-
from run_release import ReleaseException
15+
from run_release import (
16+
BLURB_VERSION_PATTERN,
17+
SIGSTORE_VERSION_PATTERN,
18+
ReleaseException,
19+
)
1620

1721

1822
@pytest.mark.parametrize(
19-
"version",
20-
["sigstore 4.0.0", "sigstore 4.1.0"],
23+
["version", "pattern", "minimum"],
24+
[
25+
("blurb version 2.2.0", BLURB_VERSION_PATTERN, (2, 2)),
26+
("blurb version 2.10.0", BLURB_VERSION_PATTERN, (2, 2)),
27+
("blurb version 3.0.0", BLURB_VERSION_PATTERN, (2, 2)),
28+
("sigstore 4.0", SIGSTORE_VERSION_PATTERN, (4, 0)),
29+
("sigstore 4.0.0", SIGSTORE_VERSION_PATTERN, (4, 0)),
30+
("sigstore 4.1.0", SIGSTORE_VERSION_PATTERN, (4, 0)),
31+
],
2132
)
22-
def test_check_sigstore_version_success(version: str) -> None:
33+
def test_check_tool_version_success(
34+
version: str, pattern: str, minimum: tuple[int, ...]
35+
) -> None:
2336
# Verify runs with no exceptions
24-
run_release.check_sigstore_version(version)
37+
run_release.check_tool_version("tool", version, pattern, minimum)
2538

2639

2740
@pytest.mark.parametrize(
28-
"version",
29-
["sigstore 3.4.0", "sigstore 3.6.2", "sigstore 3.6.6", ""],
41+
["version", "pattern", "minimum"],
42+
[
43+
("blurb version 1.3.0", BLURB_VERSION_PATTERN, (2, 2)),
44+
("blurb version 2.1.0", BLURB_VERSION_PATTERN, (2, 2)),
45+
("sigstore 3.6.6", SIGSTORE_VERSION_PATTERN, (4, 0)),
46+
("sigstore 4.0.0", BLURB_VERSION_PATTERN, (2, 2)),
47+
("", BLURB_VERSION_PATTERN, (2, 2)),
48+
],
3049
)
31-
def test_check_sigstore_version_exception(version: str) -> None:
50+
def test_check_tool_version_exception(
51+
version: str, pattern: str, minimum: tuple[int, ...]
52+
) -> None:
53+
expected = ".".join(str(part) for part in minimum)
3254
with pytest.raises(
33-
ReleaseException, match="Sigstore version not detected or not valid"
55+
ReleaseException,
56+
match=rf"tool version not detected or not valid\. Expecting >= {expected}",
3457
):
35-
run_release.check_sigstore_version(version)
58+
run_release.check_tool_version("tool", version, pattern, minimum)
3659

3760

3861
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)