pnpm / action-setup

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

Enhancement: cache pnpm-store #8

Closed hildjj closed 3 years ago

hildjj commented 3 years ago

Correct caching of the ~/.pnpm-store directory would be cool.

See https://github.com/bahmutov/npm-install for one approach to get ideas from

KSXGitHub commented 3 years ago

Use actions/cache for that.

hildjj commented 3 years ago

Maybe add an example to the docs then? This is what I came up with:

      - name: Cache pnpm modules
        uses: actions/cache@v2
        env:
          cache-name: cache-pnpm-modules
        with:
          # pnpm cache files are stored in `~/.pnpm-store` on Linux/macOS
          path: ~/.pnpm-store
          key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}
          restore-keys: |
            {{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}

and

      - name: clean pnpm store
        run: store prune 

at the end

KSXGitHub commented 3 years ago

You don't need to run pnpm prune directly since post-action of pnpm/action-setup does it for you. Otherwise, it is a good pull request.

hildjj commented 3 years ago

will send PR, and thanks for the info on the prune.

privatenumber commented 2 years ago

What's the benefit of running pnpm store prune at the end? Is it just to keep the cache size to a minimum? Or is it somehow necessary for expected behavior?

KSXGitHub commented 2 years ago

@privatenumber It's just to keep cache size to a minimum.

nelson6e65 commented 2 years ago

Cache's path needs to be set to action's dest input, or is always ~/.pnpm-store?

Can I use dest output like the following example?

      - uses: pnpm/action-setup@v2.0.1
        id: pnpm-install
        with:
          version: 7
          run_install: false

      - uses: actions/cache@v3
        name: Packages cache
        with:
          path: ${{ steps.pnpm-install.outputs.dest }}
          key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
          restore-keys: |
            ${{ runner.os }}-pnpm-

In readme states: "Where to store pnpm files" is this that should be cached or includes pnpm internal files?

EDIT: This does not work as expected, since dest output is not the pnpm store directory. Solucion provided in #41

nelson6e65 commented 2 years ago

There are other directories documented at https://pnpm.io/npmrc#store-dir. Is that directory the intended to be set in the path input?

zkochan commented 2 years ago

no, store-dir should not be in PATH

nelson6e65 commented 2 years ago

no, store-dir should not be in PATH

I meant, the path input of this action. 😅