chore: package env example in skill releases
All checks were successful
Publish Python Package to Gitea / publish (push) Successful in 31s
All checks were successful
Publish Python Package to Gitea / publish (push) Successful in 31s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -119,6 +119,14 @@ jobs:
|
||||
" shutil.copy2(req_src, req_dst)" \
|
||||
" print('Copied requirements.txt')" \
|
||||
'' \
|
||||
"env_example_src = os.path.abspath('.env.example')" \
|
||||
"env_example_dst = os.path.join(PACKAGE, '.env.example')" \
|
||||
'if os.path.isfile(env_example_src):' \
|
||||
" shutil.copy2(env_example_src, env_example_dst)" \
|
||||
" print('Copied .env.example')" \
|
||||
'if os.path.isfile(env_example_src) and not os.path.isfile(env_example_dst):' \
|
||||
" raise RuntimeError('.env.example exists in skill root but was not packaged')" \
|
||||
'' \
|
||||
"print('Package top-level entries:')" \
|
||||
'for name in sorted(os.listdir(PACKAGE)):' \
|
||||
" print(' -', name)" \
|
||||
|
||||
42
tests/test_release_workflow.py
Normal file
42
tests/test_release_workflow.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""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,
|
||||
)
|
||||
@@ -33,6 +33,7 @@
|
||||
- 复制 tests/
|
||||
- 复制 evals/(除 scripts 外均为明文;若目录不存在则跳过;复制时排除常见缓存与运行产物)
|
||||
- 若根目录存在 requirements.txt,则复制到包根(明文,不 PyArmor)
|
||||
- 若根目录存在 .env.example,则复制到包根(明文,不 PyArmor,用于首次运行时落盘用户 .env)
|
||||
本脚本在打 tag 前会做一次 scripts/ 结构自检,避免子目录未提交却仍发布。
|
||||
#>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user