def create_archive(
# Bundles all files in directory plus test-output.txt and test-results.xml into a timestamped zip archive
directory: Path,
output_dir: Path = Path("."),
*,
test_output: Path = Path("test-output.txt"),
test_results: Path = Path("test-results.xml"),
) -> Path:
stamp = datetime.now().strftime("%Y%m%d-%H%M%S")
name = f"test_{stamp}_{uuid.uuid4()}.zip"
dest = output_dir / name
with zipfile.ZipFile(dest, "w", zipfile.ZIP_DEFLATED) as zf:
for f in sorted(directory.iterdir()):
if f.is_file():
zf.write(f, f.name)
for artifact in (test_output, test_results):
if artifact.exists():
zf.write(artifact, artifact.name)
return dest