pnpm / action-setup

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

How to cache pnpm ? #87

Closed seepine closed 1 year ago

seepine commented 1 year ago
jobs:
  test:
    runs-on: ubuntu-latest
    env:
      RUNNER_TOOL_CACHE: /toolcache
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Setup Pnpm
        uses: pnpm/action-setup@v2
        with:
          version: 7.30.0

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: 16
          cache: 'pnpm'

      - name: Dependent installation
        run: pnpm i

It download pnpm every time.

image

belgattitude commented 1 year ago

I tested few approaches.

The one that works for me is in this gist: https://gist.github.com/belgattitude/838b2eba30c324f1f0033a797bab2e31.

It generally gives amost a 2x boost (see benchmarks https://github.com/belgattitude/compare-package-managers)

With cache

CI Scenario Install CI fetch cache Total Cache size CI persist cache
yarn4 no compression 26s 2s 28s 155Mb (±8s)
pnpm8.5.1 16s 9s 25s 253Mb (±30s)

Without cache

CI Scenario Install Diff with cached run
yarn4 no compression / no cache ±45s < 2x slower
pnpm8 / no cache ±48s 2x slower