37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
import importlib.util
|
|
from pathlib import Path
|
|
import zipfile
|
|
|
|
|
|
def test_archive_keeps_source_and_excludes_local_builds_and_secrets(tmp_path):
|
|
script = Path(__file__).resolve().parents[2] / "scripts/package_source.py"
|
|
spec = importlib.util.spec_from_file_location("package_source", script)
|
|
module = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
keep = ["start.bat", ".env.example", "uv.lock", "apps/showcase_ui/src/main.ts"]
|
|
omit = [
|
|
".env",
|
|
".env.local",
|
|
".venv/pyvenv.cfg",
|
|
"nested/node_modules/foo.js",
|
|
"apps/showcase_ui/dist/main.js",
|
|
"artemis/resources/showcase_ui/main.js",
|
|
"__pycache__/a.pyc",
|
|
"traces/data.db",
|
|
"helper.apk",
|
|
"debug.keystore",
|
|
".git/config",
|
|
".roo/mcp.json",
|
|
]
|
|
for name in keep + omit:
|
|
target = tmp_path / name
|
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
target.write_text("fixture")
|
|
output = tmp_path / "artifacts/source.zip"
|
|
count, digest = module.package_source(tmp_path, output)
|
|
assert count == len(keep)
|
|
assert len(digest) == 64
|
|
with zipfile.ZipFile(output) as archive:
|
|
assert archive.testzip() is None
|
|
assert set(archive.namelist()) == {f"artemis/{name}" for name in keep}
|