actions / actions/cache

Cache not found between jobs while being in the same run

Open
#1,194 8 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5.6k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

I've found a strange bug with cache action. I know about cache being only available to the PR with the branch you are working on, and only when run is finished. this is not an usage issue on my side.

In short, here is what I do with cache.

My CI:

job 1 is recovering a cache using a key, if not available, download the data from somewhere else and upload an artifact, on sucess, cache is updated with the new data if any as cache action do automatically.

job 2 is recovering a cache using the same key, if not available download the artifact and keep going from there. On sucess cache is updated but technically it is not even needed as job1 has already done it.

The problematic workflow: There is a specific situation where this breaks and it should not, when new data is available and job 2 fails.

RUN 1 (new data, broken build)

job 1 is trying to recover cache using a key, there is new data so cache is not available, so data is being downloaded from alternate source and uploaded as artifacts. cache is created from the new data as job1 is successful.

job 2 is trying to recover cache using a key, there is new data so cache is not available, so data artifact is donwloaded instead. job 2 fails to build for an unrelated reason. no cache is created from the new data as the job failed.

All behavior is expected from now

RUN 2 (no new data, build fixed)

job 1 is trying to recover cache using a key it is found, job1 succeed

job 2 is trying to recover cache using a key BUT FAILS FOR AN UNKNOWN REASON, job 2 tries to fallback on artifact, which is not available, job 2 fails.

I can see the cache listed in the cache, but job2 is not able and will never be able to access it, while job 1 can access it super fine.

Let me know If I missed anything here. I could try to create a minimal repo to reproduce this but that would be a fair amount of work so I will wait for some feedback first.

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

The report names no source file or test; begin with the described two-job workflow, using the same cache key and artifact fallback across two runs. Confirm done when job 2 in the second run can restore the cache created by job 1 in the first run, or capture the failure details needed to isolate it.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, typescript
Domain
ci-cd, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.