Skip to content

armgit / sie

Public Imported from GitHub
0

Open-source inference server and production cluster for all the models your agent needs.

fix(release): repair audio and CUDA 13 build checks (#340)

Marton Mayer605b3fea9e6e
diff --git a/.github/workflows/release-audio.yml b/.github/workflows/release-audio.yml
index f8bc8e85b..5cfd26383 100644
--- a/.github/workflows/release-audio.yml
+++ b/.github/workflows/release-audio.yml
@@ -55,7 +55,7 @@ jobs:
run: |
set -euo pipefail
test "$RELEASE_TAG" = "v$RELEASE_VERSION"
- test "$(git rev-parse HEAD)" = "$RELEASE_SHA"
+ test "$(git -c safe.directory="$GITHUB_WORKSPACE" rev-parse HEAD)" = "$RELEASE_SHA"
filename="$(mise --no-config exec [email protected] [email protected] [email protected] [email protected] -- python -c 'import runpy; print(runpy.run_path("packages/sie_audio_prep/build_wheel.py")["AUDIO_WHEEL_FILENAME"])')"
test "$filename" = "sie_audio_prep-$RELEASE_VERSION-cp312-abi3-manylinux_2_28_x86_64.whl"
echo "filename=$filename" >> "$GITHUB_OUTPUT"
diff --git a/RELEASE.md b/RELEASE.md
index 7591a9f48..4cfb38fba 100644
--- a/RELEASE.md
+++ b/RELEASE.md
@@ -138,9 +138,16 @@ Finalize these identities before enabling uploads:
PyPI/npm upload jobs live in the top-level workflow so the configured OIDC
identity is unambiguous. Existing package names use their existing registry
-settings; only new PyPI projects need pending publishers. Register config and
-MCP when their first upload is ready. Audio assets do not need another PyPI
-registration.
+settings; only new PyPI projects need pending publishers. PyPI allows only one
+pending project per publisher identity, so bootstrap config and MCP sequentially
+with the same repository, `release.yml` workflow, and `pypi` environment. Register
+`sie-config` first. Its next OIDC token exchange creates the project and converts
+the pending publisher into an ordinary publisher. Then register `sie-mcp` and
+request another original-run publisher retry so a new token exchange creates it.
+One upload attempt mints its token only once; adding the second pending publisher
+does not extend a token already issued to the first attempt. Recovery verifies
+and skips byte-identical files already uploaded and consumes the same retained
+archives. Audio assets do not need another PyPI registration.
npm supports one trusted publisher per package. Its actual upload job uses a
GitHub-hosted runner and a pinned supported npm version. Ordinary builds and
diff --git a/tools/ci/check_release_contract.py b/tools/ci/check_release_contract.py
index bc18d6668..e78ea10f2 100755
--- a/tools/ci/check_release_contract.py
+++ b/tools/ci/check_release_contract.py
@@ -155,6 +155,7 @@ MPL_LICENSE_EXCEPTION_NAMES = frozenset(
AUDIO_MANYLINUX_IMAGE = (
"quay.io/pypa/manylinux_2_28_x86_64@sha256:4dc41da7df20400310c80d162a2fe2d2c2f3d9734d8dec20f6b9843711618deb"
)
+AUDIO_SOURCE_ASSERTION = 'test "$(git -c safe.directory="$GITHUB_WORKSPACE" rev-parse HEAD)" = "$RELEASE_SHA"'
TRUSTED_WRITE_CONDITION_TERMS = (
"inputs.publish == true",
"vars.PUBLIC_RELEASE_PUBLISHING_ENABLED == 'true'",
@@ -646,6 +647,60 @@ def audio_release_contract() -> tuple[str, str, str]:
return version, filename, url
+def default_run_shell(block: str, indent: int) -> str | None:
+ """Read defaults.run.shell from block mappings; unsupported forms fail closed."""
+ lines = block.splitlines()
+ for key in ("defaults", "run", "shell"):
+ prefix = f"{' ' * indent}{key}:"
+ found = [index for index, line in enumerate(lines) if line.startswith(prefix)]
+ if not found:
+ return None
+ if len(found) != 1:
+ return ""
+ start = found[0]
+ value = lines[start].removeprefix(prefix).strip()
+ if key == "shell":
+ return value
+ if value:
+ return ""
+ end = next(
+ (
+ index
+ for index in range(start + 1, len(lines))
+ if lines[index].strip()
+ and not lines[index].lstrip().startswith("#")
+ and len(lines[index]) - len(lines[index].lstrip()) <= indent
+ ),
+ len(lines),
+ )
+ lines = lines[start + 1 : end]
+ indent += 2
+ return None
+
+
+def audio_checkout_errors(build: str, workflow: str) -> list[str]:
+ """Require the container's exact-source check to trust only its current workspace."""
+ lines = step_lines(build)
+ assertion = exact_commands(lines, (("rev-parse", re.compile(re.escape(AUDIO_SOURCE_ASSERTION))),))
+ shell = default_run_shell(build, JOB_FIELD_INDENT)
+ if shell is None:
+ shell = default_run_shell(workflow, 0)
+ if assertion is not None:
+ start, end = step_bounds(lines, assertion[0][0])
+ active = [line.removeprefix("- ") for line in lines[start:end]]
+ if (
+ shell == "bash"
+ and "set -euo pipefail" in active
+ and job_scalar(build, "if") is None
+ and job_scalar(build, "continue-on-error") is None
+ and not any(line.startswith(("if:", "continue-on-error:", "shell:", "set +")) for line in active)
+ and not refresh_control_flow(lines, assertion)
+ and build.count("safe.directory") == 1
+ ):
+ return []
+ return ["native audio source check must compare the exact SHA with command-scoped workspace Git trust"]
+
+
def audio_release_errors() -> list[str]:
errors: list[str] = []
version, filename, url = audio_release_contract()
@@ -660,6 +715,9 @@ def audio_release_errors() -> list[str]:
if not isinstance(rust, dict) or rust.get("version") != "1.98.1":
errors.append("native audio release must use the repository Rust 1.98.1 pin")
workflow = (ROOT / ".github/workflows/release-audio.yml").read_text()
+ errors.extend(
+ audio_checkout_errors(workflow_job_blocks(".github/workflows/release-audio.yml").get("build", ""), workflow)
+ )
required = (
"ref: ${{ inputs.sha }}",
AUDIO_MANYLINUX_IMAGE,
diff --git a/tools/ci/cuda13_image_smoke.py b/tools/ci/cuda13_image_smoke.py
index ecfdab01c..253016481 100644
--- a/tools/ci/cuda13_image_smoke.py
+++ b/tools/ci/cuda13_image_smoke.py
@@ -103,6 +103,8 @@ def docker_commands(bundle: str, image_tag: str) -> list[list[str]]:
"docker",
"run",
"--rm",
+ "--pull",
+ "never",
"--network",
"none",
"-e",
diff --git a/tools/ci/tests/test_audio_checkout.py b/tools/ci/tests/test_audio_checkout.py
new file mode 100644
index 000000000..9471fce24
--- /dev/null
+++ b/tools/ci/tests/test_audio_checkout.py
@@ -0,0 +1,211 @@
+from __future__ import annotations
+
+import os
+import subprocess
+from pathlib import Path
+
+import pytest
+
+from tools.ci import check_release_contract as contract
+
+
+def audio_workflow() -> str:
+ return (contract.ROOT / ".github/workflows/release-audio.yml").read_text()
+
+
+def audio_build() -> str:
+ return contract.workflow_job_blocks(".github/workflows/release-audio.yml")["build"]
+
+
+def test_audio_checkout_contract() -> None:
+ assert contract.audio_checkout_errors(audio_build(), audio_workflow()) == []
+
+
+ "replacement",
+ [
+ "",
+ f"# {contract.AUDIO_SOURCE_ASSERTION}",
+ f"echo {contract.AUDIO_SOURCE_ASSERTION}",
+ f"{contract.AUDIO_SOURCE_ASSERTION} || true",
+ contract.AUDIO_SOURCE_ASSERTION.replace(' -c safe.directory="$GITHUB_WORKSPACE"', ""),
+ contract.AUDIO_SOURCE_ASSERTION.replace("$GITHUB_WORKSPACE", "*"),
+ contract.AUDIO_SOURCE_ASSERTION.replace("$RELEASE_SHA", "$OTHER_SHA"),
+ 'git config --global --add safe.directory "$GITHUB_WORKSPACE"\n ' + contract.AUDIO_SOURCE_ASSERTION,
+ f"set +e\n {contract.AUDIO_SOURCE_ASSERTION}",
+ f"if false; then\n {contract.AUDIO_SOURCE_ASSERTION}\n fi",
+ ],
+ ids=[
+ "missing",
+ "commented",
+ "echoed",
+ "suppressed",
+ "missing-trust",
+ "wildcard-trust",
+ "wrong-source",
+ "global-trust",
+ "no-errexit",
+ "inactive-shell",
+ ],
+)
+def test_audio_checkout_rejects_weakened_source_check(replacement: str) -> None:
+ build = audio_build()
+ assert build.count(contract.AUDIO_SOURCE_ASSERTION) == 1
+ assert contract.audio_checkout_errors(build.replace(contract.AUDIO_SOURCE_ASSERTION, replacement), audio_workflow())
+
+
+ "setting", ["if: false", "continue-on-error: true", "shell: bash {0}", "shell: sh", "shell: bash"]
+)
[email protected]("first_key", [False, True])
+def test_audio_checkout_rejects_skipped_suppressed_or_shell_overridden_step(setting: str, first_key: bool) -> None:
+ build = audio_build()
+ original = " - id: contract\n"
+ assert build.count(original) == 1
+ replacement = f" - {setting}\n id: contract\n" if first_key else f"{original} {setting}\n"
+ assert contract.audio_checkout_errors(build.replace(original, replacement), audio_workflow())
+
+
+ ("workflow_shell", "job_shell", "valid"),
+ [
+ ("bash", None, True),
+ (None, None, False),
+ ("sh", None, False),
+ ("bash {0}", None, False),
+ ("bash", "bash", True),
+ ("bash", "sh", False),
+ ("bash", "bash {0}", False),
+ ("bash", "", False),
+ ("sh", "bash", True),
+ (None, "bash", True),
+ ],
+)
+def test_audio_checkout_requires_effective_bash_default(workflow_shell, job_shell, valid) -> None:
+ workflow = audio_workflow()
+ default = "defaults:\n run:\n shell: bash\n"
+ assert workflow.count(default) == 1
+ replacement = f"defaults:\n run:\n shell: {workflow_shell}\n" if workflow_shell is not None else ""
+ workflow = workflow.replace(default, replacement)
+ build = audio_build()
+ if job_shell is not None:
+ build = build.replace(" steps:\n", f" defaults:\n run:\n shell: {job_shell}\n steps:\n")
+ assert (contract.audio_checkout_errors(build, workflow) == []) is valid
+
+
+def test_audio_checkout_job_working_directory_default_keeps_workflow_shell() -> None:
+ build = audio_build().replace(
+ " steps:\n", " defaults:\n run:\n working-directory: .\n steps:\n"
+ )
+ assert contract.audio_checkout_errors(build, audio_workflow()) == []
+
+
[email protected]("scope", ["workflow", "job"])
[email protected]("shell", ["bash", "sh"])
[email protected]("comment_after", ["defaults", "run"])
+def test_audio_checkout_default_comments_do_not_change_shell_precedence(scope, shell, comment_after) -> None:
+ workflow = audio_workflow()
+ build = audio_build()
+ indent = "" if scope == "workflow" else " "
+ defaults = f"{indent}defaults:\n{indent} run:\n{indent} shell: {shell}\n"
+ defaults = defaults.replace(f"{comment_after}:\n", f"{comment_after}:\n# unindented comment\n")
+ if scope == "workflow":
+ workflow = workflow.replace("defaults:\n run:\n shell: bash\n", defaults)
+ else:
+ build = build.replace(" steps:\n", f"{defaults} steps:\n")
+ assert (contract.audio_checkout_errors(build, workflow) == []) is (shell == "bash")
+
+
[email protected]("setting", ["if: false", "continue-on-error: true"])
+def test_audio_checkout_rejects_skipped_or_suppressed_job(setting: str) -> None:
+ build = audio_build().replace(" build:\n", f" build:\n {setting}\n")
+ assert contract.audio_checkout_errors(build, audio_workflow())
+
+
+ "defaults",
+ [
+ "defaults: {run: {shell: bash}}\n",
+ "defaults:\n run:\n shell: bash\n shell: sh\n",
+ "defaults:\n run: {}\n shell: bash\n",
+ ],
+)
+def test_audio_checkout_rejects_unsupported_or_ambiguous_defaults(defaults: str) -> None:
+ workflow = audio_workflow().replace("defaults:\n run:\n shell: bash\n", defaults)
+ assert contract.audio_checkout_errors(audio_build(), workflow)
+
+
[email protected]("default", ["", "defaults:\n run:\n shell: sh\n"])
+def test_audio_release_contract_validates_workflow_shell_context(monkeypatch, default: str) -> None:
+ workflow_path = contract.ROOT / ".github/workflows/release-audio.yml"
+ read_text = Path.read_text
+ changed = audio_workflow().replace("defaults:\n run:\n shell: bash\n", default)
+ monkeypatch.setattr(Path, "read_text", lambda path: changed if path == workflow_path else read_text(path))
+ assert (
+ "native audio source check must compare the exact SHA with command-scoped workspace Git trust"
+ in contract.audio_release_errors()
+ )
+
+
+def test_audio_checkout_ownership_trust_is_command_and_workspace_scoped(tmp_path: Path) -> None:
+ environment = {key: value for key, value in os.environ.items() if not key.startswith("GIT_")}
+ environment.update({"GIT_CONFIG_NOSYSTEM": "1", "GIT_CONFIG_GLOBAL": os.devnull, "LC_ALL": "C"})
+ workspace = (tmp_path / "workspace").resolve()
+ other = (tmp_path / "other").resolve()
+ for repository in (workspace, other):
+ repository.mkdir()
+ subprocess.run(["/usr/bin/git", "init", "--quiet"], cwd=repository, env=environment, check=True)
+ subprocess.run(
+ [
+ "/usr/bin/git",
+ "-c",
+ "user.name=Test",
+ "-c",
+ "commit",
+ "--quiet",
+ "--allow-empty",
+ "-m",
+ "test",
+ ],
+ cwd=repository,
+ env=environment,
+ check=True,
+ )
+ sha = subprocess.check_output(
+ ["/usr/bin/git", "rev-parse", "HEAD"], cwd=workspace, env=environment, text=True
+ ).strip()
+ environment.update({"GIT_TEST_ASSUME_DIFFERENT_OWNER": "1", "GITHUB_WORKSPACE": str(workspace), "RELEASE_SHA": sha})
+ plain = subprocess.run(
+ ["/usr/bin/git", "rev-parse", "HEAD"],
+ cwd=workspace,
+ env=environment,
+ capture_output=True,
+ text=True,
+ check=False,
+ )
+ assert plain.returncode != 0
+ assert "dubious ownership" in plain.stderr
+
+ assertion = next(line.strip() for line in audio_build().splitlines() if "rev-parse" in line)
+ for expected_sha, expected_success in ((sha, True), ("0" * 40, False)):
+ result = subprocess.run( # noqa: S603 - execute the repository workflow assertion in an isolated test repo
+ ["/bin/bash", "-c", f"set -euo pipefail\n{assertion}"],
+ cwd=workspace,
+ env={**environment, "RELEASE_SHA": expected_sha},
+ capture_output=True,
+ text=True,
+ check=False,
+ )
+ assert (result.returncode == 0) is expected_success, result.stderr
+ assert "dubious ownership" not in result.stderr
+
+ for repository, command in (
+ (workspace, ["/usr/bin/git", "rev-parse", "HEAD"]),
+ (other, ["/usr/bin/git", "-c", f"safe.directory={workspace}", "rev-parse", "HEAD"]),
+ ):
+ result = subprocess.run( # noqa: S603 - fixed Git commands in isolated test repositories
+ command, cwd=repository, env=environment, capture_output=True, text=True, check=False
+ )
+ assert result.returncode != 0
+ assert "dubious ownership" in result.stderr
diff --git a/tools/ci/tests/test_cuda13_image_smoke.py b/tools/ci/tests/test_cuda13_image_smoke.py
index 2576912cb..dff9ec834 100644
--- a/tools/ci/tests/test_cuda13_image_smoke.py
+++ b/tools/ci/tests/test_cuda13_image_smoke.py
@@ -18,7 +18,7 @@ def test_commands_are_networkless_offline_and_never_publish(bundle):
assert len(commands) == 2
for command in commands:
assert command[:3] == ["docker", "run", "--rm"]
- assert ["--network", "none"] == command[3:5]
+ assert command[3:7] == ["--pull", "never", "--network", "none"]
assert "HF_HUB_OFFLINE=1" in command
assert "TRANSFORMERS_OFFLINE=1" in command
assert not {"push", "login"} & set(command)
diff --git a/tools/ci/tests/test_docker_task.py b/tools/ci/tests/test_docker_task.py
index a2f72dafd..db12c03e3 100644
--- a/tools/ci/tests/test_docker_task.py
+++ b/tools/ci/tests/test_docker_task.py
@@ -3,9 +3,11 @@ from __future__ import annotations
import json
import subprocess
from pathlib import Path
+from unittest.mock import Mock
import pytest
+from tools.ci import cuda13_image_smoke
from tools.ci.release_artifact import create_manifest
from tools.mise_tasks import docker_task
@@ -125,6 +127,103 @@ def test_build_commands_only_load_source_bound_images():
)
[email protected]("bundle", ["sglang-cu130", "tensorrt-llm"])
+def test_release_cuda13_smoke_uses_qualified_driverless_checks(bundle, monkeypatch):
+ image = f"ghcr.io/superlinked/sie-server:v{VERSION}-cuda13-{bundle}"
+ commands = []
+ monkeypatch.setattr(docker_task, "run", commands.append)
+
+ docker_task.smoke_image(image, bundle=bundle)
+
+ assert commands == cuda13_image_smoke.docker_commands(bundle, image)
+ assert len(commands) == 2
+ for command in commands:
+ assert command[:7] == ["docker", "run", "--rm", "--pull", "never", "--network", "none"]
+ assert "HF_HUB_OFFLINE=1" in command
+ assert "TRANSFORMERS_OFFLINE=1" in command
+ assert commands[0][-2] == "-c"
+ assert commands[0][-1] == cuda13_image_smoke.validation_script(bundle)
+ assert "import tensorrt_llm" not in commands[0][-1]
+ assert "import sglang" not in commands[0][-1]
+ assert commands[1][-6:] == [image, "resolve-deps", "--bundle", bundle, "--models-dir", "/app/models"]
+
+
+ ("bundle", "extra_import"),
+ [
+ ("default", ""),
+ ("transformers5", ""),
+ ("ctranslate2", "import ctranslate2; "),
+ ("sglang", "import sglang; "),
+ ("sglang-vision-extract", "import sglang; "),
+ (None, ""),
+ ],
+)
+def test_other_release_images_keep_existing_smoke_checks(bundle, extra_import, monkeypatch):
+ commands = []
+ monkeypatch.setattr(docker_task, "run", commands.append)
+ docker_task.smoke_image(IMAGE, bundle=bundle)
+ expected = ["docker", "run", "--rm", "--pull", "never", "--network", "none"]
+ if bundle is None:
+ expected.extend([IMAGE, "--help"])
+ else:
+ expected.extend(
+ [
+ "--entrypoint",
+ "python",
+ IMAGE,
+ "-c",
+ "import sie_server, sie_sdk, sie_audio_prep, torch, transformers; "
+ + extra_import
+ + "print('release image imports passed')",
+ ]
+ )
+ assert commands == [expected]
+
+
[email protected]("bundle", ["sglang-cu130", "tensorrt-llm"])
[email protected]("failed_check", ["imports", "resolve-deps"])
+def test_failed_cuda13_release_smoke_never_exports_image(bundle, failed_check, monkeypatch, tmp_path):
+ commands = []
+
+ def run(command):
+ commands.append(command)
+ if (failed_check == "imports" and "-c" in command) or (
+ failed_check == "resolve-deps" and "resolve-deps" in command
+ ):
+ raise subprocess.CalledProcessError(1, command)
+
+ monkeypatch.setattr(docker_task, "run", run)
+ export = Mock()
+ monkeypatch.setattr(docker_task, "export_image", export)
+ monkeypatch.setattr(
+ docker_task.sys,
+ "argv",
+ [
+ "docker_task.py",
+ "build-server",
+ "--registry",
+ "ghcr.io/superlinked",
+ "--version",
+ VERSION,
+ "--platform",
+ "cuda13",
+ "--bundle",
+ bundle,
+ "--source-revision",
+ FULL_SHA,
+ "--run-id",
+ "1234",
+ "--archive-dir",
+ str(tmp_path / "artifact"),
+ ],
+ )
+
+ assert docker_task.main() == 1
+ export.assert_not_called()
+ assert len(commands) == (2 if failed_check == "imports" else 3)
+
+
def test_complete_set_verified_before_alias_commands(complete_source, monkeypatch, tmp_path):
commands = []
diff --git a/tools/mise_tasks/docker_task.py b/tools/mise_tasks/docker_task.py
index d4b045a5e..9e84e34b4 100755
--- a/tools/mise_tasks/docker_task.py
+++ b/tools/mise_tasks/docker_task.py
@@ -17,6 +17,7 @@ from typing import Any
import yaml
+from tools.ci import cuda13_image_smoke
from tools.ci.release_artifact import create_manifest, validate_manifest
from tools.ci.release_guard import api, stable_version
@@ -290,17 +291,18 @@ def inspect_loaded(image: str, source_revision: str) -> dict[str, str]:
def smoke_image(image: str, *, bundle: str | None = None) -> None:
+ if bundle in cuda13_image_smoke.ALLOWED_BUNDLES:
+ # GPU engine imports need a host driver; use the same qualified CPU checks as PR image CI.
+ for command in cuda13_image_smoke.docker_commands(bundle, image):
+ run(command)
+ return
command = ["docker", "run", "--rm", "--pull", "never", "--network", "none"]
if bundle is not None:
imports = "import sie_server, sie_sdk, sie_audio_prep, torch, transformers; "
if bundle == "ctranslate2":
imports += "import ctranslate2; "
- elif bundle in {"sglang", "sglang-vision-extract", "sglang-cu130"}:
+ elif bundle in {"sglang", "sglang-vision-extract"}:
imports += "import sglang; "
- elif bundle == "tensorrt-llm":
- imports += "import tensorrt_llm; "
- if bundle in {"sglang-cu130", "tensorrt-llm"}:
- imports += "assert torch.version.cuda.startswith('13.'); assert transformers.__version__.startswith('5.'); "
imports += "print('release image imports passed')"
command.extend(["--entrypoint", "python", image, "-c", imports])
else: