nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.26k stars 2.32k forks source link

nx-agents and cypress unable to find cypress binary #21750

Closed faileon closed 4 months ago

faileon commented 7 months ago

Current Behavior

Hi, I am trying to run e2e tests with nx-cloud and nx-agents, I have run into some issues previously with OOM: Failed to adjust OOM score of renderer with pid 1350

I tried switching to linux-large-plus-js and upgrading Cypress to latest version 13.6.4

Now the cloud reports:

The cypress npm package is installed, but the Cypress binary is missing.

We expected the binary to be installed here: /home/workflows/.cache/Cypress/13.6.4/Cypress/Cypress

Reasons it may be missing:

  • You're caching 'node_modules' but are not caching this path: /home/workflows/.cache/Cypress
  • You ran 'npm install' at an earlier build step but did not persist: /home/workflows/.cache/Cypress

Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.

Alternatively, you can run 'cypress install' to download the binary again.

Before the update it used to be unzipping cypress etc. My workflow.yaml:

name: Run cypress e2e tests on PR

on:
    pull_request:
        types: [opened, reopened, synchronize]
        branches:
            - master

jobs:
    test:
        name: Run e2e tests and build
        runs-on: ubuntu-latest
        steps:
            # check out the repo
            - uses: actions/checkout@v4
              with:
                  fetch-depth: 0
            # setup pnpm
            - uses: pnpm/action-setup@v2
              with:
                  version: 8
            # setup nodejs
            - uses: actions/setup-node@v3
              with:
                  node-version: 20
                  cache: 'pnpm'
            # setup nx-cloud agents
            - run: |
                  pnpm dlx nx-cloud start-ci-run --distribute-on="3 linux-large-plus-js" --stop-agents-after="e2e"
            # restore cached deps
            - name: Restore cached npm dependencies
              id: cache-dependencies-restore
              uses: actions/cache/restore@v3
              with:
                  path: |
                      node_modules
                      ~/.cache/Cypress # needed for the Cypress binary
                  key: npm-dependencies-${{ hashFiles('pnpm-lock.yaml') }}
            # install deps
            - run: pnpm install --frozen-lockfile
            # cache deps
            - name: Cache npm dependencies
              id: cache-dependencies-save
              uses: actions/cache/save@v3
              with:
                  path: |
                      node_modules
                      ~/.cache/Cypress # needed for the Cypress binary
                  key: ${{ steps.cache-dependencies-restore.outputs.cache-primary-key }}
            # This line is needed for nx affected to work when CI is running on a PR
            - uses: nrwl/nx-set-shas@v3
            - run: git branch --track master origin/master
            # run targets lint, build
            - name: Run affected e2e,build in parallel
              run: pnpm nx affected -t lint,build --parallel=3
            # run target e2e
            - run: pnpm nx affected -t e2e --parallel=1
              env:
                  GRAPHQL_GATEWAY_HOST: http://localhost
                  GRAPHQL_GATEWAY_PORT: 4000

I am not sure what could be wrong, I was following the official docs and just made a few minor tweaks.

Expected Behavior

Cypress should work

GitHub Repo

No response

Steps to Reproduce

1.

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 20.10.0
   OS     : win32-x64
   pnpm   : 8.6.2

   nx                 : 18.0.1
   @nx/js             : 18.0.1
   @nx/jest           : 18.0.1
   @nx/linter         : 18.0.1
   @nx/eslint         : 18.0.1
   @nx/workspace      : 18.0.1
   @nx/angular        : 18.0.1
   @nx/cypress        : 18.0.1
   @nx/devkit         : 18.0.1
   @nx/eslint-plugin  : 18.0.1
   @nx/nest           : 18.0.1
   @nx/node           : 18.0.1
   @nx/plugin         : 18.0.1
   @nx/storybook      : 18.0.1
   @nrwl/tao          : 18.0.1
   @nx/web            : 18.0.1
   @nx/webpack        : 18.0.1
   typescript         : 5.3.3
   ---------------------------------------
   Community plugins:
   @jscutlery/semver     : 5.0.0
   @ngrx/component-store : 17.0.1
   @ngrx/effects         : 17.0.1
   @ngrx/router-store    : 17.0.1
   @ngrx/store           : 17.0.1
   @ngrx/store-devtools  : 17.0.1
   @storybook/angular    : 7.6.12
   apollo-angular        : 6.0.0
   ---------------------------------------
   Local workspace plugins:
         @datera/nx

Failure Logs

Build at: 2024-02-09T14:10:42.808Z - Hash: 8621efc0d7d90650 - Time: 29926ms

** Angular Live Development Server is listening on localhost:4203, open your browser on http://localhost:4203/ **

✔ Compiled successfully.

