Skip to main content

Cache - QuickStart

WarpCache is designed to work with WarpBuild's Runners only. Sign up at https://www.warpbuild.com/.

Usage

WarpBuild cache can be used by replacing the actions/cache@v4 action with the warpbuilds/cache action. The warpbuilds/cache action is fully compatible with the actions/cache@v4 action and can be used as a drop-in replacement.

Refer to the WarpBuild Actions cache documentation for more information on how to use the cache.

uses: WarpBuilds/cache@v1

The cache is designed to be fast, reliable, and secure. It is available on all WarpBuild runners and is enabled by default.

Examples

Restoring and saving cache using a single action

name: Caching Primes

on: push

jobs:
build:
runs-on: warp-ubuntu-latest-x64-4x

steps:
- uses: actions/checkout@v3

- name: Cache Primes
id: cache-primes
uses: WarpBuilds/cache@v1
with:
path: prime-numbers
key: ${{ runner.os }}-primes

- name: Generate Prime Numbers
if: steps.cache-primes.outputs.cache-hit != 'true'
run: /generate-primes.sh -d prime-numbers

- name: Use Prime Numbers
run: /primes.sh -d prime-numbers

The cache action provides a cache-hit output which is set to true when the cache is restored using the primary key and false when the cache is restored using restore-keys or no cache is restored.

Using a combination of restore and save actions

name: Caching Primes

on: push

jobs:
build:
runs-on: warp-ubuntu-latest-x64-4x

steps:
- uses: actions/checkout@v3

- name: Restore cached Primes
id: cache-primes-restore
uses: WarpBuilds/cache/restore@v1
with:
path: |
path/to/dependencies
some/other/dependencies
key: ${{ runner.os }}-primes
.
. //intermediate workflow steps
.
- name: Save Primes
id: cache-primes-save
uses: WarpBuilds/cache/save@v1
with:
path: |
path/to/dependencies
some/other/dependencies
key: ${{ steps.cache-primes-restore.outputs.cache-primary-key }}

Note You must use the cache or restore action in your workflow before you need to use the files that might be restored from the cache. If the provided key matches an existing cache, a new cache is not created and if the provided key doesn't match an existing cache, a new cache is automatically created provided the job completes successfully.

Configuration

Inputs

  • key - An explicit key for a cache entry. See creating a cache key.
  • path - A list of files, directories, and wildcard patterns to cache and restore. See @actions/glob for supported patterns.
  • restore-keys - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key.
  • enableCrossOsArchive - An optional boolean when enabled, allows Windows runners to save or restore caches that can be restored or saved respectively on other platforms. Default: false
  • enableCrossArchArchive - An optional boolean when enabled, allows runners to save or restore caches that can be restored or saved respectively on runners of other architectures. Default: false
  • fail-on-cache-miss - Fail the workflow if cache entry is not found. Default: false
  • lookup-only - If true, only checks if cache entry exists and skips download. Does not change save cache behavior. Default: false
  • delete-cache - If true, deletes the cache entry. Skips restore and save. Default: false

Outputs

  • cache-hit - A boolean value to indicate an exact match was found for the key.

    Note cache-hit will only be set to true when a cache hit occurs for the exact key match. For a partial key match via restore-keys or a cache miss, it will be set to false.

See Skipping steps based on cache-hit for info on using this output

Creating a cache key

A cache key can include any of the contexts, functions, literals, and operators supported by GitHub Actions.

For example, using the hashFiles function allows you to create a new cache when dependencies change.

- uses: WarpBuilds/cache@v1
with:
path: |
path/to/dependencies
some/other/dependencies
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}

Additionally, you can use arbitrary command output in a cache key, such as a date or software version:

# http://man7.org/linux/man-pages/man1/date.1.html
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
shell: bash

- uses: WarpBuilds/cache@v1
with:
path: path/to/dependencies
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/lockfiles') }}

See Using contexts to create cache keys

Cache scopes

The cache is scoped to the key, version, and branch.

See Matching a cache key for more info.

Usage with setup-* actions

WarpBuild cache provides fully-compatible drop-in replacements for various setup-* actions.

.NET

- uses: actions/setup-dotnet@v4
+ uses: WarpBuilds/setup-dotnet@v4

GoLang

- uses: actions/setup-go@v5
+ uses: WarpBuilds/setup-go@v5

Gradle Build Action V2

- uses: gradle/gradle-build-action@v2
+ uses: WarpBuilds/gradle-build-action@v2

JAVA

- uses: actions/setup-java@v4
+ uses: WarpBuilds/setup-java@v4

Node.js

- uses: actions/setup-node@v4
+ uses: WarpBuilds/setup-node@v4

Python

- uses: actions/setup-python@v5
+ uses: WarpBuilds/setup-python@v5

Note: The setup-python action does not have arm64 binaries. Because of this, the action is not supported on arm64 runners.

Ruby

- uses: ruby/setup-ruby@v1
+ uses: WarpBuilds/setup-ruby@v1

Rust

- uses: Swatinem/rust-cache@v2
+ uses: WarpBuilds/rust-cache@v2

Zig

- uses: ziglang/setup-zig@v2
+ uses: WarpBuilds/setup-zig@v2

Can't find the one you use? Let us know @ [email protected]