actions / actions/toolkit

Check cache for key, skipping download and extraction.

Open
#995 5 comments 19 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the enhancement
Quickly check if the cache exists without having to download and extract a potentially large cache.

Code Snippet

restoreCache(paths, key, [restoreKey], {
    checkKeyOnly: true
 })

checkKeyOnly?: boolean was added to the DownloadOptions interface.

Additional information
I have written a reference implementation (could be used as a PR) for this feature which can be found at:
https://github.com/CareerJSM/toolkit/tree/feature/check-cache-key-only.

In addition, I have updated the action/cache repository to use this new feature in the toolkit:
https://github.com/CareerJSM/cache/tree/feature/check-cache-key-only

I will submit the PR to the actions/cache repository once the toolkit supports this capability.

Edit - 2022-12-19

Since this doesn't appear to be going anywhere, and my branches were falling behind, I re-approached this issue and am now using the gh-actions-cache extension to check the cache.

E.g.

  - name: Check if cache key exists
    id: check-if-cache-current
    env:
      GH_TOKEN: ${{ github.token }}
    run: |
      gh extension install actions/gh-actions-cache
      KEY=${{ steps.gem-cache-keys.outputs.full-key }}
      CACHE_HIT=$(gh actions-cache list --key $KEY | grep -q $KEY && echo 'true' || echo 'false')
      echo "cache-hit=$CACHE_HIT" >> $GITHUB_OUTPUT
  - name: Restore Gem Cache
    if: ${{ steps.check-if-cache-current.outputs.cache-hit != 'true' }}
    id: restore-gem-cache
    uses: actions/cache@v3
    with:
      path: ...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the DownloadOptions interface and the restoreCache entry point described in the issue, then compare the reference implementation in the CareerJSM/toolkit check-cache-key-only branch. Verify how the action/cache branch expects the option to behave. Done means a cache key can be checked without downloading or extracting the cache, with the related behavior covered by the project’s tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ci-cd, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.