Skip to content

Commit 1e8c5ae

Browse files
v3.0.31
Signed-off-by: Dinger <quantdinger@gmail.com>
1 parent 2a8ac7f commit 1e8c5ae

5 files changed

Lines changed: 22 additions & 1 deletion

File tree

backend_api_python/app/_version.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
FALLBACK_VERSION = "0.0.0-dev"
1616
TAG_REF_PREFIX = "refs/tags/"
17+
BRANCH_REF_PREFIX = "refs/heads/"
1718

1819

1920
def normalize_version(value: object) -> str:
@@ -23,6 +24,8 @@ def normalize_version(value: object) -> str:
2324
return ""
2425
if text.startswith(TAG_REF_PREFIX):
2526
text = text[len(TAG_REF_PREFIX) :]
27+
elif text.startswith(BRANCH_REF_PREFIX):
28+
text = text[len(BRANCH_REF_PREFIX) :]
2629
if text.startswith("v") and len(text) > 1 and text[1].isdigit():
2730
text = text[1:]
2831
return text

backend_api_python/scripts/export_openapi.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ def export_spec(output: Path, fmt: str) -> None:
4646

4747
from app.openapi.register import enrich_spec
4848
spec_dict = enrich_spec(spec_dict)
49+
# Runtime build/version metadata is intentionally excluded from the
50+
# committed spec. CI exports from branch refs while release images export
51+
# from tags, so keeping this field would make openapi.yaml drift even when
52+
# the API surface has not changed.
53+
info = spec_dict.get("info")
54+
if isinstance(info, dict):
55+
info.pop("x-api-app-version", None)
4956

5057
output.parent.mkdir(parents=True, exist_ok=True)
5158

backend_api_python/tests/test_app_version.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def local_temp_dir() -> Iterator[Path]:
2525
def test_normalize_version_accepts_common_tag_formats():
2626
assert normalize_version("v3.0.23") == "3.0.23"
2727
assert normalize_version("refs/tags/v3.0.23") == "3.0.23"
28+
assert normalize_version("refs/heads/main") == "main"
2829
assert normalize_version("3.0.23") == "3.0.23"
2930

3031

@@ -73,6 +74,16 @@ def test_floating_tag_falls_back_to_version_file():
7374
)
7475

7576

77+
def test_branch_ref_falls_back_to_version_file():
78+
with local_temp_dir() as tmp_path:
79+
(tmp_path / "VERSION").write_text("3.0.22\n", encoding="utf-8")
80+
81+
assert (
82+
resolve_app_version({"GITHUB_REF": "refs/heads/main"}, repo_root=tmp_path, app_root=tmp_path, use_git=False)
83+
== "3.0.22"
84+
)
85+
86+
7687
def test_missing_sources_return_dev_fallback():
7788
with local_temp_dir() as tmp_path:
7889
assert resolve_app_version({}, repo_root=tmp_path, app_root=tmp_path, use_git=False) == FALLBACK_VERSION

backend_api_python/tests/test_openapi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,5 @@ def test_export_script_writes_yaml(tmp_path):
7070
)
7171
loaded = yaml.safe_load(out.read_text(encoding="utf-8"))
7272
assert loaded["openapi"].startswith("3.")
73+
assert "x-api-app-version" not in loaded.get("info", {})
7374
assert "/health" in loaded["paths"]

docs/api/openapi.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ info:
66
url: https://github.com/brokermr810/quantdinger
77
license:
88
name: See repository LICENSE
9-
x-api-app-version: 3.0.22
109
title: QuantDinger Web API
1110
version: 1.0.0
1211
components:

0 commit comments

Comments
 (0)