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

Runner externals Node.js version v16.13.0 always used in GHA runs #642

Closed
MikeMcC399 opened this issue Dec 2, 2022 · 9 comments
Closed

Comments

@MikeMcC399
Copy link
Collaborator

MikeMcC399 commented Dec 2, 2022

Description

When github-action is run, the version of Node.js which the Cypress log shows is being used (v16.13.0) is neither the installed version (18.13.0), nor the default version for the runner (v16.19.0).

Cypress shows: v16.13.0 (/home/runner/runners/2.300.2/externals/node16/bin/node)
Default Node.js in runner ubuntu-22.04 runner: v16.19.0

Installed Node.js: 18.13.0 Found in cache @ /opt/hostedtoolcache/node/18.13.0/x64

Steps to reproduce

Environment:
GitHub runner: ubuntu-22.04
Node.js: lts/hydrogen (18.13.0)
Cypress: 12.3.0
github-action: v5.0.5

Run action with following core instructions:

    runs-on: ubuntu-22.04
    env:
      NO_COLOR: true
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
      - name: Setup Node.js 18 environment
        uses: actions/setup-node@v3
        with:
          node-version: 'lts/hydrogen'
      - name: Cypress run
        uses: cypress-io/github-action@v5
        with:
          spec: cypress/e2e/spec.cy.js

Note that the log shows

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        12.3.0                                                                         │
  │ Browser:        Electron 106 (headless)                                                        │
  │ Node Version:   v16.13.0 (/home/runner/runners/2.300.2/externals/node16/bin/node)              │
  │ Specs:          1 found (spec.cy.js)                                                           │
  │ Searched:       cypress/e2e/spec.cy.js                                                         │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

The log shows Node.js version v16.13.0 being used by Cypress, although v18.13.0 was installed before the github-action was called.

Example action to reproduce

Action log file

Expectation

The action should use the Node.js version installed by actions/setup-node@v3 - in this case 18.13.0 - and not Node.js v16.13.0.

@MikeMcC399
Copy link
Collaborator Author

This is not a new issue. Action logs in this repository show this behaviour already a couple of months ago e.g.

For example https://github.com/cypress-io/github-action/actions/runs/3049498633/jobs/4915628273 from Sep 4, 2022:

E2E on Node v14

/opt/hostedtoolcache/node/14.20.0/x64/bin/npx cypress cache list
│ Node Version: v16.13.0 (/home/runner/runners/2.296.2/externals/node16/bin/node) │

where the test is supposed to be running under Node.js 14 and Cypress reports v16.13.0.

@MikeMcC399
Copy link
Collaborator Author

Since action.yml in cypress-io/github-action branch v5 specifies node16 in

github-action/action.yml

Lines 90 to 92 in c5724ed

runs:
using: 'node16'
main: 'dist/index.js'
it seems correct that calling cypress-io/github-action@v5 will make Cypress run under Node.js 16.

It looks like the Node.js version v16.13.0 comes from the definition
NODE16_VERSION="16.13.0"
in GH actions/runner src/Misc/externals.sh.

The Actions documentation Metadata syntax for GitHub Actions describes this:

runs


Please check if I have interpreted this correctly. If so, then the README documentation Node versions would need to be reviewed since it seems that cypress-io/github-action cannot use the Node.js version provided by actions/setup-node and simply uses the node16 version specified in action.yml.

cc: @jaffrepaul

@MikeMcC399
Copy link
Collaborator Author

After setting a repository secret ACTIONS_RUNNER_DEBUG to true (see https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging), re-running the repro steps and downloading the log archive from GitHub, I can see the following in runner-diagnostic-logs > Worker...log:

INFO HostContext] Well known directory 'Bin': '/home/runner/runners/2.299.1/bin'
INFO HostContext] Well known directory 'Root': '/home/runner/runners/2.299.1'
INFO HostContext] Well known directory 'Externals': '/home/runner/runners/2.299.1/externals'
INFO ProcessInvokerWrapper] Starting process:
INFO ProcessInvokerWrapper]   File name: '/home/runner/runners/2.299.1/externals/node16/bin/node'
INFO ProcessInvokerWrapper]   Arguments: '"/home/runner/work/_actions/cypress-io/github-action/v5/dist/index.js"'
INFO ProcessInvokerWrapper]   Working directory: '/home/runner/work/cypress-test-tiny/cypress-test-tiny'

