nrwl / nx

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

Playwright e2e-ci--* targets do not depend on "^build" #23035

Closed matthewrj closed 3 months ago

matthewrj commented 6 months ago

Current Behavior

Running nx run-many -t build e2e-ci causes a race-condition as e2e-ci does not depend on build on the project it is testing in nx even though the outputs from build are used by the e2e-ci--* tasks. Additionally, running nx run e2e-ci does not trigger a build and so will fail if you haven't previously run nx run build.

Expected Behavior

nx runs a dependency project's build target to run before running the e2e-ci--* tasks.

GitHub Repo

No response

Steps to Reproduce

  1. Create a new nx project with Next.js, Playwright and Github actions using npx create-nx-workspace --pm yarn
  2. Push to Github
  3. yarn nx affected -t lint test build e2e-ci will fail with strange errors

Nx Report

Node   : 20.12.2
OS     : darwin-arm64
yarn   : 1.22.21

nx (global)        : 18.3.3
nx                 : 18.3.4
@nx/js             : 18.3.4
@nx/jest           : 18.3.4
@nx/linter         : 18.3.4
@nx/eslint         : 18.3.4
@nx/workspace      : 18.3.4
@nx/devkit         : 18.3.4
@nx/eslint-plugin  : 18.3.4
@nx/next           : 18.3.4
@nx/playwright     : 18.3.4
@nx/react          : 18.3.4
@nrwl/tao          : 18.3.4
@nx/web            : 18.3.4
@nx/webpack        : 18.3.4
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/next/plugin
@nx/playwright/plugin
@nx/eslint/plugin
@nx/jest/plugin
---------------------------------------
Community plugins:
@simondotm/nx-firebase : 2.3.0

Failure Logs

> Build error occurred
  [Error: ENOENT: no such file or directory, rename '/home/runner/work/engineering/engineering/apps/integral-marketing/.next/export/500.html' -> '/home/runner/work/engineering/engineering/apps/integral-marketing/.next/server/pages/500.html'] {
    errno: -2,
    code: 'ENOENT',
    syscall: 'rename',
    path: '/home/runner/work/engineering/engineering/apps/integral-marketing/.next/export/500.html',
    dest: '/home/runner/work/engineering/engineering/apps/integral-marketing/.next/server/pages/500.html'
  }

  > playwright test src/example.spec.ts

  Error: Timed out waiting 60000ms from config.webServer.

Package Manager Version

No response

Operating System

Additional Information

Is the same issue as https://github.com/nrwl/nx/issues/22787. The solution proposed here is to split up the commands in the Github action, however I don't think this is the right solution as you're pushing the task dependency management up to Github actions instead of keeping it in nx.

aramfe commented 6 months ago

Is there any workaround to get all the depenended packages for each DTE agents? Can't use yarn nx e2e-ci without loosing the benefits of DTE, if I need to explicitly build each package from ^build...

MaxKless commented 3 months ago

Hey! I get the frustration. On the latest nx 19.5, you can simply define a targetDefault with a glob in nx.json to specify that all e2e-ci-* targets should depend on ^build like this:


"targetDefaults" : {
  "e2e-ci--**/*": {
    "dependsOn": ["^build"]
  }
}

If you cannot upgrade for some reason, you can specify the dependency manually for every single atomized e2e-ci--* target.
github-actions[bot] commented 2 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.