action-setup icon indicating copy to clipboard operation
action-setup copied to clipboard

Add setup-node code to examples

Open rajasegar opened this issue 3 years ago • 7 comments

We are calling it out that this action does not setup node and we have to explicitly do it, but sometimes it is not obviously enough to read through the examples till the end and find out about the warning. Instead we can add setup-node code in the README examples itself so that it becomes absolutely apparent. Something like below:

on:
  - push
  - pull_request

jobs:
  install:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js 12
        uses: actions/setup-node@v2
        with:
          node-version: 12

      - uses: pnpm/[email protected]
        with:
          version: 6.0.2
          run_install: |
            - recursive: true
              args: [--frozen-lockfile, --strict-peer-dependencies]
            - args: [--global, gulp, prettier, typescript]

If this is okay, will raise a PR for the same.

rajasegar avatar Mar 09 '22 05:03 rajasegar

This action by itself does not require setup-node, and isn't affected by setup-node, so you'll need to add that clarification in the example. I'll be waiting for your PR.

KSXGitHub avatar Mar 09 '22 05:03 KSXGitHub

This action by itself does not require setup-node, and isn't affected by setup-node, so you'll need to add that clarification in the example. I'll be waiting for your PR.

What do you mean by itself does not require setup-node? Are you implying without setup-node this action alone will work? How can we set something like what version of Node.js to use with this action without setup-node?

rajasegar avatar Mar 09 '22 06:03 rajasegar

Are you implying without setup-node this action alone will work?

Yes. But only for installing pnpm. User still have to use setup-node to run their own JavaScript code.

How can we set something like what version of Node.js to use with this action without setup-node?

The action will not let user specify what Node.js version the action use because it is an implementation detail. Besides, the Node.js version that pnpm uses is irrelevant to the dependencies it installs, why do you care about it anyway?

KSXGitHub avatar Mar 09 '22 06:03 KSXGitHub

I often end up changing my node version for specific jobs in the workflows like semantic-release, that's why I specifically need to set the node version. So to be on the safer side, so that your actions won't error out, can we always use setup node (though pnpm doesn't need it) as a best practice.

rajasegar avatar Mar 09 '22 06:03 rajasegar

So to be on the safer side, so that your actions won't error out, can we always use setup node (though pnpm doesn't need it) as a best practice.

Yes. This action does not care about whatever version setup-node installs. And whatever version this action uses does not affect your code.

KSXGitHub avatar Mar 09 '22 06:03 KSXGitHub

I agree that a full on example would be great 🙏 Trying to use it right now and they suggest setting the cache key to the package manager used pnpm in my case but I have the following error:

image

Edit: Well for my case it happened to be simpler than I thought pnpm must be installed BEFORE Node.js

More info here: https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-dependencies

melMass avatar Mar 18 '22 20:03 melMass

@melMass I will accept a PR that adds a code example that use pnpm/action-setup and actions/setup-node with cache key. There is already a section called "Use cache to reduce installation time" in README.md, you may rename it to "With actions/cache" (or something) and add another section named "Use the cache key in actions/setup-node".

KSXGitHub avatar Mar 19 '22 01:03 KSXGitHub