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

chore: add debug output of node.js version #1417

Merged

Conversation

MikeMcC399
Copy link
Collaborator

@MikeMcC399 MikeMcC399 commented Mar 29, 2025

Situation

If Cypress fails to run using the Module API, for instance due to an issue with the Cypress config file, which was the case with issue #1408, no information about the version of Node.js being used is logged.

The action selects the Node.js major version through the setting for runs.using:

cypress-io/github-action@v6 selects:

github-action/action.yml

Lines 102 to 104 in 4b97333

runs:
using: 'node20'
main: 'dist/index.js'

Based on the runs.using setting, GitHub Actions runner takes the value of Node.js from https://github.com/actions/runner/blob/main/src/Misc/externals.sh

GitHub Actions runner v2.323.0 is set to:

NODE20_VERSION="20.19.0"

Currently only node20 is allowed for runs.using.

This version of Node.js is separate from the one provided by the GitHub Runner image default Node.js version, for example, currently windows-2025 sets its default to Node.js 22.14.0. It is also separate from and uninfluenced by any alternate Node.js version that might be installed into the runner using actions/setup-node.

Change

Expose Node.js process.version in the debug log when calling the Cypress Module API.

The debug log command outputs the Node.js value if the DEBUG environment variable is set as follows:

  env:
    DEBUG: '@cypress/github-action'

see Debugging.

Verification

View workflow log workflows/example-debug.yml, job action-debug, step Cypress action debug logs and confirm that the Node.js version is displayed, similar to the following:

@cypress/github-action Running Cypress tests using Module API
@cypress/github-action requiring cypress dependency, cwd is /home/runner/work/github-action/github-action
@cypress/github-action working directory /home/runner/work/github-action/github-action/examples/basic
@cypress/github-action resolved cypress /home/runner/work/github-action/github-action/examples/basic/node_modules/cypress/index.js
@cypress/github-action GitHub JavaScript Action Node.js version v20.19.0
@cypress/github-action Cypress options {"headed":false,"record":false,"parallel":false,"quiet":false,"component":false}

@MikeMcC399 MikeMcC399 added the type: enhancement New feature or request label Mar 29, 2025
@MikeMcC399 MikeMcC399 self-assigned this Mar 29, 2025
@cypress-app-bot
Copy link

@MikeMcC399
Copy link
Collaborator Author

Example debug log showing Node.js version in successful workflow:

https://github.com/cypress-io/github-action/actions/runs/14144517533/job/39630213417?pr=1417#step:3:55

Example in unsuccessful workflow showing Node.js debug log line displayed before Cypress error:

2025-03-29T10:08:16.453Z @cypress/github-action No start command found
2025-03-29T10:08:16.644Z @cypress/github-action Running Cypress tests using Module API
2025-03-29T10:08:16.644Z @cypress/github-action requiring cypress dependency, cwd is /home/runner/work/github-action/github-action
2025-03-29T10:08:16.644Z @cypress/github-action working directory /home/runner/work/github-action/github-action/examples/basic
2025-03-29T10:08:16.644Z @cypress/github-action resolved cypress /home/runner/work/github-action/github-action/examples/basic/node_modules/cypress/index.js
2025-03-29T10:08:16.644Z @cypress/github-action GitHub JavaScript Action Node.js version v20.19.0
2025-03-29T10:08:16.645Z @cypress/github-action Cypress options {"headed":false,"record":false,"parallel":false,"quiet":false,"component":false}

DevTools listening on ws://127.0.0.1:34403/devtools/browser/1bb92478-2b96-4480-81a4-203f6128946e
(node:2372) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("file%3A///home/runner/.cache/Cypress/14.2.0/Cypress/resources/app/node_modules/ts-node/esm/transpile-only.mjs", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
Your configFile is invalid: /home/runner/work/github-action/github-action/examples/basic/cypress.config.ts

It threw an error when required, check the stack trace below:

SyntaxError: Unexpected token ':'

Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of a repo I've worked in that didn't need this printed out inevitably. 👍🏻

@jennifer-shehane jennifer-shehane merged commit a5a6c59 into cypress-io:master Mar 31, 2025
76 checks passed
@MikeMcC399 MikeMcC399 deleted the add/node-version-debug branch March 31, 2025 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants