Skip to content

Commit 0230ddd

Browse files
tensornullCometAPI
andauthored
fix(ci): keep distribution metadata compatible with locked tooling (#47)
Co-authored-by: CometAPI <support@cometapi.com>
1 parent 95c4d39 commit 0230ddd

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ uv run python scripts/run_actionlint.py
4242
when it is not cached. A passing static workflow check does not mean the
4343
workflow has run successfully on GitHub.
4444

45+
Both Hatch build targets explicitly emit Core Metadata 2.4, which the locked
46+
Twine toolchain can validate. Build isolation resolves Hatchling separately from
47+
`uv.lock`, so relying on its default metadata version can break an unchanged
48+
checkout. The build regression test checks both the sdist-to-wheel path and a
49+
direct wheel build with the locked Twine validator. Change the metadata format
50+
only together with verified support in the validation and publication tools.
51+
4552
If a check is unavailable, say so in the pull request rather than describing
4653
it as passing.
4754

‎pyproject.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ requires = ["hatchling>=1.27.0,<2.0.0"]
5151
build-backend = "hatchling.build"
5252

5353
[tool.hatch.build.targets.sdist]
54+
core-metadata-version = "2.4"
5455
include = [
5556
"/AGENTS.md",
5657
"/ARCHITECTURE.md",
@@ -71,6 +72,7 @@ include = [
7172
]
7273

7374
[tool.hatch.build.targets.wheel]
75+
core-metadata-version = "2.4"
7476
packages = ["src/cometapi"]
7577

7678
[tool.pyright]

‎tests/test_release_documents.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,30 @@ def test_artifact_metadata_accepts_publication_neutral_long_description() -> Non
15761576
)
15771577

15781578

1579+
@pytest.mark.parametrize("build_options", [[], ["--wheel"]], ids=["sdist-to-wheel", "direct-wheel"])
1580+
def test_built_distributions_pass_locked_twine_check(
1581+
tmp_path: Path, build_options: list[str]
1582+
) -> None:
1583+
"""Exercise the isolated build backend against the locked metadata validator."""
1584+
built = tmp_path / "distributions"
1585+
subprocess.run(
1586+
["uv", "build", *build_options, "--out-dir", str(built)],
1587+
cwd=PROJECT_ROOT,
1588+
check=True,
1589+
capture_output=True,
1590+
text=True,
1591+
)
1592+
artifacts = sorted(built.glob("*.whl")) + sorted(built.glob("*.tar.gz"))
1593+
assert len(artifacts) == (1 if build_options else 2)
1594+
subprocess.run(
1595+
[sys.executable, "-m", "twine", "check", "--strict", *map(str, artifacts)],
1596+
cwd=tmp_path,
1597+
check=True,
1598+
capture_output=True,
1599+
text=True,
1600+
)
1601+
1602+
15791603
@pytest.mark.parametrize(
15801604
"description",
15811605
[

0 commit comments

Comments
 (0)