Repository navigation
Description
Version: gh-aw v1.2.2
What happens
A cache: block declared in a shared workflow and pulled in with imports: is not applied.
The compile succeeds with no warning. The lock file has no cache steps, and the agent job still
gets cache-mode: read (the detection-gated cache policy from ADR-72543).
The same cache: block declared in the importing workflow's own frontmatter works.
Minimal repro
.github/workflows/shared/cache.md
---
cache:
key: probe-${{ runner.os }}-v1
path:
- ~/probe-dir
---.github/workflows/imported.md
---
on:
workflow_dispatch:
permissions:
contents: read
safe-outputs:
add-comment:
imports:
- shared/cache.md
---
Say hello in a comment..github/workflows/local.md is the same, except cache: is in its own frontmatter and there is
no imports:.
gh aw compile with v1.2.2, no warnings:
| Workflow | actions/cache steps in the lock |
cache-mode: read |
|---|---|---|
imported |
0 | yes |
local |
2 (Cache and the restore variant) |
no |
safe-outputs is needed so detection is on. Without it, neither lock has cache-mode: read,
but the imported cache: is still dropped (0 cache steps against 1).
Expected
Either:
- the imported
cache:is merged, likejobs:andcheckout:, or - the compiler warns that
cache:is not merged from imports, and the docs say so.
ADR-26292 says MergedCheckout follows the same pattern as MergedJobs and MergedCaches, so
merging looks like the intended design. Option 2 alone would already stop the silent failure.
Notes
pkg/parser/import_accumulator.gocollectscacheintoacc.caches, and
import_processor.goreturns it asMergedCaches. I found no use ofMergedCachesin
pkg/workflow(in v0.93.5, v1.0.1 and v1.2.2). That is from a code search, so please check it.docs/src/content/docs/reference/imports.mdhas nocacherow in its field table, so the docs
neither promise nor rule out the merge.- Related: Compiler silently drops jobs.agent.continue-on-error #60313 (compiler silently drops
jobs.agent.continue-on-error) is the same kind of
silent drop for a different field.
Impact
With detection on, the agent job's cache token is read-only. A shared workflow cannot provide a
writable dependency cache to the workflows that import it. Each importing workflow has to repeat
the cache: block. Because the compiler gives no warning, this is easy to miss. The cache just
stops being saved. A custom actions/cache/save step in the shared file does not help: the save
fails with cache write denied: token has no writable scopes, and the step still shows success.
Activity