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

[Q] Setup Node Cache #82

Open
robotkutya opened this issue May 5, 2023 · 4 comments
Open

[Q] Setup Node Cache #82

robotkutya opened this issue May 5, 2023 · 4 comments

Comments

@robotkutya
Copy link

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
Copy link

nicolassanmar commented Jun 12, 2023

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: #76 (comment)

@codeflorist
Copy link

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
Copy link

mmkal commented Sep 7, 2023

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
Copy link

FFdhorkin commented Sep 27, 2023

@mmkal I believe that would be covered under #80

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

5 participants