Repository navigation
cache doesn't work with github workspace directory #833
Description
Activity
Thank you for the report. I was able to reproduce this. From the first look, it appears that there is a bug while converting the cache paths to relative paths for compression in the toolkit. I will debug the cause and get back.
Contribution are welcome as this will mostly require changes in actions/toolkit and actions/cache.
It doesn't seems to be fixed for some reason :/
I've tested with actions/cache@v3.0.1 both the two version with . and env variable and it still cache 22B @pdotlReacted by Lovepreet SinghHi @erwan-joly , the above version is for actions/cache npm module and not for the actions/cache action. We are yet to merge toolkit changes into the
actions/cache. Once done, you should be able to test and use the same. I'll post an update here once done.@erwan-joly ,please test now with the latest version of actions/cache using
actions/cache@v3.@pdotl I confirm it's now fixed 💯
Reacted by Lovepreet Singh and VipulOne should also consider this issue if he has troubles with
github.worspacecontext and cache action as I did:github.workspace === /home/runner/work/testContainers/testContainers GITHUB_WORKSPACE === /__w/testContainers/testContainers runner.workspace === /home/runner/work/testContainers RUNNER_WORKSPACE === /__w/testContainersMy build job relies on
${{ github.workspace }}to output its result and I want to cache this result and restore it in my publish job. Here is how I made this works:name: Build on: push: tags: - '*' workflow_dispatch: jobs: build: runs-on: ubuntu-latest container: image: mstorsjo/llvm-mingw:latest steps: - name: build stuff run: | echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" echo "github.workspace=${{ github.workspace }}" # echo curent working dir which is $GITHUB_WORKSPACE and not ${{ github.workspace }}. echo "current working dir:" pwd # cd to build dir. # for the example, creates a my_build_dir and cd to it. cd my_build_dir # run build command that generates the buil result in ${{ github.workspace }}/output. # for the example, creates the output dir and touch a result.out file in it. mkdir -p ${{ github.workspace }}/output touch ${{ github.workspace }}/output/result.out # back to $GITHUB_WORKSPACE cd .. cp -r ${{ github.workspace }}/output $GITHUB_WORKSPACE ls -l $GITHUB_WORKSPACE - name: Cache build output id: cache-save-build-ouput uses: actions/cache/save@v3 with: path: | ./output key: ${{ runner.os }}-build-output-run_${{ github.run_id }} enableCrossOsArchive: true publish: runs-on: ubuntu-latest image: mstorsjo/llvm-mingw:latest needs: build steps: - name: Restore build ouput cache uses: actions/cache/restore@v3 id: cache-restore-build-ouput with: path: | ./output key: ${{ runner.os }}-build-output-run_${{ github.run_id }} enableCrossOsArchive: true fail-on-cache-miss: true - name: archive run: | echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" echo "github.workspace=${{ github.workspace }}" # echo curent working dir which is $GITHUB_WORKSPACE and not ${{ github.workspace }}. echo "current working dir:" pwd echo "restored cache output dir:" ls -l ./ouput
Note that restoring a cache in a container image different from the one that saved the cache may fail because the comrpession tool (tar) may be different. For example using
image: alpine:latestcontainer in mypublishjob fails this way:/bin/tar: unrecognized option: POn the other hand, using no container on the my
publishjob fails this way:##[debug]No matching cache found for cache key 'Linux-build-output-run_4252492458', version '864e6dbc1f60e04c96ce9a7e3cc1dc27a256109377aae3de699034043992ea42 and scope refs/tags/v4.2.1-full. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key ##[debug]Other caches with similar key: ##[debug]Cache Key: Linux-build-output-run_4252492[45](https://github.com/khelkun/ffmpeg-wos-arm64-build/actions/runs/4252492458/jobs/7396194685#step:2:46)8, Cache Version: ea8764569ab4d245f2db7a85367253cd303504ee4289[46](https://github.com/khelkun/ffmpeg-wos-arm64-build/actions/runs/4252492458/jobs/7396194685#step:2:47)df7d21a697b0c7812f, Cache Scope: refs/tags/v4.2.1-full, Cache Created: 2023-02-23T12:16:30.7133333Z ##[debug]Failed to delete archive: Error: ENOENT: no such file or directory, unlink '' Error: Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: Linux-build-output-run_4252492458And using the
enableCrossOsArchive: truein theactions/cache/restore@v3does not fix it.Reacted by Wolfgang Anger
Hi, I'm trying to cache the whole workspace to fetch it between jobs.
Unfortunately it seems like the local directory can not be cached
Using . doesn't work (it cache 22B)
Using ${{ github.workspace }} doesn't work (it also cache 22B)
the only solution I found which work is to list all the files/directory