Skip to content

fix(gh-aw): prune stale imports cache before compile#316

Merged
JacobPEvans merged 1 commit into
mainfrom
fix/prune-stale-aw-imports
May 15, 2026
Merged

fix(gh-aw): prune stale imports cache before compile#316
JacobPEvans merged 1 commit into
mainfrom
fix/prune-stale-aw-imports

Conversation

@JacobPEvans
Copy link
Copy Markdown
Owner

Summary

  • The weekly gh-aw-pin-refresh automation 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.
  • Adds a single rm -rf .github/aw/imports to refresh.sh before the first gh aw compile. The cache regenerates from current import refs in the workflow .md files, so the PR opened by peter-evans/create-pull-request contains the deletes and the adds in one atomic diff — exactly the requested behavior.
  • Fan-out: 14 caller repos consume _gh-aw-pin-refresh.yml@main and pick up the fix automatically with zero per-repo changes.

Why this approach

gh aw has no native prune flag for the imports cache (verified against pkg/parser/import_cache.go and pkg/cli/compile_pipeline.go in upstream github/gh-aw). The only built-in "purge" is for stale .lock.yml files.

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. .gitattributes is recreated by gh aw compile automatically.

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

  • Local sanity check on ansible-proxmox-apps/main: wipe + recompile reduced 17 SHA folders to 2 (one current SHA per upstream); .gitattributes preserved; diff showed -6972 lines (deletions of stale imports).
  • bash -n refresh.sh syntax-clean.
  • Pre-commit hooks pass.
  • After merge: trigger gh-aw-pin-refresh workflow_dispatch on ansible-proxmox-apps (worst offender) and nix-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

  • Backfill of existing PR branches' stale folders — they get cleaned by the next refresh cycle automatically.
  • Same wipe in agentics-maintenance.yml — auto-generated by gh aw compile, not safe to hand-edit; only touches imports on manual workflow_dispatch of update/upgrade.
  • Filing an upstream issue with github/gh-aw for a native --prune-imports flag — wrapper fix is sufficient and ships immediately.

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>
Copilot AI review requested due to automatic review settings May 15, 2026 12:15
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 gh-aw-pin-refresh automation. By implementing a cleanup step prior to the compilation process, the automation will now produce cleaner, more manageable pull requests that reflect only the necessary changes, effectively pruning redundant data across all repositories utilizing this workflow.

Highlights

  • Cache Cleanup: Added a command to remove the .github/aw/imports directory before running the compilation process to prevent the accumulation of stale cache folders.
  • Automation Efficiency: Ensures that the weekly automation PRs contain an atomic diff, including both the deletion of old cache files and the addition of new ones, rather than just appending new files.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/imports before gh 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.

@JacobPEvans JacobPEvans merged commit 52ef5e4 into main May 15, 2026
6 checks passed
@JacobPEvans JacobPEvans deleted the fix/prune-stale-aw-imports branch May 15, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants