CI / lint (push) Successful in 1m7s
CI / security (push) Successful in 43s
CI / test (push) Successful in 2m12s
CI / build (push) Successful in 42s
CI / e2e (push) Successful in 10m43s
Desktop Build / build-windows (push) Canceled after 0s
Desktop Build / build-linux (push) Canceled after 0s
- scripts/updater_manifest.py : construit latest.json (version, pub_date, platforms Windows/Linux avec signature .sig et URLs des assets). - publish_release.py : genere latest.json, upload des .sig + latest.json, rappel de commit. - tauri.conf.json : endpoint updater -> raw/branch/main/desktop/latest.json. - build-windows.bat / build-linux.sh : detection automatique de obsigate-updater.key (signature) ou repli non signe. - .gitignore : ignore desktop/key/ ; tests/test_updater_manifest.py (8 tests).
126 lines
4.2 KiB
Python
126 lines
4.2 KiB
Python
# tests/test_updater_manifest.py
|
|
# Unit tests for scripts/updater_manifest.py — Tauri updater `latest.json` builder.
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
SCRIPTS_DIR = Path(__file__).resolve().parent.parent / "scripts"
|
|
sys.path.insert(0, str(SCRIPTS_DIR))
|
|
|
|
from updater_manifest import build_updater_manifest # noqa: E402
|
|
|
|
|
|
def _write(path: Path, content: str = "") -> None:
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
path.write_text(content, encoding="utf-8")
|
|
|
|
|
|
def _make_desktop(tmp_path: Path, version: str = "2.3.0") -> Path:
|
|
desktop = tmp_path / "desktop"
|
|
_write(desktop / "tauri.conf.json", json.dumps({"version": version}))
|
|
return desktop
|
|
|
|
|
|
def _add_signed_bundle(desktop: Path, rel: str, signature: str) -> None:
|
|
bundle = desktop / rel
|
|
_write(bundle, "binary")
|
|
_write(bundle.with_name(bundle.name + ".sig"), signature)
|
|
|
|
|
|
def test_manifest_both_platforms(tmp_path):
|
|
desktop = _make_desktop(tmp_path, "2.3.0")
|
|
_add_signed_bundle(
|
|
desktop, "target/release/bundle/nsis/ObsiGate_2.3.0_x64-setup.exe", "sig-win"
|
|
)
|
|
_add_signed_bundle(
|
|
desktop, "target/release/bundle/appimage/ObsiGate_2.3.0_amd64.AppImage", "sig-lin"
|
|
)
|
|
|
|
manifest = build_updater_manifest(
|
|
desktop,
|
|
"v2.3.0",
|
|
"https://git.example.com",
|
|
"Org/Repo",
|
|
notes="Hello",
|
|
pub_date="2026-09-12T00:00:00Z",
|
|
)
|
|
|
|
assert manifest["version"] == "2.3.0"
|
|
assert manifest["notes"] == "Hello"
|
|
assert manifest["pub_date"] == "2026-09-12T00:00:00Z"
|
|
assert set(manifest["platforms"]) == {"windows-x86_64", "linux-x86_64"}
|
|
assert manifest["platforms"]["windows-x86_64"] == {
|
|
"signature": "sig-win",
|
|
"url": (
|
|
"https://git.example.com/Org/Repo/releases/download/v2.3.0/"
|
|
"ObsiGate_2.3.0_x64-setup.exe"
|
|
),
|
|
}
|
|
assert manifest["platforms"]["linux-x86_64"]["url"].endswith(
|
|
"ObsiGate_2.3.0_amd64.AppImage"
|
|
)
|
|
|
|
|
|
def test_manifest_prefers_nsis_over_msi(tmp_path):
|
|
desktop = _make_desktop(tmp_path)
|
|
_add_signed_bundle(
|
|
desktop, "target/release/bundle/nsis/ObsiGate_2.3.0_x64-setup.exe", "sig-nsis"
|
|
)
|
|
_add_signed_bundle(
|
|
desktop, "target/release/bundle/msi/ObsiGate_2.3.0_x64_en-US.msi", "sig-msi"
|
|
)
|
|
|
|
manifest = build_updater_manifest(desktop, "v2.3.0")
|
|
assert manifest["platforms"]["windows-x86_64"]["signature"] == "sig-nsis"
|
|
|
|
|
|
def test_manifest_falls_back_to_msi_when_nsis_unsigned(tmp_path):
|
|
desktop = _make_desktop(tmp_path)
|
|
_write(desktop / "target/release/bundle/nsis/ObsiGate_2.3.0_x64-setup.exe", "binary")
|
|
_add_signed_bundle(
|
|
desktop, "target/release/bundle/msi/ObsiGate_2.3.0_x64_en-US.msi", "sig-msi"
|
|
)
|
|
|
|
manifest = build_updater_manifest(desktop, "v2.3.0")
|
|
assert manifest["platforms"]["windows-x86_64"]["signature"] == "sig-msi"
|
|
|
|
|
|
def test_manifest_skips_unsigned_platform(tmp_path):
|
|
desktop = _make_desktop(tmp_path)
|
|
_add_signed_bundle(
|
|
desktop, "target/release/bundle/nsis/ObsiGate_2.3.0_x64-setup.exe", "sig-win"
|
|
)
|
|
|
|
manifest = build_updater_manifest(desktop, "v2.3.0")
|
|
assert set(manifest["platforms"]) == {"windows-x86_64"}
|
|
|
|
|
|
def test_manifest_none_when_no_artifacts(tmp_path):
|
|
desktop = _make_desktop(tmp_path)
|
|
assert build_updater_manifest(desktop, "v2.3.0") is None
|
|
|
|
|
|
def test_manifest_none_when_unsigned(tmp_path):
|
|
desktop = _make_desktop(tmp_path)
|
|
_write(desktop / "target/release/bundle/nsis/ObsiGate_2.3.0_x64-setup.exe", "binary")
|
|
assert build_updater_manifest(desktop, "v2.3.0") is None
|
|
|
|
|
|
def test_manifest_generates_iso_pub_date(tmp_path):
|
|
desktop = _make_desktop(tmp_path)
|
|
_add_signed_bundle(
|
|
desktop, "target/release/bundle/nsis/ObsiGate_2.3.0_x64-setup.exe", "sig"
|
|
)
|
|
manifest = build_updater_manifest(desktop, "v2.3.0")
|
|
assert manifest["pub_date"].endswith("Z")
|
|
assert "T" in manifest["pub_date"]
|
|
|
|
|
|
def test_manifest_reads_version_from_tauri_conf(tmp_path):
|
|
desktop = _make_desktop(tmp_path, "9.9.9")
|
|
_add_signed_bundle(
|
|
desktop, "target/release/bundle/nsis/ObsiGate_9.9.9_x64-setup.exe", "sig"
|
|
)
|
|
manifest = build_updater_manifest(desktop, "v9.9.9")
|
|
assert manifest["version"] == "9.9.9"
|