pnpm / action-setup

Install pnpm package manager
https://github.com/marketplace/actions/setup-pnpm
MIT License
949 stars 93 forks source link

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

Open transitive-bullshit opened 2 years ago

transitive-bullshit commented 2 years ago

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!

KSXGitHub commented 2 years ago

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 commented 2 years ago

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 commented 1 year ago

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 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 }}?