PruneStaleGHAWEntries removes entries from the cache for the gh-aw-actions repository whose version does not match the current compiler version. When the compiler is updated (e.g., from v0.67.1 to v0.67.3), previously compiled workflows referenced setup@v0.67.1 but the new compiler pins to setup@v0
(currentVersion string, actionsRepoPrefix string)
| 689 | // - currentVersion: the compiler version that is currently in use (e.g., "v0.67.3") |
| 690 | // - actionsRepoPrefix: the org/repo prefix for gh-aw-actions (e.g., "github/gh-aw-actions") |
| 691 | func (c *ActionCache) PruneStaleGHAWEntries(currentVersion string, actionsRepoPrefix string) { |
| 692 | if currentVersion == "" || actionsRepoPrefix == "" { |
| 693 | return |
| 694 | } |
| 695 | // Only prune for clean release versions (e.g., "v0.67.3"), not dev/dirty builds |
| 696 | if !strings.HasPrefix(currentVersion, "v") || strings.Contains(currentVersion, "-") { |
| 697 | return |
| 698 | } |
| 699 | |
| 700 | var toDelete []string |
| 701 | for key, entry := range c.Entries { |
| 702 | if !strings.HasPrefix(entry.Repo, actionsRepoPrefix+"/") { |
| 703 | continue |
| 704 | } |
| 705 | if entry.Version != currentVersion { |
| 706 | actionCacheLog.Printf("Pruning stale gh-aw-actions entry: %s (version %s != current %s)", key, entry.Version, currentVersion) |
| 707 | toDelete = append(toDelete, key) |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | for _, key := range toDelete { |
| 712 | delete(c.Entries, key) |
| 713 | } |
| 714 | |
| 715 | if len(toDelete) > 0 { |
| 716 | c.dirty = true |
| 717 | actionCacheLog.Printf("Pruned %d stale gh-aw-actions entries, %d entries remaining", len(toDelete), len(c.Entries)) |
| 718 | } |
| 719 | } |