All checks were successful
Publish Python Package to Gitea / publish (push) Successful in 26s
Package optional TUTORIAL/DEMO/CHANGELOG into skill ZIPs and sync tutorial_md, demo_md, demo_video_url, and versioned changelog to the marketplace API. Co-authored-by: Cursor <cursoragent@cursor.com>
107 lines
3.7 KiB
Python
107 lines
3.7 KiB
Python
"""Text-level checks for release-related GitHub Actions workflows."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import re
|
|
|
|
import pytest
|
|
|
|
_REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
_SKILL_WORKFLOW_PATH = os.path.join(
|
|
_REPO_ROOT, ".github", "workflows", "reusable-release-skill.yaml"
|
|
)
|
|
_PUBLISH_WORKFLOW_PATH = os.path.join(
|
|
_REPO_ROOT, ".github", "workflows", "publish.yml"
|
|
)
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def workflow_text() -> str:
|
|
with open(_SKILL_WORKFLOW_PATH, encoding="utf-8") as f:
|
|
return f.read()
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def publish_workflow_text() -> str:
|
|
with open(_PUBLISH_WORKFLOW_PATH, encoding="utf-8") as f:
|
|
return f.read()
|
|
|
|
|
|
def test_workflow_packages_readme_at_root(workflow_text: str) -> None:
|
|
assert "readme_src = os.path.abspath('README.md')" in workflow_text
|
|
assert "readme_dst = os.path.join(PACKAGE, 'README.md')" in workflow_text
|
|
assert "Copied README.md" in workflow_text
|
|
assert (
|
|
"raise RuntimeError('README.md exists in skill root but was not packaged')"
|
|
in workflow_text
|
|
)
|
|
|
|
|
|
def test_workflow_metadata_reads_root_readme(workflow_text: str) -> None:
|
|
assert 'load_md("README.md")' in workflow_text
|
|
assert 'metadata["readme_md"] = body' in workflow_text
|
|
|
|
|
|
def test_workflow_packages_market_docs_when_present(workflow_text: str) -> None:
|
|
assert 'for market_doc in ("TUTORIAL.md", "DEMO.md", "CHANGELOG.md"):' in workflow_text
|
|
assert "Copied {market_doc}" in workflow_text
|
|
|
|
|
|
def test_workflow_metadata_syncs_tutorial_demo_changelog(workflow_text: str) -> None:
|
|
assert 'load_md("TUTORIAL.md")' in workflow_text
|
|
assert 'metadata["tutorial_md"] = tutorial_body' in workflow_text
|
|
assert 'load_md("DEMO.md")' in workflow_text
|
|
assert 'metadata["demo_md"] = demo_body' in workflow_text
|
|
assert 'metadata["demo_video_url"]' in workflow_text
|
|
assert "extract_changelog_for_version" in workflow_text
|
|
assert 'metadata["changelog"] = section' in workflow_text
|
|
|
|
|
|
def test_workflow_does_not_use_references_readme_for_marketplace(
|
|
workflow_text: str,
|
|
) -> None:
|
|
assert "os.path.join('references', 'README.md')" not in workflow_text
|
|
assert not re.search(
|
|
r"frontmatter\.load\([^)]*references[^)]*README",
|
|
workflow_text,
|
|
)
|
|
|
|
|
|
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,
|
|
)
|
|
|
|
|
|
def test_publish_workflow_triggers_on_main_only(publish_workflow_text: str) -> None:
|
|
assert "branches:" in publish_workflow_text
|
|
assert "- main" in publish_workflow_text
|
|
assert "tags:" not in publish_workflow_text
|
|
|
|
|
|
def test_publish_workflow_uses_pyproject_version_only(publish_workflow_text: str) -> None:
|
|
assert "ci_set_package_version" not in publish_workflow_text
|
|
assert "GITHUB_RUN_NUMBER" not in publish_workflow_text
|
|
assert "GITHUB_RUN_ID" not in publish_workflow_text
|
|
assert ".post" not in publish_workflow_text
|
|
assert "python3.12 -m build" in publish_workflow_text
|
|
assert "twine upload" in publish_workflow_text
|