actions / actions/cache

Caching directories outside of workspace (self-hosted vs GitHub-hosted)

Open
#1,127 14 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:advanced-control
Dominant language
TypeScript
Stars
5.6k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

We are using actions/cache in between jobs that run on a variety of runners (GitHub-hosted and self-hosted) and we noticed the following:

When creating a cache on ubuntu-latest of a directory that is outside the workspace (for example Java - Maven caches the ~/.m2/repository directory), we noticed that the cache archive stores paths relative to the current workspace directory (using ../../..).

When restoring this path on a self-hosted runner, this means that the cache restore will place the files on the ../../.. directory relative to the working directory of the self-hosted runner. This may be different from the filesystem structure of the GitHub-hosted runners, meaning that the cache will be restored in the wrong location (and maven will not be able to find it)

##[debug]Archive Path: /runner/_work/_temp/3670ed6f-f2b5-4387-b1c0-7dee396807af/cache.tzst
##[debug]Use Azure SDK: true
##[debug]Download concurrency: 8
##[debug]Request timeout (ms): 30000
##[debug]Cache segment download timeout mins env var: 5
##[debug]Segment download timeout (ms): 300000
##[debug]Downloading segment at offset 0 with length 262618027...
Received 0 of 262618027 (0.0%), 0.0 MBs/sec
Received 46137344 of 262618027 (17.6%), 22.0 MBs/sec
Received 92274688 of 262618027 (35.1%), 29.3 MBs/sec
Received 146800640 of 262618027 (55.9%), 35.0 MBs/sec
Received 197132288 of 262618027 (75.1%), 37.6 MBs/sec
Received 254229419 of 262618027 (96.8%), 40.4 MBs/sec
Received 262618027 of 262618027 (100.0%), 39.8 MBs/sec
/usr/bin/tar -tf /runner/_work/_temp/3670ed6f-f2b5-4387-b1c0-7dee396807af/cache.tzst -P --use-compress-program unzstd
../../../.m2/repository/
../../../.m2/repository/log4j/
../../../.m2/repository/log4j/log4j/

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 Java - Maven example in examples.md and the actions/cache archive creation and restore entry points. Reproduce the cache across GitHub-hosted and self-hosted runners, inspecting the tar paths shown in the report. Done means directories outside the workspace restore to the intended location regardless of runner filesystem layout.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.