Files
jiangchang-platform-kit/tests/test_release_workflow.py
chendelian 84bb085250
All checks were successful
Publish Python Package to Gitea / publish (push) Successful in 31s
chore: package env example in skill releases
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-02 10:33:55 +08:00

43 lines
1.3 KiB
Python

"""Text-level checks that reusable-release-skill packages .env.example at package root."""
from __future__ import annotations
import os
import re
import pytest
_REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
_WORKFLOW_PATH = os.path.join(
_REPO_ROOT, ".github", "workflows", "reusable-release-skill.yaml"
)
@pytest.fixture(scope="module")
def workflow_text() -> str:
with open(_WORKFLOW_PATH, encoding="utf-8") as f:
return f.read()
def test_workflow_packages_env_example_at_root(workflow_text: str) -> None:
assert ".env.example" in workflow_text
assert "Copied .env.example" in workflow_text
assert "env_example_src = os.path.abspath('.env.example')" in workflow_text
assert "env_example_dst = os.path.join(PACKAGE, '.env.example')" in workflow_text
assert (
"raise RuntimeError('.env.example exists in skill root but was not packaged')"
in workflow_text
)
def test_workflow_does_not_package_dot_env(workflow_text: str) -> None:
# Must not copy live .env to package root (only .env.example).
assert not re.search(
r"shutil\.copy2\([^)]*['\"]\.env['\"]",
workflow_text,
)
assert not re.search(
r"os\.path\.join\(PACKAGE,\s*['\"]\.env['\"]\)",
workflow_text,
)