Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current GH action caching boilerplate is too complex and out of sync with the official actions/setup-node #68

Open
transitive-bullshit opened this issue Nov 8, 2022 · 3 comments

Comments

@transitive-bullshit
Copy link

First off, love pnpm ❤️

I've been gradually replacing yarn v1 with pnpm in all of my OSS repos, and adding pnpm to GitHub actions is currently kind of ugly / verbose / error-prone.

The official actions/setup-node guide also recommends a completely different, simpler approach which doesn't seem to work. See the Caching pnpm (v6.10+) dependencies in their guide, which uses the much simpler cache: 'pnpm' parameter. Since this is how caching works for npm and yarn, I fully expected pnpm caching to "just work" using the official actions/setup-node guide, but it doesn't appear to.

Here's an example of the boilerplate that I'm currently using which matches the caching setup recommended by this repo's readme. As far as I can tell, the caching is taking effect, BUT it seems brittle to have this logic spread across N repositories instead of in pnpm/action-setup and/or the official GitHub actions/setup-node.

For maintainers with lots of repos like myself, this is an annoyance that I know will cause a maintenance burden down the line.

So I'm opening this issue to get feedback and track a better solution going forwards.

Thanks!

@transitive-bullshit transitive-bullshit changed the title Current basic GH action caching boilerplate is too complex and out of sync with the official actions/setup-node Current GH action caching boilerplate is too complex and out of sync with the official actions/setup-node Nov 8, 2022
@KSXGitHub
Copy link
Collaborator

The official actions/setup-node guide also recommends a completely different, simpler approach which doesn't seem to work.

Sounds like a bug on actions/setup-node behalf? I am not a maintainer of actions/setup-node so I can do nothing about it. I cannot just copy the guide on actions/setup-node to pnpm/action-setup because, if your words are to be believed, it doesn't work.

@KSXGitHub
Copy link
Collaborator

KSXGitHub commented Nov 9, 2022

But I do agree that currently, the only way to do cache is a bit to complex, if pnpm/action-setup has cache built-in, things would've been a lot simpler. I'm not going to implement it though, if someone else wants to tackle this, feel free.

@axelboc
Copy link

axelboc commented Dec 12, 2022

The solution documented by actions/setup-node worked for me, but I ran into a limitation: I use Cypress, which downloads binaries in a post-install script and stores them in a ~/.cache/Cypress folder that is meant to be cached along with the pnpm store directory.

The maintainers of actions/setup-node are not willing to complexify the caching feature to solve this, and I understand their reasoning. The feature is really just for convenience and that's a good thing.

if pnpm/action-setup has cache built-in, things would've been a lot simpler.

I don't think pnpm/action-setup should attempt to deal with caching dependencies, whichever the approach:

  • I don't see the point of providing a convenience caching option since actions/setup-node already provides one (if it doesn't work for you @transitive-bullshit, then that's something to look into for sure).
  • Attempting to support more advanced caching scenarios like mine would basically require replicating actions/cache's configuration API, which seems pointless.

I do think, however, that the README should document the convenience caching method provided by actions/setup-node ... or at least link to it.

For advanced caching use cases, in my opinion, pnpm/action-setup should just do its best to make caching the pnpm store directory in a separate action as easy as possible. Right now, I think the main complexity comes from having an extra step to get the pnpm store's path (i.e. echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT). Any chance pnpm/action-setup could save the pnpm store path as an output so it can be used directly in actions/cache with path: ${{ steps.pnpm-install.outputs.storePath }}?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants