pnpm / action-setup

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

[Q] Setup Node Cache #82

Open robotkutya opened 1 year ago

robotkutya commented 1 year ago

What's the difference in using the cache via https://github.com/pnpm/action-setup#use-cache-to-reduce-installation-time

Versus using cache: 'pnpm' with: https://github.com/actions/setup-node

Thank you!

nicolassanmar commented 1 year ago

I'm also curious about this. When run manually, we can also cache node_modules which leads to faster results, but regarding the pnpm store both solutions might be equal.

See my comparison of the two runs (one caching node_modules and the other not) here: https://github.com/pnpm/action-setup/pull/76#issuecomment-1587440914

codeflorist commented 1 year ago

https://pnpm.io/continuous-integration#github-actions uses the cache: 'pnpm' version. imho the readme of this package and the website should use identical examples.

mmkal commented 1 year ago

Is there any reason the action couldn't automatically set up node and caching for users? It would be great if we could do something like:

on: [push]
jobs:
  test:
    steps:
      - uses: pnpm/action-setup@vnext
        with:
          do-for-me: node,cache,install
      - run: pnpm-test

People who wanted fine-grained control could just opt out of do-for-me and run separate uses: actions/setup-node, uses: actions/cache and run: pnpm install themselves. But getting started and being confident you're doing things a recommended/supported way would become very easy.

I think the equivalent of the above right now is something like this according to this repo's docs:

on: [push]
jobs:
  cache-and-install:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 16

      - uses: pnpm/action-setup@v2
        name: Install pnpm
        with:
          version: 7
          run_install: false

      - name: Get pnpm store directory
        shell: bash
        run: |
          echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

      - uses: actions/cache@v3
        name: Setup pnpm cache
        with:
          path: ${{ env.STORE_PATH }}
          key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
          restore-keys: |
            ${{ runner.os }}-pnpm-store-

      - name: Install dependencies
        run: pnpm install

      - run: pnpm test
FFdhorkin commented 11 months ago

@mmkal I believe that would be covered under #80