fix(gh-aw): prune stale imports cache before compile#316
Conversation
The `gh aw compile --force-refresh-action-pins` step caches imported workflow content under `.github/aw/imports/<owner>/<repo>/<sha>/` but never removes folders for SHAs that have moved on. Each weekly refresh PR adds a new SHA folder while leaving every prior one behind; after 8 cycles, ansible-proxmox-apps already had 17 stale folders. The upstream gh-aw CLI has no native prune flag (verified against pkg/parser/import_cache.go and pkg/cli/compile_pipeline.go). Wipe the cache before the first compile so it regenerates from the current import refs only. peter-evans/create-pull-request includes the deletes in the same commit as the new SHA's adds, so each refresh PR is one atomic before/after diff. `.gitattributes` is recreated by `gh aw compile`; verified locally against ansible-proxmox-apps and matches the proven pattern in ai-workflows/.github/workflows/gh-aw-sync-upstream.yml. The fix is in the reusable action so all 14 caller repos pick it up via @main with no per-repo changes. Assisted-by: Claude <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses the accumulation of stale import cache folders generated by the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. The cache grew large with files of old, / A story of cruft that had been told. / A simple command to wipe the slate, / Now clean PRs are our current fate. Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR updates the reusable gh-aw action pin refresh flow to prune stale workflow import cache folders before recompiling generated gh-aw files.
Changes:
- Deletes
.github/aw/importsbeforegh aw compile --force-refresh-action-pins. - Documents that the cache is regenerated from current workflow markdown imports and included atomically in the refresh PR.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
gh-aw-pin-refreshautomation creates PRs (e.g. JacobPEvans/ansible-proxmox-apps#251) that add new.github/aw/imports/<owner>/<repo>/<sha>/cache folders but never remove the old ones. Each refresh leaves more cruft behind; ansible-proxmox-apps had 17 stale folders, nix-ai 17, ansible-splunk 15.rm -rf .github/aw/importstorefresh.shbefore the firstgh aw compile. The cache regenerates from current import refs in the workflow .md files, so the PR opened bypeter-evans/create-pull-requestcontains the deletes and the adds in one atomic diff — exactly the requested behavior._gh-aw-pin-refresh.yml@mainand pick up the fix automatically with zero per-repo changes.Why this approach
gh awhas no native prune flag for the imports cache (verified againstpkg/parser/import_cache.goandpkg/cli/compile_pipeline.goin upstreamgithub/gh-aw). The only built-in "purge" is for stale.lock.ymlfiles.The same wipe-before-compile pattern is already proven in
ai-workflows/.github/workflows/gh-aw-sync-upstream.yml:50, running weekly since 2026-04-11 with no regressions..gitattributesis recreated bygh aw compileautomatically.The 24h soak logic (rewinding action SHAs in
actions-lock.json) is independent of the workflow imports cache, so wiping imports does not affect the soak.Test plan
ansible-proxmox-apps/main: wipe + recompile reduced 17 SHA folders to 2 (one current SHA per upstream);.gitattributespreserved; diff showed -6972 lines (deletions of stale imports).bash -n refresh.shsyntax-clean.gh-aw-pin-refreshworkflow_dispatch onansible-proxmox-apps(worst offender) andnix-ai. The first PR per repo will be larger than usual (one-time normalization deleting accumulated cruft); subsequent weekly PRs return to a small one-folder-out, one-folder-in pattern.Out of scope
agentics-maintenance.yml— auto-generated bygh aw compile, not safe to hand-edit; only touches imports on manualworkflow_dispatchofupdate/upgrade.github/gh-awfor a native--prune-importsflag — wrapper fix is sufficient and ships immediately.