Skip to content

Add checkout-with-cache composite action#35

Draft
benstpierre wants to merge 1 commit into
runs-on:mainfrom
benstpierre:add-checkout-with-cache-action
Draft

Add checkout-with-cache composite action#35
benstpierre wants to merge 1 commit into
runs-on:mainfrom
benstpierre:add-checkout-with-cache-action

Conversation

@benstpierre

Copy link
Copy Markdown

Summary

This is a small proposal based on a helper action we have been using at Galatea to speed up large repository checkouts on RunsOn runners. It adds a composite action at checkout-with-cache/ that restores a cached repository .git snapshot from RunsOn EFS before running actions/checkout, then updates and rotates the cache afterward.

I am not 100% sure whether this repository is the right final home for it, so I opened this as a draft. If you would rather have this live in a tiny dedicated repo like runs-on/checkout-with-cache, that may actually be better for runtime performance because checkout acceleration should not require downloading a larger action repo first. Happy to reshape this however you prefer.

Why

For large repos using fetch-depth: 0, checkout can dominate job startup time. In one Galatea repo (galateatech/waste-coordinator), we saw roughly:

  • plain actions/checkout@v6 with fetch-depth: 0: about 34s
  • EFS restore plus checkout delta fetch: about 6s total

This felt like something worth proposing upstream because the useful bit is really the RunsOn EFS/cache behavior, not anything Galatea-specific.

Usage

steps:
  - uses: runs-on/action/checkout-with-cache@v2
    with:
      encryption_key: ${{ secrets.CHECKOUT_CACHE_KEY }}

The action wraps actions/checkout@v6, defaults to /mnt/efs/${GITHUB_REPOSITORY}/.git, stores files as repository-<sha>-<timestamp>.tar, and optionally encrypts them with openssl enc -aes-256-cbc -pbkdf2.

Safety / behavior

  • only enables cache behavior on RunsOn Linux runners with EFS available
  • cache misses and restore failures fall back to normal checkout
  • writes are skipped on pull request events
  • writes default to the repository default branch
  • persist-credentials defaults to false for actions/checkout
  • checkout extraheaders are removed before saving .git
  • old cache archives are rotated by timestamp

Validation

  • bash -n checkout-with-cache/*.sh
  • shellcheck checkout-with-cache/*.sh
  • YAML parse check
  • local plain tar save/restore smoke test
  • local encrypted tar save/restore smoke test

Thanks for taking a look. We found this really helpful internally, and I figured it might be useful to other RunsOn users too if you like the shape.

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