This confirms that github-action always runs in the context of node16.

The consequence is that:

  1. The README documentation Node versions which says that github-action can be run using different Node.js versions is incorrect.
  2. The .github/workflows/example-node-versions.yml action, although successful, doesn't test that Cypress is actually running under the Node.js versions it is implying.

I don't know what the best solution would be: change the documentation to match the software behavior or modify the github-action action so that Cypress can run in different selectable Node.js version environments?

A workaround for simple cases would be to call Cypress directly instead of using github-action as in the example workflow .github/workflows/cypress-native.yaml:

      - name: Cypress run
        run: npx cypress run -s cypress/e2e/spec.cy.js 

(From a practical side for the production repo I am working on, it is not causing any issue to have Cypress run under node16, even though the repo build has been converted to run with Node.js 18.)

@MikeMcC399
Copy link
Collaborator Author

MikeMcC399 commented Dec 5, 2022

@MikeMcC399
Copy link
Collaborator Author

MikeMcC399 commented Dec 6, 2022

There was a breaking change in Cypress 9.0.0, released Nov 10, 2021:

https://docs.cypress.io/guides/references/changelog#9-0-0

"The nodeVersion configuration option now defaults to system. The behavior of the system option has changed to always use the Node.js binary/version that launched Cypress. If Cypress was not launched via the terminal, Cypress will use the bundled Node.js version. This could change the behavior of code within your pluginsFile since it may be run in your system Node.js version. Addresses #18684.

The nodeVersion configuration option has been deprecated and will be removed in a future release.

The bundled Node.js version was upgraded from 14.17.0 to 16.5.0. This could change the behavior of code within the pluginsFile when using the bundled Node.js version of Cypress. Addressed in #18317."


Starting from version 9.0.0, when running github-action v5 under ubuntu-22.04 with Node.js: lts/hydrogen (18.12.1) installed, Cypress reports:

"Node Version: v16.13.0 (/home/runner/runners/2.299.1/externals/node16/bin/node)"

In Cypress version 8, the Node.js version was not reported in the results of running Cypress.


The issue remains that running Cypress through github-action always reports the externals version v16.13.0 whereas running Cypress in a workflow using npx cypress will report the Node.js version installed by the workflow e.g. 18.12.1. Reference to the documentation for github-action implies that the current behavior of github-action is a bug.

@jaffrepaul
Copy link
Member

Thanks for the legwork @MikeMcC399

@MikeMcC399 MikeMcC399 changed the title Wrong Node.js version used Runner externals Node.js version v16.13.0 always used in GHA runs Dec 11, 2022
@MikeMcC399
Copy link
Collaborator Author

JavaScript actions on GitHub can only currently run in node12 or node16. According to information in actions/runner#2255 the next version will probably be node20 later this year.

So the document here needs updating and any workflows which incorrectly assume that cypress-io/github-action v5 runs in anything other than the specified node16 should be simplified.

@MikeMcC399
Copy link
Collaborator Author

MikeMcC399 commented Jan 17, 2023

Viewing the logs from https://github.com/cypress-io/github-action/actions/workflows/example-node-versions.yml?query=branch%3Amaster, for instance https://github.com/cypress-io/github-action/actions/runs/3914280111/jobs/6691164116 for "Cypress v10 E2E on Node v18" shows that:

[command]/opt/hostedtoolcache/node/18.13.0/x64/bin/npm ci
[command]/opt/hostedtoolcache/node/18.13.0/x64/bin/npx cypress cache list
[command]/opt/hostedtoolcache/node/18.13.0/x64/bin/npx cypress verify

are each executed under Node.js 18.13.0.

Only Cypress itself is running under Node.js v16.13.0:

Node Version:   v16.13.0 (/home/runner/runners/2.300.2/externals/node16/bin/node) 

The theme of this issue was that all of the action runs under v16.13.0. I see now that this is incorrect, so I am closing the issue. Any remaining consequences of this mixed-mode use of Node.js should be covered in other issues if necessary.

@MikeMcC399 MikeMcC399 reopened this Jan 17, 2023
@MikeMcC399 MikeMcC399 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2023
@MikeMcC399
Copy link
Collaborator Author

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

2 participants