Files
bitcoin/.github/actions/cache/restore/internal/action.yml
will 2ce4ae7d8f ci: Add dynamic cache switching to warp cache
The GHA cache is very slow, taking on the order of minutes to save and
restore from.

Use WarpBuild's cache instead as this is in the same region and much
faster.

WarpBuild cache action does not auto-fallback to GHA if not being run on
Warp. To allow fork runs to fallback to GHA caching, whilst minimising
duplication in the action files, create new "interal" actions which
perform the switching logic, and use these in the (renamed) cache|save
actions.

Without this we would need the `if` logic in our prvious actions, 4
times in each of save and restore.

Plumb the provider through into the action, as a composite action can't
read `env` (`GITHUB_OUTPUT`) from previous steps.
2026-06-01 12:08:27 +01:00

44 lines
1.4 KiB
YAML

name: 'Cache Restore'
description: 'Restore a cache with WarpBuild on Warp runners and GitHub Actions cache otherwise'
inputs:
path:
description: 'A list of files, directories, and wildcard patterns to restore'
required: true
key:
description: 'An explicit key for restoring the cache'
required: true
restore-keys:
description: 'An ordered multiline string listing prefix-matched restore keys'
required: false
default: ''
provider:
description: 'The cache provider to use'
required: true
outputs:
cache-hit:
description: 'A boolean value to indicate an exact match was found for the primary key'
value: ${{ steps.warp.outputs.cache-hit || steps.gha.outputs.cache-hit }}
cache-primary-key:
description: 'The primary key used to restore the cache'
value: ${{ steps.warp.outputs.cache-primary-key || steps.gha.outputs.cache-primary-key }}
runs:
using: 'composite'
steps:
- name: Restore cache with WarpBuild
id: warp
if: ${{ inputs.provider == 'warp' }}
uses: WarpBuilds/cache/restore@v1
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}
restore-keys: ${{ inputs.restore-keys }}
- name: Restore cache with GitHub Actions
id: gha
if: ${{ inputs.provider == 'gha' }}
uses: actions/cache/restore@v5
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}
restore-keys: ${{ inputs.restore-keys }}