Repository navigation
chore(test): cleanup_all reaps orphan test-room gists from prior runs - #126
Conversation
Pre-fix: integration test scenarios that timed out were pkill -9'd by the harness wrapper, bypassing airc's EXIT trap that normally deletes hosted gists on graceful shutdown. Result: every CI/dev run leaks 'airc room: sars-test-NNNN' / 'pks-test-NNNN' / 'debug-room' / 'sidecar-test-NNNN' gists onto the user's gh account, piling into 'airc list' output and slowly filling gist quota. Found 5 orphans on this account post-session. Fix: cleanup_all gains a cleanup_test_gists step that walks 'gh gist list' and deletes anything matching the test-scope name prefixes (sars-test-, pks-test-, hb-test-, bounce-test-, etc). Filtered carefully — won't touch real rooms (#general, #useideem, #cambriantech, anything else). The prefix regex is the source of truth; keep in sync as new scenarios are added. No-op when gh isn't authed or lacks gist scope (CI without gh, or local runs with gh logged out). Silent failure on individual deletes (they may already be gone). The cleanup runs at every cleanup_all boundary — start of each scenario AND end — so leaked gists get swept the same run they were created. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR improves integration-test hygiene by cleaning up orphaned GitHub gists created by prior test runs that were terminated before EXIT traps could delete their “room” gists.
Changes:
- Adds
cleanup_test_gists()to find and delete test-scoped “airc room:” gists viagh gist list+ description-prefix filtering. - Extends
cleanup_all()to callcleanup_test_gistsalongside existing process/dir/known_hosts cleanup.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # left alone (real rooms or someone else's tests). | ||
| local _test_prefix_re='airc room: (sars-test-|pks-test-|pks-debug|debug-room|sidecar-test-|solo-test-|ronly-test-|new-room|myproject|hb-test-|bounce-test-|ttl-test-|test-irc-|useideem-test-|stalepid-)' |
There was a problem hiding this comment.
The prefix allowlist regex includes very generic room names (new-room, myproject) that are not clearly test-scoped. If a developer’s real account has an airc room: myproject (or airc room: new-room) gist, this cleanup will delete it. Consider removing these generic entries or tightening the match (e.g., require a *-test-/PID suffix and/or anchor the regex to exact expected test descriptions).
| # left alone (real rooms or someone else's tests). | |
| local _test_prefix_re='airc room: (sars-test-|pks-test-|pks-debug|debug-room|sidecar-test-|solo-test-|ronly-test-|new-room|myproject|hb-test-|bounce-test-|ttl-test-|test-irc-|useideem-test-|stalepid-)' | |
| # left alone (real rooms or someone else's tests). Keep matches | |
| # narrowly test-scoped: do not include generic room names such as | |
| # "new-room" or "myproject", which may belong to a real account. | |
| local _test_prefix_re='^airc room: (sars-test-|pks-test-|pks-debug|debug-room|sidecar-test-|solo-test-|ronly-test-|hb-test-|bounce-test-|ttl-test-|test-irc-|useideem-test-|stalepid-)' |
| cleanup_test_gists() { | ||
| command -v gh >/dev/null 2>&1 || return 0 | ||
| gh auth status >/dev/null 2>&1 || return 0 | ||
| gh auth status 2>&1 | grep -qiE '(scopes|token scopes):.*\bgist\b' || return 0 |
There was a problem hiding this comment.
cleanup_all is invoked many times throughout this script; adding gh auth status + gh gist list on every cleanup can add noticeable latency and may trigger GitHub API throttling for authed developers. Consider guarding cleanup_test_gists so it runs at most once per script invocation (or only in the top-level EXIT trap / initial pre-run cleanup).
| # left alone (real rooms or someone else's tests). | ||
| local _test_prefix_re='airc room: (sars-test-|pks-test-|pks-debug|debug-room|sidecar-test-|solo-test-|ronly-test-|new-room|myproject|hb-test-|bounce-test-|ttl-test-|test-irc-|useideem-test-|stalepid-)' | ||
| local _ids | ||
| _ids=$(gh gist list --limit 50 2>/dev/null | awk -F'\t' -v re="$_test_prefix_re" '$2 ~ re { print $1 }') |
There was a problem hiding this comment.
gh gist list --limit 50 can miss older orphaned test gists when the account has >50 gists total (or >50 orphans), so the cleanup may never reach them. Consider paginating until no matches remain or using a sufficiently high limit to reliably reap all test-scoped gists.
| _ids=$(gh gist list --limit 50 2>/dev/null | awk -F'\t' -v re="$_test_prefix_re" '$2 ~ re { print $1 }') | |
| _ids=$( | |
| gh api --paginate /gists 2>/dev/null \ | |
| | jq -r '.[] | [.id, (.description // "")] | @tsv' \ | |
| | awk -F'\t' -v re="$_test_prefix_re" '$2 ~ re { print $1 }' | |
| ) |
Test-only reliability fix. Integration scenarios that timeout get pkill -9'd, bypassing airc's EXIT trap, leaking room gists. cleanup_all now walks 'gh gist list' and deletes anything matching the test-scope name prefixes (sars-test-, pks-test-, hb-test-, bounce-test-, debug-room, etc). Filtered to avoid real rooms.
🤖 Generated with Claude Code