Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(release): make distribution verification version-independent (#1993)

Call Whitecb6b83c71396
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 7db1641c3..bd6ab030d 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -400,8 +400,21 @@ jobs:
raise SystemExit("avibe-memory wheel unexpectedly contains Memory Runtime archives")
PY
+ - name: Checkout release automation
+ uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
+ with:
+ ref: ${{ needs.resolve-tag.outputs.workflow_sha }}
+ path: release-automation
+ sparse-checkout: |
+ scripts/github_release.py
+ tests/test_memory_distribution.py
+ sparse-checkout-cone-mode: false
+
- name: Verify distribution package matrix
run: |
+ # Use workflow-owned verification only AFTER building the tagged source.
+ # Keep its location so source comparisons still inspect that source.
+ cp release-automation/tests/test_memory_distribution.py tests/test_memory_distribution.py
AVIBE_CORE_WHEEL="$(ls dist/avibe_os-*.whl)" \
AVIBE_MEMORY_WHEEL="$(ls dist/avibe_memory-*.whl)" \
pytest tests/test_memory_distribution.py -v
@@ -427,14 +440,6 @@ jobs:
tests/e2e/test_upgrade_command.py \
-v
- - name: Checkout release automation
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
- with:
- ref: ${{ needs.resolve-tag.outputs.workflow_sha }}
- path: release-automation
- sparse-checkout: scripts/github_release.py
- sparse-checkout-cone-mode: false
-
- name: Upload GitHub release assets
env:
GH_TOKEN: ${{ github.token }}
diff --git a/.github/workflows/release_ai.yml b/.github/workflows/release_ai.yml
index 4cb11092f..f84467f40 100644
--- a/.github/workflows/release_ai.yml
+++ b/.github/workflows/release_ai.yml
@@ -288,8 +288,19 @@ jobs:
print("vibe/memory_runtime_manifest.json")
PY
+ - name: Checkout release verification
+ uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
+ with:
+ ref: ${{ github.sha }}
+ path: release-automation
+ sparse-checkout: tests/test_memory_distribution.py
+ sparse-checkout-cone-mode: false
+
- name: Verify distribution package matrix
run: |
+ # Use workflow-owned verification only AFTER building the tagged source.
+ # Keep its location so source comparisons still inspect that source.
+ cp release-automation/tests/test_memory_distribution.py tests/test_memory_distribution.py
AVIBE_CORE_WHEEL="$(ls dist/avibe_os-*.whl)" \
AVIBE_MEMORY_WHEEL="$(ls dist/avibe_memory-*.whl)" \
pytest tests/test_memory_distribution.py -v
diff --git a/tests/test_memory_distribution.py b/tests/test_memory_distribution.py
index 5ec65368e..dff84d459 100644
--- a/tests/test_memory_distribution.py
+++ b/tests/test_memory_distribution.py
@@ -156,6 +156,37 @@ def _write_minimal_wheel(directory: Path, distribution: str, version: str) -> Pa
return wheel
+def _newer_decoy_version(version: Version) -> Version:
+ release = list(version.release)
+ release[-1] += 1
+ return Version(f"{version.epoch}!{'.'.join(map(str, release))}")
+
+
+ ("version", "expected"),
+ [
+ ("3.0.15rc11", "3.0.16"),
+ ("3.0.99rc1", "3.0.100"),
+ ("3.1.0", "3.1.1"),
+ ("4.0.0", "4.0.1"),
+ ("3.1.0.dev2", "3.1.1"),
+ ("3.1.0.post2", "3.1.1"),
+ ("3.1.0+local", "3.1.1"),
+ ("2!3.1.0rc1", "2!3.1.1"),
+ ("4", "5"),
+ ("4.1", "4.2"),
+ ("4.1.0.9", "4.1.0.10"),
+ ],
+)
+def test_decoy_is_a_newer_resolver_candidate_for_any_release(version: str, expected: str) -> None:
+ current = Version(version)
+ decoy = _newer_decoy_version(current)
+ assert decoy == Version(expected)
+ assert decoy > current
+ assert not decoy.is_prerelease
+ assert not SpecifierSet(f"=={current}").contains(decoy, prereleases=True)
+
+
def _parent_site_packages() -> list[Path]:
paths = [
path
@@ -640,7 +671,7 @@ def test_memory_extra_resolves_and_installs_from_both_sdists(tmp_path: Path) ->
core_pyproject = _sdist_pyproject(core_wheel, "avibe_os")
memory_pyproject = _sdist_pyproject(memory_wheel, "avibe_memory")
core_version = Version(_sdist_metadata(core_wheel, "avibe_os")["Version"])
- decoy_version = Version("3.0.99rc2")
+ decoy_version = _newer_decoy_version(core_version)
assert decoy_version > core_version
package_links = tmp_path / "package-links"
diff --git a/tests/test_release_verification.py b/tests/test_release_verification.py
new file mode 100644
index 000000000..da65282d5
--- /dev/null
+++ b/tests/test_release_verification.py
@@ -0,0 +1,135 @@
+from __future__ import annotations
+
+import json
+import os
+from pathlib import Path
+import subprocess
+import sys
+
+import pytest
+import yaml
+
+
+ROOT = Path(__file__).resolve().parents[1]
+WORKFLOWS = (
+ ("release_ai.yml", "build-assets", "Checkout release verification", "${{ github.sha }}"),
+ ("publish.yml", "build", "Checkout release automation", "${{ needs.resolve-tag.outputs.workflow_sha }}"),
+)
+
+
+def _job(workflow_name: str, job_name: str) -> dict:
+ workflow = yaml.safe_load((ROOT / ".github/workflows" / workflow_name).read_text(encoding="utf-8"))
+ return workflow["jobs"][job_name]
+
+
+def _step(job: dict, name: str) -> dict:
+ step, = [step for step in job["steps"] if step.get("name") == name]
+ return step
+
+
[email protected](("workflow_name", "job_name", "checkout_name", "workflow_ref"), WORKFLOWS)
+def test_release_verification_is_workflow_owned_after_tagged_artifacts_are_built(
+ workflow_name: str, job_name: str, checkout_name: str, workflow_ref: str,
+) -> None:
+ job = _job(workflow_name, job_name)
+ steps = job["steps"]
+ source = _step(job, "Checkout")
+ checkout = _step(job, checkout_name)
+ build = _step(job, "Build Python distributions")
+ verify = _step(job, "Verify distribution package matrix")
+
+ expected_source_ref = (
+ "${{ github.event.inputs.tag || github.ref }}" if workflow_name == "release_ai.yml"
+ else "${{ needs.resolve-tag.outputs.tag }}"
+ )
+ assert source["with"]["ref"] == expected_source_ref
+ assert checkout["uses"] == source["uses"]
+ assert checkout["with"]["ref"] == workflow_ref
+ assert checkout["with"]["path"] == "release-automation"
+ assert checkout["with"]["sparse-checkout-cone-mode"] is False
+ expected_files = {"tests/test_memory_distribution.py"}
+ if workflow_name == "publish.yml":
+ expected_files.add("scripts/github_release.py")
+ assert set(checkout["with"]["sparse-checkout"].splitlines()) == expected_files
+ assert steps.index(source) < steps.index(build) < steps.index(checkout) < steps.index(verify)
+ assert all(not step.get("if") and not step.get("continue-on-error") for step in (checkout, verify))
+ commands = [
+ line for line in verify["run"].splitlines()
+ if line.strip() and not line.lstrip().startswith("#")
+ ]
+ assert commands == [
+ "cp release-automation/tests/test_memory_distribution.py tests/test_memory_distribution.py",
+ 'AVIBE_CORE_WHEEL="$(ls dist/avibe_os-*.whl)" \\',
+ 'AVIBE_MEMORY_WHEEL="$(ls dist/avibe_memory-*.whl)" \\',
+ " pytest tests/test_memory_distribution.py -v",
+ ]
+ for later in steps[steps.index(checkout) + 1:]:
+ assert "python -m build" not in later.get("run", "")
+ upload_name = "Upload release artifacts" if workflow_name == "release_ai.yml" else "Upload GitHub release assets"
+ assert steps.index(verify) < steps.index(_step(job, upload_name))
+
+
[email protected](("workflow_name", "job_name", "checkout_name", "workflow_ref"), WORKFLOWS)
[email protected]("failure", [None, "missing-verifier", "test-failure"])
+def test_exact_matrix_command_uses_new_verifier_without_changing_artifacts(
+ tmp_path: Path, workflow_name: str, job_name: str, checkout_name: str, workflow_ref: str,
+ failure: str | None,
+) -> None:
+ workspace = tmp_path / "tagged source 中文"
+ tests = workspace / "tests"
+ automation_tests = workspace / "release-automation" / "tests"
+ dist = workspace / "dist"
+ for directory in (tests, automation_tests, dist):
+ directory.mkdir(parents=True, exist_ok=True)
+ original = b"# original tagged verification\n"
+ corrected = b"# corrected workflow-owned verification\n"
+ (tests / "test_memory_distribution.py").write_bytes(original)
+ if failure != "missing-verifier":
+ (automation_tests / "test_memory_distribution.py").write_bytes(corrected)
+ artifacts = {
+ "avibe_os-3.1.0-py3-none-any.whl": b"core built from immutable source",
+ "avibe_memory-3.1.0-py3-none-any.whl": b"companion built from immutable source",
+ "avibe_os-3.1.0.tar.gz": b"core sdist",
+ "avibe_memory-3.1.0.tar.gz": b"companion sdist",
+ }
+ for name, data in artifacts.items():
+ (dist / name).write_bytes(data)
+ source_file = workspace / "source.py"
+ source_file.write_bytes(b"# unchanged runtime code\n")
+ binaries = tmp_path / "bin"
+ binaries.mkdir()
+ pytest_stub = binaries / "pytest"
+ pytest_stub.write_text(
+ f"#!{sys.executable}\n"
+ "import json, os, pathlib, sys\n"
+ "pathlib.Path('invocation.json').write_text(json.dumps({\n"
+ " 'args': sys.argv[1:],\n"
+ " 'core': os.environ['AVIBE_CORE_WHEEL'],\n"
+ " 'memory': os.environ['AVIBE_MEMORY_WHEEL'],\n"
+ " 'test': pathlib.Path(sys.argv[1]).read_text(),\n"
+ "}))\n"
+ f"sys.exit({1 if failure == 'test-failure' else 0})\n",
+ encoding="utf-8",
+ )
+ pytest_stub.chmod(0o755)
+ command = _step(_job(workflow_name, job_name), "Verify distribution package matrix")["run"]
+ result = subprocess.run(
+ ["bash", "--noprofile", "--norc", "-e", "-o", "pipefail", "-c", command],
+ cwd=workspace,
+ env={**os.environ, "PATH": f"{binaries}{os.pathsep}{os.environ['PATH']}"},
+ capture_output=True, text=True, timeout=15,
+ )
+ assert (result.returncode == 0) is (failure is None), result.stdout + result.stderr
+ assert {path.name: path.read_bytes() for path in dist.iterdir()} == artifacts
+ assert source_file.read_bytes() == b"# unchanged runtime code\n"
+ receipt = workspace / "invocation.json"
+ if failure == "missing-verifier":
+ assert not receipt.exists()
+ assert (tests / "test_memory_distribution.py").read_bytes() == original
+ else:
+ assert json.loads(receipt.read_text()) == {
+ "args": ["tests/test_memory_distribution.py", "-v"],
+ "core": "dist/avibe_os-3.1.0-py3-none-any.whl",
+ "memory": "dist/avibe_memory-3.1.0-py3-none-any.whl",
+ "test": corrected.decode(),
+ }