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.

Add support for cache per job for multiple repo/jobs workflows

See original GitHub issue

Description: Currently a cache option does not allow setting a target cache name. So if you have a setup action like one below in multiple jobs in the same workflow, you will end-up in situation that only the first job is able to create a new cache item.

      - name: Set up JDK 17
        uses: actions/setup-java@v3
        with:
          distribution: 'temurin'
          java-version: '17'
          cache: maven

Now if you think about complex workloads where for example in one job I build one component and in other I build another component, the second job will never be able to create/update the cache, and ends up reporting:

Post job cleanup.
Cache hit occurred on the primary key setup-java-Linux-maven-6c2c8a559e1cd40e1d894833707e2873888f46c5461f3a626c93ef3c40ba0ca5, not saving cache.

We are hitting this issues where we have a multi-repository checkout, and build is split in multiple jobs. Only the first job caches the dependencies correctly. Even in a mono-repo scenarios you might have different independent projects in the same repo that you want to build with some dependency-order.

The simple requirement would be to add a cache name prefix or something like this, so that I would end-up having different caches used in different jobs.

Task version: actions/setup-java@v3

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Repro steps:
Public example: https://github.com/stargate/stargate/actions/workflows/apis-v2.yaml

  • First job Coordinator build is the only one creating a cache item
  • The Unit tests that runs unit tests on different pom.xml is never able to cache dependencies

Expected behavior: Would like to be able to either update cache or specify a different cache name.

Actual behavior: Cache not saved/updated.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ivanseniccommented, Oct 6, 2022

I perfectly understand that the builtin cache should be zero-config and that adding a cache action myself is easy. But have you considered how many people might be doing this wrong? My self as well for example… I was sure that this auto-built caching support would be handling everything, even in different jobs… But in fact my dependencies are not cached and I have longer running actions because of that… Now think on all GitHUb users and how much this “misunderstood” usage costs GitHub a year and how much it costs the environment…

I gave feedback that I consider valuable, because I believe in the feedback-driven development… It’s up to you to decide if this goes into roadmap or not…

I am willing to help… I can set whatever you need, I can even implement the feature myself… Just give me a green light!

1reaction
dmitry-shibanovcommented, Oct 6, 2022

Hello @ivansenic. Thank you for your report. We’ll investigate the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Caching dependencies to speed up workflows - GitHub Docs
To cache dependencies for a job, you can use GitHub's cache action. The action creates and restores a cache identified by a unique...
Read more >
Persisting data in workflows: when to use caching, artifacts ...
Caching persists data between the same job in multiple workflow runs. Caching lets you reuse the data from expensive fetch operations from ...
Read more >
multiple cache in a same job (#32814) · Issues - GitLab
Currently in CI pipelines we can use multiple cache using different keys. But we cannot use multiple cache on the same jobs.
Read more >
GitHub Actions — How To Share Data Between Jobs
Both are used to store files on GitHub, but each one serves a ... Caching is used to re-use data/files between jobs or...
Read more >
github - Share cache between distinct jobs - Stack Overflow
In the first job - uses: actions/cache@v3 with: path: <path to the files you need> # Note that this path is not influenced...
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