node-ipc icon indicating copy to clipboard operation
node-ipc copied to clipboard

ci: fix nodejs matrix

Open achrinza opened this issue 2 years ago • 2 comments

Previously, all tests were running against the default LTS version of Node.js at the time of the run. This fixes the mismatched Node.js version matrix variable.

Signed-off-by: Rifa Achrinza [email protected]

achrinza avatar Mar 25 '22 14:03 achrinza

I don't think this is accurate. Can you provide a documentation link for it?

RIAEvangelist avatar Mar 30 '22 04:03 RIAEvangelist

Copied over from https://github.com/achrinzatest/RIAEvangelist--node-ipc--594/issues/2


If we look at the "Use Node.js" step of the last run in https://github.com/RIAEvangelist/node-ipc, we can see the following, even for runs that should've been for Node.js v14:

Run actions/setup-node@v1
/usr/local/bin/node --version
v16.14.0
/usr/local/bin/npm --version
8.3.1

If we look at the same step of the run for the patch, we can see this fixes the issue:

Run actions/setup-node@v1
/Users/runner/hostedtoolcache/node/14.19.1/x64/bin/node --version
v14.19.1
/Users/runner/hostedtoolcache/node/14.19.1/x64/bin/npm --version
6.14.16

Note that the step is now correctly called "Use Node.js 14.x".

This is because jobs.[job name].strategy.matrix accepts any arbitrary variable and arbitrary value. node_version is not a special keyword that's recognised by GitHub Actions.

By reading through the GitHub Actions Workflow, we can see the discrepancy in the variables used (node-version vs node_version):

https://github.com/RIAEvangelist/node-ipc/blob/088a1ca4d5fe5d175c43ee41718b72b017f6f6a4/.github/workflows/node.js.yml#L22-L24

https://github.com/RIAEvangelist/node-ipc/blob/088a1ca4d5fe5d175c43ee41718b72b017f6f6a4/.github/workflows/node.js.yml#L30

As per-the documentation:

A matrix allows you to create multiple jobs by performing variable substitution in a single job definition. ... Each option you define in the matrix has a key and value. The keys you define become properties in the matrix context and you can reference the property in other areas of your workflow file.

In the same documentation, they provided an example of using multiple Node.js version with a different matrix variable, node:

strategy:
  matrix:
    node: [10, 12, 14]
steps:
  # Configures the node version used on GitHub-hosted runners
  - uses: actions/setup-node@v2
    with:
      # The Node.js version to configure
      node-version: ${{ matrix.node }}

achrinza avatar Apr 09 '22 07:04 achrinza