Skip to content

Commit d31aa86

Browse files
authored
Merge pull request #17 from SMI-Lab-Inha/citation-version-guard
Guard CITATION.cff version against drift
2 parents e53cebc + 54c0560 commit d31aa86

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to `pyIECWind` will be documented in this file.
44

55
The format is inspired by Keep a Changelog, adapted to the needs of this project.
66

7+
## [Unreleased]
8+
9+
### Added
10+
11+
- A version-consistency guard: the test suite now fails if `CITATION.cff`'s
12+
`version` drifts from the installed package version, and checks that its
13+
`date-released` is a valid ISO (`YYYY-MM-DD`) date. The citation metadata is
14+
hand-maintained, so this prevents it from silently falling behind a release.
15+
716
## [0.2.0] - 2026-05-22
817

918
Input-contract and CLI hardening. No changes to the numeric `.wnd` output of any

tests/test_version.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
from __future__ import annotations
22

3+
import re
34
import unittest
5+
from datetime import date
46
from importlib.metadata import version
57
from pathlib import Path
68

79
import pyiecwind
810
from pyiecwind import VERSION, models
911

1012

13+
def _cff_field(name: str) -> str:
14+
"""Return the value of a top-level scalar field in CITATION.cff.
15+
16+
Parsed with a regex so the test needs no YAML dependency; the file is a flat
17+
list of ``key: value`` pairs, so this is sufficient and dependency-free.
18+
"""
19+
20+
root = Path(__file__).resolve().parents[1]
21+
text = (root / "CITATION.cff").read_text(encoding="utf-8")
22+
match = re.search(rf"^{re.escape(name)}:\s*(.+?)\s*$", text, re.MULTILINE)
23+
assert match is not None, f"CITATION.cff is missing a '{name}' field"
24+
return match.group(1).strip().strip('"').strip("'")
25+
26+
1127
class VersionTests(unittest.TestCase):
1228
"""Guard against the historical drift where models.py hardcoded a version
1329
(1.0.0) different from the one declared in pyproject.toml (0.1.0)."""
@@ -31,6 +47,18 @@ def test_pyproject_version_matches_installed_metadata(self) -> None:
3147
data = tomllib.loads((root / "pyproject.toml").read_text(encoding="utf-8"))
3248
self.assertEqual(data["project"]["version"], version("pyiecwind"))
3349

50+
def test_citation_version_matches_installed_metadata(self) -> None:
51+
# CITATION.cff is hand-maintained YAML, not single-sourced like the
52+
# package version; this guard fails the build if it drifts behind a release.
53+
self.assertEqual(_cff_field("version"), version("pyiecwind"))
54+
55+
def test_citation_release_date_is_iso(self) -> None:
56+
released = _cff_field("date-released")
57+
try:
58+
date.fromisoformat(released)
59+
except ValueError:
60+
self.fail(f"CITATION.cff date-released {released!r} is not an ISO YYYY-MM-DD date")
61+
3462

3563
if __name__ == "__main__":
3664
unittest.main()

0 commit comments

Comments
 (0)