nrwl / nx

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

multiple issues with a brand new nest with angular project #22144

Closed robertIsaac closed 3 weeks ago

robertIsaac commented 8 months ago

Current Behavior

right now when I create a new project using angular then add nest to do there are multiple problems

  1. the GitHub action fail by default with error fatal: ambiguous argument 'origin/main': unknown revision or path not in the working tree. that's because the branch that nx created is master but the default branch in nrwl/nx-set-shas jon is main
  2. I choose to playwright as my e2e it fails by default with error Executable doesn't exist at /home/runner/.cache/ms-playwright/chromium-1105/chrome-linux/chrome
  3. the nest e2e doesn't work out of the box in the CI because it needs the API to be served first, I wasn't sure how to actually make it work so I just deleted it πŸ˜…
  4. running nx run-many -t serve doesn't work, only the first one actually is served and it's random sometimes it's Angular and some other it's nest

Expected Behavior

  1. create the default branch main or add main-branch-name for master in the .github/workflows/ci.yml file like what I did here https://github.com/robertIsaac/ng-nest-reprod/commit/527b40111c7ae18eb28857cc9abf91dc3e5ab4f5
  2. when choosing playwright as e2e, nx should by default add postinstall script npx playwright install --with-deps as I did in https://github.com/robertIsaac/ng-nest-reprod/commit/a8b02076652ab2e6717f6d189bd9785b5d79126e or to add it as an extra step in the ci.yaml file
  3. it should work out of the box
  4. it should work for both angular and nest, this actually used to work in 17.x version, seems to be broken in 18.0 version

GitHub Repo

https://github.com/robertIsaac/ng-nest-reprod

Steps to Reproduce

1.create a new project npx create-nx-workspace ng-nest-reprod then follow these steps

 NX   Let's create a new workspace [https://nx.dev/getting-started/intro]

√ Which stack do you want to use? · angular
√ Integrated monorepo, or standalone project? · integrated
√ Application name · fe
√ Which bundler would you like to use? · esbuild
√ Default stylesheet format · scss
√ Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? · Yes
√ Test runner to use for end to end (E2E) tests · playwright
√ Do you want Nx Cloud to make your CI fast? · github
  1. run nx add @nx/nest
  2. run nx g @nx/nest:app be --frontendProject fe

Nx Report

Node   : 20.11.0
OS     : win32-x64
npm    : 10.4.0

nx                 : 18.0.7
@nx/js             : 18.0.7
@nx/jest           : 18.0.7
@nx/linter         : 18.0.7
@nx/eslint         : 18.0.7
@nx/workspace      : 18.0.7
@nx/angular        : 18.0.7
@nx/cypress        : 18.0.7
@nx/devkit         : 18.0.7
@nx/eslint-plugin  : 18.0.7
@nx/nest           : 18.0.7
@nx/node           : 18.0.7
@nx/playwright     : 18.0.7
@nrwl/tao          : 18.0.7
@nx/web            : 18.0.7
@nx/webpack        : 18.0.7
typescript         : 5.3.3

Failure Logs

nx s be

> nx run be:serve:development

Build option outputFileName not set for be. Using fallback value of dist\apps\be\main.js.

> nx run be:build

chunk (runtime: main) main.js (main) 2.71 KiB [entry] [rendered]
webpack compiled successfully (f60f6de829567d37)

β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” 

 NX   Successfully ran target build for project be (3s)

Debugger listening on ws://localhost:9229/45b5e4be-970d-449c-ae66-4be0dfa0cf52
Debugger listening on ws://localhost:9229/45b5e4be-970d-449c-ae66-4be0dfa0cf52
For help, see: https://nodejs.org/en/docs/inspector

[Nest] 28260  - 03/04/2024, 11:43:34 PM     LOG [NestFactory] Starting Nest application...
[Nest] 28260  - 03/04/2024, 11:43:34 PM     LOG [InstanceLoader] AppModule dependencies initialized +5ms
[Nest] 28260  - 03/04/2024, 11:43:34 PM     LOG [RoutesResolver] AppController {/api}: +12ms
[Nest] 28260  - 03/04/2024, 11:43:34 PM     LOG [RouterExplorer] Mapped {/api, GET} route +1ms
[Nest] 28260  - 03/04/2024, 11:43:34 PM     LOG [NestApplication] Nest application successfully started +1ms
[Nest] 28260  - 03/04/2024, 11:43:34 PM     LOG πŸš€ Application is running on: http://localhost:3000/api

Package Manager Version

No response

Operating System

Additional Information

these are 4 different issues related to multiple issues, if you want me to create separate issues for each or for one of them just tell me and I will do I'm also open to contribute to fix these issues, just let's agree how they should work and point me to where to go to fix them because I get lost easily in the repo

exocom commented 8 months ago

@AgentEnder We have an empty node + NestJS and experienced number 3 above as well.

The reason for the failure is because the @nx/jest/plugin is creating a VIRTUAL test target on the e2e project.

2 possible solutions:

  1. Instead of 2 projects merge them into one with an e2e folder. (We've seen this in the wild.)
  2. Do not add the virtual task the e2e projects.

nx.json

    {
      "plugin": "@nx/jest/plugin",
      "options": {
        "targetName": "test"
      }
    }

Here is the output:

❌ > nx run gateway-e2e:test

  Setting up...

   FAIL   gateway-e2e  src/gateway/gateway.spec.ts
    GET /api
      βœ• should return a message (39 ms)

    ● GET /api β€Ί should return a message

      AggregateError

        at Function.Object.<anonymous>.AxiosError.from (../../node_modules/.pnpm/axios@1.6.7/node_modules/axios/lib/core/AxiosError.js:89:14)
        at RedirectableRequest.handleRequestError (../../node_modules/.pnpm/axios@1.6.7/node_modules/axios/lib/adapters/http.js:610:25)
        at ClientRequest.eventHandlers.<computed> (../../node_modules/.pnpm/follow-redirects@1.15.5/node_modules/follow-redirects/index.js:38:24)
        at Axios.request (../../node_modules/.pnpm/axios@1.6.7/node_modules/axios/lib/core/Axios.js:45:[41](https://github.com/safe-health/platform/actions/runs/8180154723/job/22367616715#step:8:46))

      Cause:
      AggregateError
github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it hasn't had any activity for 6 months. Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore. If at this point, this is still an issue, please respond with updated information. It will be closed in 21 days if no further activity occurs. Thanks for being a part of the Nx community! πŸ™