cypress-io / circleci-orb

Install, cache and run Cypress.io tests on CircleCI with minimal configuration.
https://circleci.com/orbs/registry/orb/cypress-io/cypress
MIT License
161 stars 101 forks source link

Need help overriding node version 18.16.1 #467

Closed delusioninabox closed 2 weeks ago

delusioninabox commented 7 months ago

Cypress is installing all my NPM packages by default with node version 18.16.1. Because of the older version, some of our packages appear to be installing older versions despite being newer versions in our package-lock file. We have a few tests that are flaky in circleci but run reliably locally, and I think they might be related, so I want our Cypress tests in circleci to run on a newer version to see if that resolves some of that inconsistency.

I have tried following the steps in the documentation and alternative configurations, but it runs on 18.16.1 every time regardless. Our setup is also set to work with circleci's "rerun failed tests" and following that documentation, if that matters. I tried different cypress/browsers for the image and had the same result.

version: 2.1
orbs:
  cypress: cypress-io/cypress@3

executor:
  docker:
    - image: cypress/browsers:node-20.12.0-chrome-123.0.6312.86-1-ff-124.0.2-edge-123.0.2420.65-1

workflows:
  build-deploy:
    jobs:
      - cypress/run:
          parallelism: 10
          start-command: 'npm start'
          cypress-command: |
            mkdir test_results
            npx wait-on http://localhost:3001
            circleci tests glob "cypress/e2e/**/*.cy.ts" |
            circleci tests run --command="xargs npx cypress run --reporter cypress-circleci-reporter --spec" --split-by=timings --verbose
          post-steps:
            - store_test_results:
                path: test_results

Can someone help spot what I'm missing to get this running on a different node version than the default?

jennifer-shehane commented 7 months ago

@delusioninabox Could you share some of the output that shows Node 18.16.1 being used?

delusioninabox commented 7 months ago

@jennifer-shehane Of course!

The spin up environment step:

Build-agent version 1.0.234836-59bdf2c3 (2024-04-15T14:48:32+0000).
System information:
 Server Version: 24.0.9
 Storage Driver: overlay2
  Backing Filesystem: xfs
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Kernel Version: 5.15.0-1053-aws
 Operating System: Ubuntu 20.04.6 LTS
 OSType: linux
 Architecture: x86_64

Starting container cimg/node:18.16.1-browsers
Warning: No authentication provided, using CircleCI credentials for pulls from Docker Hub.
  image cache not found on this host, downloading cimg/node:18.16.1-browsers
18.16.1-browsers: Pulling from cimg/node
2ab09b027e7f: Already exists 
7b8664c77e57: Already exists 
217f1150b17c: Already exists 
b67a6a85b221: Already exists 
0f829e38bde7: Already exists 
44a002a96bdc: Already exists 
5546d74a5479: Already exists 
4f4fb700ef54: Already exists 
613613a13e99: Already exists 
6250e3504854: Already exists 
4f550f5c419d: Already exists 
1792f3d5cbfa: Pull complete 
2e3101443624: Pull complete 
84508b676d07: Pull complete 
Digest: sha256:49903b71aac206cdc489648589909f480a24f178d3274a2979686377f7fbf88c
Status: Downloaded newer image for cimg/node:18.16.1-browsers
cimg/node:18.16.1-browsers:
  using image cimg/node@sha256:49903b71aac206cdc489648589909f480a24f178d3274a2979686377f7fbf88c
  pull stats: download 173.3MiB in 1.754s (98.74MiB/s), extract 173.3MiB in 5.22s (33.19MiB/s)
  time to create container: 3.473s
Time to upload agent and config: 430.218157ms
Time to start containers: 243.35086ms

At the start of the installing NPM packages step:

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package '<<removed>>'
npm WARN EBADENGINE   required: { node: '21.5.0', npm: '10.2.5' },
npm WARN EBADENGINE   current: { node: 'v18.16.1', npm: '9.5.1' }
npm WARN EBADENGINE }
MikeMcC399 commented 7 months ago

@delusioninabox

A working example on https://github.com/cypress-io/cypress-realworld-app/blob/develop/.circleci/config.yml is using executors: instead of executor:. Does that make any difference if you try that out on your workflow?

version: 2.1
orbs:
  cypress: cypress-io/cypress@3.3.1
  codecov: codecov/codecov@1.2.3 #

executors:
  with-chrome-and-firefox:
    docker:
      - image: "cypress/browsers:node-20.12.0-chrome-123.0.6312.86-1-ff-124.0.2-edge-123.0.2420.65-1"
    resource_class: large
    environment:
      CYPRESS_coverage: false
delusioninabox commented 7 months ago

Yes, I initially tried with executors and it didn't work. 😔

executors:
  default:
    docker:
      - image: cypress/browsers:node-20.12.0-chrome-123.0.6312.86-1-ff-124.0.2-edge-123.0.2420.65-1
MikeMcC399 commented 4 months ago
TooColline commented 4 months ago

@MikeMcC399 Yeah that works, although it would be nice to have the option for cypress/run as well

MikeMcC399 commented 4 months ago

@TooColline

Yeah that works, although it would be nice to have the option for cypress/run as well

Agreed! I added some comment into https://github.com/cypress-io/circleci-orb/issues/468#issuecomment-2227301918 about this.

delusioninabox commented 4 months ago

Thanks y'all! Agreed that an option for cypress/run would be fantastic. 💯

MikeMcC399 commented 3 months ago

@TooColline / @delusioninabox

Thanks y'all! Agreed that an option for cypress/run would be fantastic. 💯

MikeMcC399 commented 1 month ago