Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ follow_imports = "skip"
#
# Version is mirrored here (rather than read dynamically) because Briefcase resolves PEP621
# `dynamic = ["version"]` by running the PEP517 build backend in an isolated env, which is wasteful
# in CI. Bump both this string and src/searchmob_desktop/version.py together at release time.
# in CI. Bump both this string and src/searchmob_desktop/version.py together at release time;
# `tests/test_version_consistency.py` fails the build if they ever drift apart.
[tool.briefcase]
project_name = "SearchMob Desktop"
bundle = "com.flintwave"
version = "26.06.05"
version = "26.06.06"
url = "https://github.com/FlintWave/SearchMob-Desktop"
author = "FlintWave"
author_email = "flintwave@tuta.com"
Expand Down
27 changes: 27 additions & 0 deletions tests/test_version_consistency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""The app version lives in two places that MUST agree: `src/searchmob_desktop/version.py` (the
single source of truth, read by hatchling and the in-app update check) and the `[tool.briefcase]`
`version` in `pyproject.toml` (mirrored there because Briefcase resolves a PEP 621 dynamic version
by running the build backend in an isolated env, which is wasteful in CI).

If they drift, the installers Briefcase builds carry a different version than the app reports, so a
release can ship packages labelled with the previous version and Linux package managers refuse the
upgrade. This test fails the build when that happens, so the two can never silently diverge again.
"""

from __future__ import annotations

import tomllib
from pathlib import Path

from searchmob_desktop.version import __version__

_PYPROJECT = Path(__file__).resolve().parent.parent / "pyproject.toml"


def test_briefcase_version_matches_version_py() -> None:
data = tomllib.loads(_PYPROJECT.read_text(encoding="utf-8"))
briefcase_version = data["tool"]["briefcase"]["version"]
assert briefcase_version == __version__, (
f"pyproject [tool.briefcase] version {briefcase_version!r} != "
f"version.py {__version__!r}; bump both together at release time."
)