mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-20 13:07:57 +09:00
## Summary
A full `pulumi preview` from main showed runner-manager drift ("replace
source, update function"), last applied from the
`karaoke-gen-runner-scan-retry` worktree. I checked it:
- #1262 (that worktree's branch) is fully on main. The squash merge is
byte-identical to the branch tip. The live scheduler job (`retryCount
2`, `maxRetryDuration 60s`, `attemptDeadline 300s`) also matches the
code exactly.
- The drift comes from the **deployed zip containing
`__pycache__/*.pyc`** (including a pytest pyc) from the worktree's test
run. `pulumi.FileArchive` hashes every file, so every clean checkout saw
a phantom diff. Separately, the 7-day lifecycle rule had already deleted
the bucket object.
## Changes
- New `infrastructure/modules/source_archive.clean_source_archive()`
builds an `AssetArchive` of source files only. It skips `__pycache__`,
`*.pyc`, `.pytest_cache`, other tool caches and `.DS_Store`.
- Used for runner-manager, divebar-lookup and divebar-mirror (the three
`FileArchive` users).
- Unit tests, added to the "Infra - Cloud Function tests" CI job.
- LESSONS-LEARNED entry.
## Applied (before merge, per repo convention)
- I ran a targeted preview with `__pycache__` present in the worktree.
Runner-manager showed source replace + function update (the one-time
correction). Divebar-lookup and divebar-mirror showed **no change**.
- Targeted `pulumi up` ran as claude-admin (Andrew's grant): 2 changes,
289 unchanged.
- The new revision is `github-runner-manager-00031-sam`, and the
deployed zip now holds only the 4 source files.
- The re-preview shows 291 unchanged.
## Testing
- `pytest infrastructure/test_source_archive.py`: 4 passed
- `pytest infrastructure/functions/runner_manager`: 75 passed
- Local CodeRabbit review: no findings
@coderabbitai ignore
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_012RYLVSfwoV9WyncjqMPHrq
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
"""Tests for modules/source_archive.py (run: pytest infrastructure/test_source_archive.py)."""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent / "modules"))
|
|
|
|
from source_archive import clean_source_archive, source_files # noqa: E402
|
|
|
|
|
|
def _write(path: Path, text: str = "x") -> None:
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
path.write_text(text)
|
|
|
|
|
|
def test_skips_caches_and_os_junk(tmp_path):
|
|
_write(tmp_path / "main.py")
|
|
_write(tmp_path / "requirements.txt")
|
|
_write(tmp_path / "pkg" / "helper.py")
|
|
_write(tmp_path / "__pycache__" / "main.cpython-313.pyc")
|
|
_write(tmp_path / "pkg" / "__pycache__" / "helper.cpython-313.pyc")
|
|
_write(tmp_path / ".pytest_cache" / "v" / "cache" / "lastfailed")
|
|
_write(tmp_path / "stray.pyc")
|
|
_write(tmp_path / ".DS_Store")
|
|
|
|
assert list(source_files(tmp_path)) == ["main.py", "pkg/helper.py", "requirements.txt"]
|
|
|
|
|
|
def test_same_files_regardless_of_test_run_leftovers(tmp_path):
|
|
clean = tmp_path / "clean"
|
|
dirty = tmp_path / "dirty"
|
|
for root in (clean, dirty):
|
|
_write(root / "main.py", "print('hi')")
|
|
_write(dirty / "__pycache__" / "main.cpython-313.pyc", "bytecode")
|
|
|
|
assert list(source_files(clean)) == list(source_files(dirty))
|
|
|
|
|
|
def test_archive_holds_file_assets(tmp_path):
|
|
_write(tmp_path / "main.py")
|
|
archive = clean_source_archive(tmp_path)
|
|
assert set(archive.assets) == {"main.py"}
|
|
|
|
|
|
def test_empty_dir_raises(tmp_path):
|
|
_write(tmp_path / "__pycache__" / "only.pyc")
|
|
with pytest.raises(ValueError):
|
|
source_files(tmp_path)
|