shared module @apollo/client/link/batch -> /home/workflows/workspace/node_modules/.pnpm/@apollo+client@3.7.9_graphql@16.6.0_react-dom@18.2.0_react@18.2.0/node_modules/@apollo/client/link/batch/index.js - Warning: No version specified and unable to automatically determine one. No version in description file (usually package.json). Add version to description file /home/workflows/workspace/node_modules/.pnpm/apollo-angular@6.0.0_@angular+core@17.1.2_@apollo+client@3.7.9_graphql@16.6.0_rxjs@7.8.1/node_modules/@apollo/client/link/batch/package.json, or manually specify version in shared config.

shared module @apollo/client/core -> /home/workflows/workspace/node_modules/.pnpm/@apollo+client@3.7.9_graphql@16.6.0_react-dom@18.2.0_react@18.2.0/node_modules/@apollo/client/core/index.js - Warning: No version specified and unable to automatically determine one. No version in description file (usually package.json). Add version to description file /home/workflows/workspace/node_modules/@apollo/client/core/package.json, or manually specify version in shared config.

The cypress npm package is installed, but the Cypress binary is missing.

We expected the binary to be installed here: /home/workflows/.cache/Cypress/13.6.4/Cypress/Cypress

Reasons it may be missing:

- You're caching 'node_modules' but are not caching this path: /home/workflows/.cache/Cypress
- You ran 'npm install' at an earlier build step but did not persist: /home/workflows/.cache/Cypress

Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.

Alternatively, you can run 'cypress install' to download the binary again.

https://on.cypress.io/not-installed-ci-error

----------

Platform: linux-x64 (Ubuntu - 22.04)
Cypress Version: 13.6.4

Package Manager Version

No response

Operating System

Additional Information

No response

faileon commented 7 months ago

Also attaching the other error message we get when it decides to find the cypress binary every now and then:

 >  NX   Successfully ran target build for project absint-app and 91 tasks it depends on

   Nx read the output from the cache instead of running the command for 92 out of 92 tasks.

It looks like this is your first time using Cypress: 13.6.4

[STARTED] Task without title.
Starting up http-server, serving dist/apps/absint-app

http-server version: 14.1.1

http-server settings: 
CORS: true
Cache: -1 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none

Available on:
  http://localhost:4200
Unhandled requests will be served from: http://localhost:4200?. Options: {"secure":false,"prependPath":true}
Hit CTRL-C to stop the server

[SUCCESS] Task without title.

Opening Cypress...
[2509:0210/022218.329213:ERROR:zygote_host_impl_linux.cc(273)] Failed to adjust OOM score of renderer with pid 2663: Permission denied (13)

DevTools listening on ws://127.0.0.1:37619/devtools/browser/b9d51b09-dfd7-4150-9c15-f4724633591f
[2509:0210/022218.339423:ERROR:object_proxy.cc(590)] Failed to call method: org.freedesktop.portal.Settings.Read: object_path= /org/freedesktop/portal/desktop: unknown error type: 
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.

tput: No value for $TERM and no -T specified
====================================================================================================
  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        13.6.4                                                                         │
  │ Browser:        Electron 114 (headless)                                                        │
  │ Node Version:   v20.9.0 (/usr/local/bin/node)                                                  │
  │ Specs:          4 found (app.cy.ts, auth/login.cy.ts, settings/design/_confirm-html-elements.c │
  │                 y.ts, settings/design/ui-scheme.cy.ts)                                         │
  │ Searched:       src/**/*.cy.{js,jsx,ts,tsx}                                                    │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  app.cy.ts                                                                       (1 of 4)
[2509:0210/022219.777337:ERROR:zygote_host_impl_linux.cc(273)] Failed to adjust OOM score of renderer with pid 2798: Permission denied (13)

Timed out waiting for the browser to connect. Retrying...
[2509:0210/022422.767520:ERROR:zygote_host_impl_linux.cc(273)] Failed to adjust OOM score of renderer with pid 2815: Permission denied (13)
Cannot read properties of null (reading 'getWebSocketDebuggerUrl')
TypeError: Cannot read properties of null (reading 'getWebSocketDebuggerUrl')
    at Object.open (<embedded>:4432:117536)
    at async Object.open (<embedded>:4438:27363)
    at async v.relaunchBrowser (<embedded>:4504:37915)

This does not happen when using Github runners. But it happens on the nx-agents runners.

kaceycleveland commented 4 months ago

I am running into the same issue as well; it becomes difficult to pinpoint why our agents are cancelling but this is the current suspect

FrozenPandaz commented 4 months ago

A fix for nx agents fixed the detection of cypress.

https://github.com/nrwl/nx-cloud-workflows/commit/ef8aeeffabcf8a5df4fa3bd4e9845649d0aefd00

Can you please open a separate issue for the OOM issues?

github-actions[bot] commented 3 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.