validateNoCacheKeyRunID returns an error when a user-supplied cache key contains the ${{ github.run_id }} expression. Including run_id in the key means every run writes to a unique cache slot and the cache can never be restored from a previous run. The compiler already appends run_id automatically
(key string)
| 36 | // appends run_id automatically to the save key while generating a stable |
| 37 | // restore-keys prefix — users must not add it themselves. |
| 38 | func validateNoCacheKeyRunID(key string) error { |
| 39 | if cacheKeyRunIDPattern.MatchString(key) { |
| 40 | return NewValidationError( |
| 41 | "tools.cache-memory.key", |
| 42 | key, |
| 43 | "cache key must not reference github.run_id — every run would write to a unique cache slot, preventing cross-run cache restoration", |
| 44 | "Remove github.run_id from the key. The compiler appends it automatically to the save key and generates a stable restore-keys prefix.\n\nExample:\n\ntools:\n cache-memory:\n key: my-data-${{ env.GH_AW_WORKFLOW_ID_SANITIZED }}\n # ✓ compiler adds run_id to the save key; restore-keys prefix enables cross-run restoration", |
| 45 | ) |
| 46 | } |
| 47 | return nil |
| 48 | } |
| 49 | |
| 50 | // validateNoDuplicateCacheIDs checks for duplicate cache IDs and returns an error if found. |
| 51 | // Uses the generic validateNoDuplicateIDs helper for consistent duplicate detection. |
no test coverage detected