Skip to content

Add a save-cache input for callers where only the default branch saves caches - #12

Merged
asgeirf merged 13 commits into
mainfrom
save-cache-input
Nov 24, 2026
Merged

asgeirf merged 13 commits into
mainfrom
save-cache-input

Conversation

@asgeirf

@asgeirf asgeirf commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Adds a save-cache input: true (the default, unchanged for every v1 caller), default-branch or false.

Why. In neokapi/neokapi only the default branch saves caches. The action saved its caches on every ref, pull requests included: binary, plugins, and a parse cache keyed by run. They were never read again and used that repository's cache budget. A caller there will pass save-cache: default-branch.

How.

  • A new early step, "Resolve save-cache", runs scripts/save-cache-decision.sh to turn the input into a yes or no for the run, and exposes it as the saves-cache output:
    • true is yes; false is no.
    • default-branch is yes on a schedule run, which GitHub runs on the default branch only and whose payload names no repository. It is also yes when github.ref is refs/heads/<github.event.repository.default_branch>. The branch name comes from the event, not a literal, so this works in any repository. In every other case, where the branch cannot be told, it is no.
    • Any other value fails the step with a message.
  • Each actions/cache step runs only on yes. A twin actions/cache/restore step, with the same path and key, runs on no; actions/cache/restore never saves.
  • The cache-hit output reads whichever ran.
  • For the parse cache, the existing restore-only step for pull_request_target, workflow_run and issue_comment also covers a "no".
  • The input's description and default are plain text. The first push put an expression in the description, which GitHub refuses to load ("Unrecognized named-value: 'github'"); that failed every job.

Tests.

  • test/save-cache/restore-only.py checks two things. Every saving cache step follows the decision and has a restore-only twin. And no input's description or default holds an expression, other than ${{ github.token }} as token's default. It fails on the first push's action.yml for both reasons.
  • test/save-cache/decision.sh unit-tests the decision over eleven fabricated events: each value, a pull request, a push to main and to a trunk default branch, a dispatch, a workflow_run, a schedule with no repository in its payload, and an invalid value.
  • test-save-cache runs each value (false, default-branch, true) with the bowrain plugin and asserts the install, the cache-hit output, and that saves-cache matches the expected decision for the run.
  • test-save-cache-invalid asserts that save-cache: maybe fails.

Not merged, and no tag moved.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr

asgeirf and others added 13 commits November 24, 2026 06:15
Verified: test/save-cache/restore-only.py against the changed action.yml; actionlint on test.yml

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
…action still installs

Verified: test/save-cache/restore-only.py against the changed action.yml; actionlint on test.yml

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
Verified: test/save-cache/restore-only.py against the changed action.yml; actionlint on test.yml

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
Verified: test/save-cache/restore-only.py against the changed action.yml; actionlint on test.yml

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
…s text holds no expression

Verified: test/save-cache/restore-only.py passes on this action.yml and fails on the previous one (expression in a description, an ungated parse cache step); actionlint on test.yml

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
Verified: test/save-cache/restore-only.py passes on this action.yml and fails on the previous one (expression in a description, an ungated parse cache step); actionlint on test.yml

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
Verified: test/save-cache/restore-only.py passes on this action.yml and fails on the previous one (expression in a description, an ungated parse cache step); actionlint on test.yml

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
…or default

Verified: test/save-cache/restore-only.py passes on this action.yml and fails on the previous one (expression in a description, an ungated parse cache step); actionlint on test.yml

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
…ranch

Verified: test/save-cache/decision.sh (eleven fabricated events, schedule included); test/save-cache/restore-only.py; actionlint on test.yml

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
…cluded

Verified: test/save-cache/decision.sh (eleven fabricated events, schedule included); test/save-cache/restore-only.py; actionlint on test.yml

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
…s-cache output

Verified: test/save-cache/decision.sh (eleven fabricated events, schedule included); test/save-cache/restore-only.py; actionlint on test.yml

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
…nd run the decision unit test

Verified: test/save-cache/decision.sh (eleven fabricated events, schedule included); test/save-cache/restore-only.py; actionlint on test.yml

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
Verified: test/save-cache/decision.sh (eleven fabricated events, schedule included); test/save-cache/restore-only.py; actionlint on test.yml

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtGobCdyR3d9yLXAfX9jsr
@asgeirf
asgeirf merged commit 859b9a5 into main Nov 24, 2026
33 checks passed
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.

1 participant