github-action icon indicating copy to clipboard operation
github-action copied to clipboard

yarn cache saving nothing

Open mmahalwy opened this issue 4 years ago • 2 comments

In the logs:

##[debug]implicitDescendants 'false'
##[debug]followSymbolicLinks 'true'
##[debug]implicitDescendants 'false'
##[debug]omitBrokenSymbolicLinks 'true'
##[debug]Search path '/github/home/.cache/yarn'
##[debug]Cache Paths:
##[debug][]
##[debug]Archive Path: /__w/_temp/07a15199-21c2-43ce-8c0a-cc01882a0843/cache.tgz
/bin/tar --posix -z -cf cache.tgz -P -C /__w/brooklyn/brooklyn --files-from manifest.txt
/bin/tar -z -tf /__w/_temp/07a15199-21c2-43ce-8c0a-cc01882a0843/cache.tgz -P
##[debug]File Size: 45
##[debug]Saving Cache (ID: 69)
##[debug]Upload cache
##[debug]Resource Url: https://artifactcache.actions.githubusercontent.com/fmfATEajpiOCSHwAtp7sjR8AAEAsY7yLnCJarOtkklYPFr9aLe/_apis/artifactcache/caches/69
##[debug]Upload concurrency: 4
##[debug]Upload chunk size: 33554432
##[debug]Awaiting all uploads
##[debug]Uploading chunk of size 45 bytes at offset 0 with content range: bytes 0-44/*
##[debug]Commiting cache
Cache Size: ~0 MB (45 B)
##[debug]Resource Url: https://artifactcache.actions.githubusercontent.com/fmfATEajpiOCSHwAtp7sjR8AAEAsY7yLnCJarOtkklYPFr9aLe/_apis/artifactcache/caches/69
Cache saved successfully

I am noticing that subsequent runs are hitting cache but cache is empty. Probably this is pointing at the wrong paths for yarn. see: https://github.com/cypress-io/github-action/blob/6eb6f881ebf8e50db293da5179bf410769faed5d/index.js#L118 when it should point at whatever yarn cache dir returns?

mmahalwy avatar Aug 03 '21 07:08 mmahalwy

I've found the way to fix it is to add

- run: yarn config set cache-folder ~/.cache/yarn

That way it matches what is in the code.

mmahalwy avatar Aug 03 '21 07:08 mmahalwy

I've found the way to fix it is to add

- run: yarn config set cache-folder ~/.cache/yarn

That way it matches what is in the code.

These issues seem to be tangentially related: #430

This workaround is not really a solution if you are leveraging Zero-Installs and using the --immutable --immutable-cache options in the CI install step ahead of Cypress.

If I try the workaround mentioned above (using yarn2 syntax) before my install step:

      # Change Yarn Cache folder to match expectation of cypress-io/github-action@v2
      # https://github.com/cypress-io/github-action/issues/407
      - name: Change Yarn Cache Folder for Cypress GitHub action Bug Workaround
        run: yarn config set cacheFolder ~/.cache/yarn

Then, I'll get this error:

Run yarn install --immutable --immutable-cache
Internal Error: Cache path does not exist.

Locally, if you run this in the project, you'll see that it's adding the following line to the .yarnrc.yml:

cacheFolder: /Users/forgo/.cache/yarn

If you dig into the yarn code, you'll see this: https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-core/sources/Cache.ts#L131

With Zero-Installs, most projects will be checking in their entire cache directory: <projectRoot>/.yarn/cache -- which doesn't match the expected path you mentioned ~/.cache/yarn within the context of this GitHub action.

To fix this, I believe there needs to be a way for inputPath to be configurable OR to default to to the yarn (berry) cache directly. Possibly a flag that enables yarnZeroInstalls: true to get this out-of-the-box.

What are your thoughts?

forgo avatar Sep 28 '21 21:09 forgo

  • Closing in favor of https://github.com/cypress-io/github-action/issues/969

See also the updated README > Yarn Modern which discusses how to run Yarn Modern including a workaround for Yarn Plug'n'Play.

MikeMcC399 avatar Nov 07 '23 08:11 MikeMcC399