Skip to content
Merged
Changes from 1 commit
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
80 changes: 31 additions & 49 deletions services/analysis-engine/tests/test_release_packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def test_release_packaging_includes_architecture_in_artifact_identity(
monkeypatch.setenv("BANDSCOPE_ARTIFACT_OS", "windows")
monkeypatch.setenv("BANDSCOPE_ARTIFACT_ARCH", "arm64")

artifact = packaging.artifact_identity()
artifact = packaging.artifact_identity("installer.dmg")
Comment thread
coderabbitai[bot] marked this conversation as resolved.

assert artifact == {
"platform": "windows",
"arch": "arm64",
"archive_name": "bandscope-windows-arm64-abcdef123456.zip",
"manifest_name": "bandscope-windows-arm64-abcdef123456.manifest.txt",
"archive_name": "bandscope-windows-arm64-abcdef123456.dmg",
"manifest_name": "bandscope-windows-arm64-abcdef123456.dmg.manifest.txt",
}


Expand All @@ -46,44 +46,37 @@ def test_release_packaging_derives_artifact_identity_from_target_triple(
monkeypatch.setattr(packaging.platform, "system", lambda: "Darwin")
monkeypatch.setattr(packaging.platform, "machine", lambda: "arm64")

artifact = packaging.artifact_identity()
artifact = packaging.artifact_identity("installer.exe")

assert artifact == {
"platform": "windows",
"arch": "amd64",
"archive_name": "bandscope-windows-amd64-fedcba987654.zip",
"manifest_name": "bandscope-windows-amd64-fedcba987654.manifest.txt",
"archive_name": "bandscope-windows-amd64-fedcba987654.exe",
"manifest_name": "bandscope-windows-amd64-fedcba987654.exe.manifest.txt",
}


def test_expected_binary_path_uses_target_triple_when_provided(
def test_find_installer_packages_returns_dmg(
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
) -> None:
"""Ensure target triples redirect packaging to the expected Tauri output path."""
"""Ensure find_installer_packages finds dmg files."""
packaging = load_module(
"scripts/release/package_desktop_artifact.py", "package_desktop_artifact_target"
)

monkeypatch.setenv("BANDSCOPE_TARGET_TRIPLE", "aarch64-apple-darwin")
dmg_path = tmp_path / "apps" / "desktop" / "src-tauri" / "target" / "aarch64-apple-darwin" / "release" / "bundle" / "dmg" / "Test.dmg"
dmg_path.parent.mkdir(parents=True)
dmg_path.write_bytes(b"dmg")

binary_path = packaging.expected_binary_path(tmp_path)
installers = packaging.find_installer_packages(tmp_path)
assert installers == [dmg_path]

Comment thread
coderabbitai[bot] marked this conversation as resolved.
assert binary_path == (
tmp_path
/ "apps"
/ "desktop"
/ "src-tauri"
/ "target"
/ "aarch64-apple-darwin"
/ "release"
/ "bandscope-desktop"
)


def test_expected_binary_path_derives_windows_extension_from_target_triple(
def test_find_installer_packages_returns_exe_and_msi(
monkeypatch, tmp_path: Path
) -> None:
"""Ensure Windows target triples select the .exe packaging path on non-Windows hosts."""
"""Ensure find_installer_packages finds exe and msi files."""
packaging = load_module(
"scripts/release/package_desktop_artifact.py", "package_desktop_artifact_windows_target"
)
Expand All @@ -92,18 +85,15 @@ def test_expected_binary_path_derives_windows_extension_from_target_triple(
monkeypatch.setenv("BANDSCOPE_TARGET_TRIPLE", "x86_64-pc-windows-msvc")
monkeypatch.setattr(packaging.platform, "system", lambda: "Darwin")

binary_path = packaging.expected_binary_path(tmp_path)
exe_path = tmp_path / "apps" / "desktop" / "src-tauri" / "target" / "x86_64-pc-windows-msvc" / "release" / "bundle" / "nsis" / "Test.exe"
msi_path = tmp_path / "apps" / "desktop" / "src-tauri" / "target" / "x86_64-pc-windows-msvc" / "release" / "bundle" / "msi" / "Test.msi"
exe_path.parent.mkdir(parents=True)
exe_path.write_bytes(b"exe")
msi_path.parent.mkdir(parents=True)
msi_path.write_bytes(b"msi")

assert binary_path == (
tmp_path
/ "apps"
/ "desktop"
/ "src-tauri"
/ "target"
/ "x86_64-pc-windows-msvc"
/ "release"
/ "bandscope-desktop.exe"
)
installers = packaging.find_installer_packages(tmp_path)
assert set(installers) == {exe_path, msi_path}


def test_release_packaging_maps_darwin_to_macos(monkeypatch: pytest.MonkeyPatch) -> None:
Expand All @@ -129,29 +119,21 @@ def test_release_packaging_main_writes_arch_specific_manifest(
script_path = repo_root / "scripts" / "release" / "package_desktop_artifact.py"
script_path.parent.mkdir(parents=True)
script_path.write_text("# placeholder", encoding="utf-8")
binary_path = (

dmg_path = (
repo_root
/ "apps"
/ "desktop"
/ "src-tauri"
/ "target"
/ "aarch64-apple-darwin"
/ "release"
/ "bandscope-desktop"
/ "bundle"
/ "dmg"
/ "App.dmg"
)
binary_path.parent.mkdir(parents=True)
binary_path.write_bytes(b"binary")
frontend_file = repo_root / "apps" / "desktop" / "dist" / "index.html"
frontend_file.parent.mkdir(parents=True)
frontend_file.write_text("<html></html>", encoding="utf-8")
for metadata_path in [
repo_root / "services" / "analysis-engine" / "uv.lock",
repo_root / "package-lock.json",
repo_root / "apps" / "desktop" / "src-tauri" / "Cargo.lock",
repo_root / "supply-chain" / "supplemental-component-inventory.json",
]:
metadata_path.parent.mkdir(parents=True, exist_ok=True)
metadata_path.write_text("metadata", encoding="utf-8")
dmg_path.parent.mkdir(parents=True)
dmg_path.write_bytes(b"dmg")

monkeypatch.setattr(packaging, "__file__", str(script_path))
monkeypatch.setenv("GITHUB_SHA", "1234567890abcdef")
Expand All @@ -160,7 +142,7 @@ def test_release_packaging_main_writes_arch_specific_manifest(
monkeypatch.setenv("BANDSCOPE_TARGET_TRIPLE", "aarch64-apple-darwin")

assert packaging.main() == 0
manifest_path = repo_root / "artifacts" / "bandscope-macos-arm64-1234567890ab.manifest.txt"
manifest_path = repo_root / "artifacts" / "bandscope-macos-arm64-1234567890ab.dmg.manifest.txt"

assert manifest_path.exists()
assert "platform=macos" in manifest_path.read_text(encoding="utf-8")
Expand Down