question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cache multiple paths

See original GitHub issue

It can be useful to cache multiple directories, for example from different tools like pip and pre-commit.

With Travis CI (ignoring their pip: true shortcut):

cache:
  directories:
    - $HOME/.cache/pip
    - $HOME/.cache/pre-commit

The Actions equivalent requires adding a duplicated step for each directory, something like:

      - name: pip cache
        uses: actions/cache@preview
        with:
          path: ~/.cache/pip
          key: ${{ matrix.python-version }}-pip

      - name: pre-commit cache
        uses: actions/cache@preview
        with:
          path: ~/.cache/pre-commit
          key: ${{ matrix.python-version }}-pre-commit

Perhaps also allow multiple directories in a single step, something like this?

      - name: pip cache
        uses: actions/cache@preview
        with:
          path:
            - ~/.cache/pip
            - ~/.cache/pre-commit
          key: ${{ matrix.python-version }}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:64
  • Comments:31 (13 by maintainers)

github_iconTop GitHub Comments

16reactions
hugovkcommented, Nov 13, 2019

Certainly not all ecosystems, but for some major ones.

Compare the config for Python’s pip with Travis CI:

cache: pip

With GitHub Actions:

      - name: Ubuntu cache
        uses: actions/cache@v1
        if: startsWith(matrix.os, 'ubuntu')
        with:
          path: ~/.cache/pip
          key:
            ${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/setup.py')
            }}
          restore-keys: |
            ${{ matrix.os }}-${{ matrix.python-version }}-

      - name: macOS cache
        uses: actions/cache@v1
        if: startsWith(matrix.os, 'macOS')
        with:
          path: ~/Library/Caches/pip
          key:
            ${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/setup.py')
            }}
          restore-keys: |
            ${{ matrix.os }}-${{ matrix.python-version }}-

      - name: Windows cache
        uses: actions/cache@v1
        if: startsWith(matrix.os, 'windows')
        with:
          path: ~\AppData\Local\pip\Cache
          key:
            ${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/setup.py')
            }}
          restore-keys: |
            ${{ matrix.os }}-${{ matrix.python-version }}-

10 characters vs. 1,000 characters!

I know which I’m be more confident using, and prefer suggesting for projects to add 😃

Travis also has shortcuts like:

cache: bundler   # Ruby
cache: cocoapods # Objective-C
cache: npm       # npm
cache: yarn      # yarn
cache: ccache    # C or other C/C++ variants 
cache: packages  # R
cache: cargo     # Rust

The flexibility of GHA’s caching is good, but it would be even better to have some user-friendly shortcuts. Thanks!

14reactions
chrispatcommented, Oct 31, 2019

We made a scoping call for the v1 to not support multiple paths. This is something we do plan to look at for the future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using GitHub cache action with multiple cache paths?
I was able to make it work with a few modifications;. use relative paths instead of absolute; use a hash of the content...
Read more >
Caching dependencies to speed up workflows - GitHub Docs
Multiple workflow runs in a repository can share caches. ... You can specify a single path, or you can add multiple paths on...
Read more >
GitHub Actions: V2 cache actions | GitHub Changelog
Added support for caching multiple paths, wildcard patterns path or single file path; Increased performance and improved cache sizes using zstd ...
Read more >
CI build: How to cache different paths by different keys? - GitLab
I suspect it should be possible by splitting pages into multiple jobs, one doing the compilation and one the creation of the pages, ......
Read more >
Caching Strategies - CircleCI
Split cache keys by directory. Having multiple directories under a single cache key increases the chances of there being a change to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found