Repository navigation
feat: add opt-in cache_claude_code input to reuse the Claude Code binary across runs - #1939
Open
dolphin9712 wants to merge 1 commit into
Open
dolphin9712 wants to merge 1 commit into
dolphin9712 wants to merge 1 commit into
Conversation
…ary across runs Restore the binary that install.sh would download with actions/cache/restore, use it only if it matches the release manifest checksum and the pinned version, and save it with actions/cache/save only on a cache miss.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every run downloads the Claude Code native binary (~280 MB) with
install.sh. On our 1-core self-hosted runners this took 15–25 s per run (up to ~47 s), before Claude starts. The only way to skip it today ispath_to_claude_code_executable, which needs a custom runner image.Change
New opt-in input
cache_claude_code(default"false"):src/entrypoints/run.ts, so a version bump changes the cache key with no extra edit (a test fails if that line's format changes).actions/cache/restorethe binary at~/.local/share/claude/versions/<version>.install.sh, including musl detection) andclaude --versionreports the pinned version. Otherwise discard it and install as usual.run.tsthroughPATH_TO_CLAUDE_CODE_EXECUTABLEas a fallback; a user-providedpath_to_claude_code_executablestill wins.actions/cache/saveonly on a cache miss.Restore and save are separate steps and an existing key is never saved again, which avoids the duplicate-save 409 retries that led to disabling setup-bun's cache (#1259, #1580). Every cache step is
continue-on-error, so a cache problem falls back to the normal install.Testing
test/claude-code-cache.test.tsruns the step scripts fromaction.ymlwith the same bash flags as a composite step: version lookup, a matching binary, checksum mismatch, version mismatch and an unreachable manifest.bun test,bun run typecheckandbun run format:checkpass.