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): format generated SDK package metadata (#339)

Marton Mayer36bd49e15f68
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index c8fb2a353..fda3c4ecc 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -98,14 +98,16 @@ jobs:
git checkout -B "$branch" FETCH_HEAD
mise exec -- uv lock --project .
mise exec -- pnpm install --lockfile-only
+ mise exec -- pnpm --filter @superlinked/sie-sdk install --frozen-lockfile --ignore-scripts
+ mise exec -- pnpm --dir packages/sie_ts_sdk exec biome format --write package.json
mise exec -- cargo metadata --format-version 1 > /dev/null
mise exec -- python -I tools/ci/release_openapi.py
- if git diff --quiet -- uv.lock pnpm-lock.yaml Cargo.lock packages/sie_server/openapi.json packages/sie_gateway/openapi.json; then
+ if git diff --quiet -- uv.lock pnpm-lock.yaml Cargo.lock packages/sie_ts_sdk/package.json packages/sie_server/openapi.json packages/sie_gateway/openapi.json; then
exit 0
fi
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- git add uv.lock pnpm-lock.yaml Cargo.lock packages/sie_server/openapi.json packages/sie_gateway/openapi.json
+ git add uv.lock pnpm-lock.yaml Cargo.lock packages/sie_ts_sdk/package.json packages/sie_server/openapi.json packages/sie_gateway/openapi.json
git commit -m 'chore: refresh release locks and OpenAPI versions'
git push origin "HEAD:refs/heads/$branch"
- id: release-pr-head
diff --git a/RELEASE.md b/RELEASE.md
index 408f8a7d5..7591a9f48 100644
--- a/RELEASE.md
+++ b/RELEASE.md
@@ -25,6 +25,9 @@ committed server and gateway OpenAPI documents. CI regenerates those documents
and requires identical bytes, so they are not release-please extra files: its
JSON rewrite changes number formatting and precision, string escapes, and key
order. Config and MCP join this train for their first PyPI publication.
+The refresh also formats the SDK package metadata rewritten by release-please
+with the lockfile-pinned Biome version and the SDK's formatter configuration.
+Only that manifest is formatted; its release version and metadata are preserved.
Independently versioned implementation crates are not silently renumbered: a
Rust worker image follows the release image tag even where its crate has an
independent version.
@@ -182,6 +185,27 @@ artifact destination.
## Recovery
+### Release-PR authoring
+
+To refresh an open release PR, use the push-to-`main` authoring workflow. Merge
+any automation repair through normal review and CI, then approve that commit's
+`release-automation` job. The manual entrypoint below only recovers failed
+publication; it does not refresh release PRs.
+
+Before resuming a waiting authoring run, inspect its source revision and workflow:
+release-please can read current `main`, but the run still executes the workflow
+from its original push. An old run can therefore generate current release files
+using outdated refresh steps. Cancel obsolete queued **push** runs before
+cancelling the old waiting run, then retain the authoring run from the intended
+current source. Do not cancel publication or recovery runs as part of this
+cleanup. Keep the environment protections and approve the retained run normally.
+If the intended push run was cancelled, rerun that exact push run after checking
+its source and workflow, while GitHub still permits the rerun; do not replay the
+obsolete backlog. Verify the generated PR's source ancestry after refresh, too:
+the approved run's revision does not freeze release-please's reads of `main`.
+
+### Artifact publication
+
Retain release build artifacts for at least 30 days. Normal recovery reruns
failed publication jobs from the original release workflow run. This preserves
the original commit/ref and reuses the original outputs.
diff --git a/tools/ci/check_release_contract.py b/tools/ci/check_release_contract.py
index 38fa5fdd6..bc18d6668 100755
--- a/tools/ci/check_release_contract.py
+++ b/tools/ci/check_release_contract.py
@@ -78,6 +78,9 @@ OPENAPI_VERSION_PATHS = {
"packages/sie_gateway/openapi.json",
}
OPENAPI_STAMP_COMMAND = "mise exec -- python -I tools/ci/release_openapi.py"
+SDK_PACKAGE_PATH = "packages/sie_ts_sdk/package.json"
+SDK_INSTALL_COMMAND = "mise exec -- pnpm --filter @superlinked/sie-sdk install --frozen-lockfile --ignore-scripts"
+SDK_FORMAT_COMMAND = "mise exec -- pnpm --dir packages/sie_ts_sdk exec biome format --write package.json"
PLAIN_PATHS = r"((?:[\w.][\w./-]* )*[\w.][\w./-]*)"
CONTRACTS_OPENAPI_COMMANDS = (
("mise run openapi", re.compile(re.escape("- run: mise run openapi"))),
@@ -91,6 +94,13 @@ REFRESH_OPENAPI_COMMANDS = (
("git commit", re.compile(r"git commit -m '[^'\\]*'")),
("git push", re.compile(re.escape('git push origin "HEAD:refs/heads/$branch"'))),
)
+REFRESH_METADATA_COMMANDS = (
+ REFRESH_OPENAPI_COMMANDS[0],
+ ("pnpm install", re.compile(re.escape("mise exec -- pnpm install --lockfile-only"))),
+ ("pnpm --filter", re.compile(re.escape(SDK_INSTALL_COMMAND))),
+ ("biome", re.compile(re.escape(SDK_FORMAT_COMMAND))),
+ *REFRESH_OPENAPI_COMMANDS[2:],
+)
SHELL_CONTROL_FLOW = frozenset(
{
"if",
@@ -462,6 +472,16 @@ def release_openapi_errors(refresh: str, contracts: str, stamped: set[str]) -> l
"release PR refresh must run checkout, OpenAPI stamp, diff, add, commit, and push once each, "
"in order, as exact commands without failure suppression"
)
+ metadata = exact_commands(refresh_lines, REFRESH_METADATA_COMMANDS)
+ if (
+ metadata is None
+ or any(SDK_PACKAGE_PATH not in match.group(1).split() for _, match in metadata[4:6])
+ or len({step_bounds(refresh_lines, index) for index, _ in metadata}) != 1
+ ):
+ errors.append(
+ "release PR refresh must refresh the pnpm lock, install the SDK's pinned formatter, and format "
+ "its package.json before diff and staging, in the same step as checkout, commit, and push"
+ )
return errors
diff --git a/tools/ci/tests/test_release_contract.py b/tools/ci/tests/test_release_contract.py
index d85201a17..d70ef995a 100644
--- a/tools/ci/tests/test_release_contract.py
+++ b/tools/ci/tests/test_release_contract.py
@@ -187,6 +187,89 @@ def move_before(lines: list[str], moved: str, anchor: str) -> None:
lines.insert(line_index(lines, anchor), line)
+ ("command", "replacement"),
+ [
+ (contract.SDK_INSTALL_COMMAND, ""),
+ (contract.SDK_INSTALL_COMMAND, f"{contract.SDK_INSTALL_COMMAND} || true"),
+ (
+ contract.SDK_INSTALL_COMMAND,
+ contract.SDK_INSTALL_COMMAND.replace("--frozen-lockfile", "--no-frozen-lockfile"),
+ ),
+ (contract.SDK_INSTALL_COMMAND, contract.SDK_INSTALL_COMMAND.replace(" --ignore-scripts", "")),
+ (contract.SDK_INSTALL_COMMAND, contract.SDK_INSTALL_COMMAND.replace("@superlinked/sie-sdk", "other-package")),
+ (contract.SDK_FORMAT_COMMAND, ""),
+ (contract.SDK_FORMAT_COMMAND, f"# {contract.SDK_FORMAT_COMMAND}"),
+ (contract.SDK_FORMAT_COMMAND, f"echo {contract.SDK_FORMAT_COMMAND}"),
+ (contract.SDK_FORMAT_COMMAND, f"{contract.SDK_FORMAT_COMMAND} || true"),
+ (
+ contract.SDK_FORMAT_COMMAND,
+ "mise exec -- pnpm dlx @biomejs/biome format --write packages/sie_ts_sdk/package.json",
+ ),
+ (contract.SDK_FORMAT_COMMAND, contract.SDK_FORMAT_COMMAND.replace(" --write", "")),
+ (
+ contract.SDK_FORMAT_COMMAND,
+ contract.SDK_FORMAT_COMMAND.replace("packages/sie_ts_sdk", "integrations/sie_ts_chroma"),
+ ),
+ (contract.SDK_FORMAT_COMMAND, contract.SDK_FORMAT_COMMAND.replace("package.json", "other.json")),
+ ],
+ ids=[
+ "missing-install",
+ "suppressed-install",
+ "unfrozen-install",
+ "install-scripts",
+ "wrong-package-install",
+ "missing-formatter",
+ "commented-formatter",
+ "echoed-formatter",
+ "suppressed-formatter",
+ "external-formatter",
+ "read-only-formatter",
+ "wrong-package-formatter",
+ "wrong-file-formatter",
+ ],
+)
+def test_release_pr_metadata_refresh_uses_active_exact_pinned_commands(command, replacement) -> None:
+ refresh, contracts, stamped = openapi_surfaces()
+ assert refresh.count(command) == 1
+ assert contract.release_openapi_errors(refresh.replace(command, replacement), contracts, stamped)
+
+
+ ("moved", "anchor"),
+ [
+ (contract.SDK_INSTALL_COMMAND, "mise exec -- pnpm install --lockfile-only"),
+ (contract.SDK_FORMAT_COMMAND, contract.SDK_INSTALL_COMMAND),
+ (contract.SDK_FORMAT_COMMAND, "git add "),
+ (contract.SDK_FORMAT_COMMAND, "git commit "),
+ ],
+ ids=["install-before-lock", "format-before-install", "diff-before-format", "add-before-format"],
+)
+def test_release_pr_metadata_refresh_preserves_lock_install_format_diff_stage_order(moved, anchor) -> None:
+ refresh, contracts, stamped = openapi_surfaces()
+ lines = refresh.splitlines()
+ move_before(lines, moved, anchor)
+ assert contract.release_openapi_errors("\n".join(lines), contracts, stamped)
+
+
[email protected]("command", ["if git diff --quiet --", "git add "])
+def test_release_pr_metadata_changes_are_detected_and_staged(command) -> None:
+ refresh, contracts, stamped = openapi_surfaces()
+ lines = refresh.splitlines()
+ index = line_index(lines, command)
+ assert contract.SDK_PACKAGE_PATH in lines[index]
+ lines[index] = lines[index].replace(f" {contract.SDK_PACKAGE_PATH}", "")
+ assert contract.release_openapi_errors("\n".join(lines), contracts, stamped)
+
+
+def test_release_pr_metadata_refresh_cannot_move_to_a_skipped_step() -> None:
+ refresh, contracts, stamped = openapi_surfaces()
+ lines = refresh.splitlines()
+ index = line_index(lines, contract.SDK_FORMAT_COMMAND)
+ lines[index:index] = [" - name: Skip formatting", " if: false", " run: |"]
+ assert contract.release_openapi_errors("\n".join(lines), contracts, stamped)
+
+
@pytest.mark.parametrize(
"rewrite",
[