Open dtinth opened 1 year ago
Anyone knows what the difference is between the two methods? https://github.com/pnpm/action-setup/issues/82
I don't know if I have set this up incorrectly, but I find the manual way to be faster than using the cache from setup-node
.
The manual way does not require us to install the packages again (as we cache node_modules
), while this suggested one does require it:
setup-node
(~1m)(This was a cache hit)
setup-node
step config - name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8.1.0
run_install: false
# Has to be done after installing pnpm, otherwise the cache will not work.
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm
cache-dependency-path: 'pnpm-lock.yaml'
@nicolassanmar Does your “manual” setup also cache node_modules
? Using cache: pnpm
merely caches the pnpm store, not node_modules
.
This is how I interpret the log message:
Log message | Description |
---|---|
resolved X, reused 0, downloaded X, added X, done |
Cache is not working. |
resolved X, reused X, downloaded 0, added X, done |
Store cache is working. |
Already up to date |
node_modules is cached. |
@dtinth You are 100% right. I thought that https://github.com/pnpm/action-setup#use-cache-to-reduce-installation-time suggested caching node_modules
but I was mistaken.
I am manually caching node_modules
and ~I don't think setup-node
provides a way to do that~
They stated that it is not supported and they are not planning to add it https://github.com/actions/setup-node/issues/406#issuecomment-1014271353
thanks guys for the discussion, makes it much more clear!
I think more info about this would be appreciated to newcomers, any ideas how to improve the docs in this regard?
I would highly suggest you show both as two different options (as opposed to replacing the existing one) - this solution won't work if you're using a self-hosted runner that has node pre-installed
pnpm
docs also mention using setup-node
to cache pnpm
store
https://pnpm.io/continuous-integration#github-actions
I think we should update the example to go the recommended way by using setup-node
. I think that would be the recommended way given you don't have to maintain a custom cache. setup-node
takes care of that for you (what if pnpm store
command is deprecated and now another one is used? setup-node
would take care of that). So a thing less to worry about
Links:
actions/setup-node
supports the optioncache: pnpm
, so we can take advantage of that to make our workflow simpler.Note:
pnpm/action-setup
must be run BEFOREactions/setup-node
because otherwise thesetup-node
action will fail due to not being able to find the pnpm executable.