Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ paramiko
alive_progress>=3.3.0
python-gnupg
aiohttp
blurb>=2.1.0
blurb>=2.2.0
requests>=2.34
sigstore>=4.5.0
29 changes: 21 additions & 8 deletions run_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
from buildbotapi import STALE_BUILDER_DAYS, BuildBotAPI, Builder
from release import ReleaseShelf, Tag, Task, ask_question

BLURB_MIN_VERSION = (2, 2)
SIGSTORE_MIN_VERSION = (4, 0)
BLURB_VERSION_PATTERN = r"^blurb version ([0-9.]+)"
SIGSTORE_VERSION_PATTERN = r"^sigstore ([0-9.]+)"
API_KEY_REGEXP = re.compile(r"(?P<user>\w+):(?P<key>\w+)")
RELEASE_REGEXP = re.compile(
r"(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(?P<extra>.*)?"
Expand Down Expand Up @@ -286,7 +290,6 @@ def check_tool(db: ReleaseShelf, tool: str) -> None:
check_gh = functools.partial(check_tool, tool="gh")
check_git = functools.partial(check_tool, tool="git")
check_make = functools.partial(check_tool, tool="make")
check_blurb = functools.partial(check_tool, tool="blurb")
check_autoconf = functools.partial(check_tool, tool="autoconf")
check_docker = functools.partial(check_tool, tool="docker")

Expand Down Expand Up @@ -335,20 +338,30 @@ def check_sigstore_client(db: ReleaseShelf) -> None:
)
_, stdout, _ = client.exec_command("python3 -m sigstore --version")
sigstore_version = stdout.read(1000).decode()
check_sigstore_version(sigstore_version)
check_tool_version(
"sigstore", sigstore_version, SIGSTORE_VERSION_PATTERN, SIGSTORE_MIN_VERSION
)


def check_blurb(db: ReleaseShelf) -> None:
check_tool(db, tool="blurb")
blurb_version = subprocess.check_output(["blurb", "--version"], text=True)
check_tool_version("blurb", blurb_version, BLURB_VERSION_PATTERN, BLURB_MIN_VERSION)


def check_sigstore_version(version: str) -> None:
version_match = re.match("^sigstore ([0-9.]+)", version)
if version_match:
def check_tool_version(
tool: str, version: str, pattern: str, minimum: tuple[int, ...]
) -> None:
if version_match := re.search(pattern, version):
version_tuple = tuple(int(part) for part in version_match.group(1).split("."))
if version_tuple >= (4, 0):
if version_tuple >= minimum:
# good version
return

expected = ".".join(str(part) for part in minimum)
raise ReleaseException(
f"Sigstore version not detected or not valid. "
f"Expecting >= 4.0.0, got: {version}"
f"{tool} version not detected or not valid. "
f"Expecting >= {expected}, got: {version}"
)


Expand Down
45 changes: 35 additions & 10 deletions tests/test_run_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,52 @@

import run_release
from release import ReleaseShelf, Tag
from run_release import ReleaseException
from run_release import (
BLURB_MIN_VERSION,
BLURB_VERSION_PATTERN,
SIGSTORE_MIN_VERSION,
SIGSTORE_VERSION_PATTERN,
ReleaseException,
)


@pytest.mark.parametrize(
"version",
["sigstore 4.0.0", "sigstore 4.1.0"],
["version", "pattern", "minimum"],
[
("blurb version 2.2.0", BLURB_VERSION_PATTERN, BLURB_MIN_VERSION),
("blurb version 2.10.0", BLURB_VERSION_PATTERN, BLURB_MIN_VERSION),
("blurb version 3.0.0", BLURB_VERSION_PATTERN, BLURB_MIN_VERSION),
("sigstore 4.0", SIGSTORE_VERSION_PATTERN, SIGSTORE_MIN_VERSION),
("sigstore 4.0.0", SIGSTORE_VERSION_PATTERN, SIGSTORE_MIN_VERSION),
("sigstore 4.1.0", SIGSTORE_VERSION_PATTERN, SIGSTORE_MIN_VERSION),
],
)
def test_check_sigstore_version_success(version: str) -> None:
def test_check_tool_version_success(
version: str, pattern: str, minimum: tuple[int, ...]
) -> None:
# Verify runs with no exceptions
run_release.check_sigstore_version(version)
run_release.check_tool_version("tool", version, pattern, minimum)


@pytest.mark.parametrize(
"version",
["sigstore 3.4.0", "sigstore 3.6.2", "sigstore 3.6.6", ""],
["version", "pattern", "minimum"],
[
("blurb version 1.3.0", BLURB_VERSION_PATTERN, BLURB_MIN_VERSION),
("blurb version 2.1.0", BLURB_VERSION_PATTERN, BLURB_MIN_VERSION),
("sigstore 3.6.6", SIGSTORE_VERSION_PATTERN, SIGSTORE_MIN_VERSION),
("sigstore 4.0.0", BLURB_VERSION_PATTERN, BLURB_MIN_VERSION),
("", BLURB_VERSION_PATTERN, BLURB_MIN_VERSION),
],
)
def test_check_sigstore_version_exception(version: str) -> None:
def test_check_tool_version_exception(
version: str, pattern: str, minimum: tuple[int, ...]
) -> None:
expected = ".".join(str(part) for part in minimum)
with pytest.raises(
ReleaseException, match="Sigstore version not detected or not valid"
ReleaseException,
match=rf"tool version not detected or not valid\. Expecting >= {expected}",
):
run_release.check_sigstore_version(version)
run_release.check_tool_version("tool", version, pattern, minimum)


@pytest.mark.parametrize(
Expand Down
Loading