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

Regression - Cypress executor does not respect env cli parameters. #10808

Closed
danr-za opened this issue Jun 19, 2022 · 30 comments · Fixed by #12499
Closed

Regression - Cypress executor does not respect env cli parameters. #10808

danr-za opened this issue Jun 19, 2022 · 30 comments · Fixed by #12499
Assignees
Labels
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug

Comments

@danr-za
Copy link
Contributor

danr-za commented Jun 19, 2022

Current Behavior

Regression of #9764.
I upgraded from 14.2.4 where it worked.

Expected Behavior

Steps to Reproduce

This issue may not be prioritized if details are not provided to help us reproduce the issue.

Failure Logs

Environment

   Node : 16.13.0
   OS   : darwin x64
   yarn : 3.2.1
   
   nx : 14.3.6
   @nrwl/angular : Not Found
   @nrwl/cypress : 14.3.6
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.3.6
   @nrwl/eslint-plugin-nx : 14.3.6
   @nrwl/express : Not Found
   @nrwl/jest : 14.3.6
   @nrwl/js : 14.3.6
   @nrwl/linter : 14.3.6
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : 14.3.6
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 14.3.6
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.3.6
   @nrwl/web : 14.3.6
   @nrwl/workspace : 14.3.6
   typescript : 4.7.4
   ---------------------------------------
   Community plugins:
         nx-stylelint: 13.4.0
@AgentEnder AgentEnder added the scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx label Jun 21, 2022
@barbados-clemens
Copy link
Contributor

@danr-za I just tried this locally and it works correctly.
the only issue is the args nx shows is showing [object Object] vs the actual argument but the args are sent to cypress correctly.

WkMacM1-ZCjfRdC8_06231513.mp4

@danr-za
Copy link
Contributor Author

danr-za commented Jun 27, 2022

@barbados-clemens so this is what I see:

  • Our CI command currently looks like this:
yarn app:e2e:production --browser=chrome --baseUrl=<URL> --env.NX_API_URL=<API URL> 
--record -- --parallel --ci-build-id=<build> --key=<key>

When running that, I get:

 NX   Nx didn't recognize the following args: browser, baseUrl, env, record

   When using '--' all executor args have to be defined after '--'.

The reason we append it is because of #8014

Moving it to the beginning results in:

yarn app:e2e:production -- --browser=chrome --baseUrl=<URL> --env.NX_API_URL=<API URL>
 --record --parallel --ci-build-id=<build> --key=<key>

Here, for some reason, the NX_API_URL is not set and is using the default one from the cypress.env.json file.

I will try running without the additional dashes and update.

@danr-za
Copy link
Contributor Author

danr-za commented Jun 27, 2022

Running this:

nx run management-e2e:e2e:production --browser=chrome --baseUrl=http://10.11.103.227/ --env.NX_API_URL=http://10.1.2.3 --record=true --ci-build-id=1234 --key=12345578

Results with:

You passed the --ci-build-id flag but did not provide either a --group or --parallel flag.

So there's an issue anyway.

@danr-za
Copy link
Contributor Author

danr-za commented Jul 5, 2022

@barbados-clemens any news about this? thanks

@barbados-clemens
Copy link
Contributor

that error doesn't look like it's related to the issue you initially raised. I've yet to be able to reproduce this locally as I demoed in the above comments.

You passed the --ci-build-id flag but did not provide either a --group or --parallel flag.

I'm not seeing your command pass either flag.

@danr-za
Copy link
Contributor Author

danr-za commented Jul 8, 2022

correction - the command I posted was after I ran the following:

nx run management-e2e:e2e:production --browser=chrome --baseUrl=http://10.11.103.227/ --env.NX_API_URL=http://10.1.2.3 --parallel --record=true --ci-build-id=1234 --key=12345578

parallel flag was omitted.

  • The error happens on a linux that is running from Jenkins CI. On my personal Mac that indeed does not reproduce.

@rodrigomata
Copy link

I've run randomly into this issue too within Github Actions, seems that additional flags are randomly being ignored. I've also tried removing parallel without success. This began happening suddenly, so it seems to be a regression on NX

@danr-za
Copy link
Contributor Author

danr-za commented Jul 16, 2022

Any news about this? If there's anything else I can check or do lmk

@danr-za
Copy link
Contributor Author

danr-za commented Jul 23, 2022

@barbados-clemens - it's still labeled as waiting for repro, is there something else you want me to provide?

@barbados-clemens
Copy link
Contributor

Hey all, so just a status update. this is next on my list of things to look more into after #10857 which should be soon as I found the root cause of my last issue.

but last time looking at myself and @FrozenPandaz were not able to reproduce this locally. so any extra info you can give about the environment and versions would be helpful. also, double checking with the latest nx version with cypress 10 support would also be helpful. nx v14.5.1

@danr-za
Copy link
Contributor Author

danr-za commented Aug 2, 2022

Unfortunately, I already tried with the latest version and Cypress 10, but it seems that it has something to do with the CLI args not passing.
Specifically, I guess parallel flag is omitted because Nx uses it for the runners.

This breaks in:

  • Github actions
  • Jenkins

But as I previously mentioned, locally on my M1 Mac it seems to be working (even though I couldn't fully check that as I don't have the access to the env I need)

@barbados-clemens
Copy link
Contributor

you should be able to set that option via the project executor options, you can make a ci configuration so you can do
nx run e2e my-app-e2e --configuration=ci or nx affected --target=e2e --configuration=ci

though I just saw an issue with env options via the project config aren't being properly passed in #10392 so will have to figure that

@ureciocais
Copy link

Hey all, so just a status update. this is next on my list of things to look more into after #10857 which should be soon as I found the root cause of my last issue.

but last time looking at myself and @FrozenPandaz were not able to reproduce this locally. so any extra info you can give about the environment and versions would be helpful. also, double checking with the latest nx version with cypress 10 support would also be helpful. nx v14.5.1

I'm also not only able to reproduce it on my Mac, but I can on Github actions using NX Cloud and distributed execution. If you need any extra info, let me know (I'm currently passing 3 --env args)

@meeroslav
Copy link
Contributor

We managed to reproduce it also for one client. Again, locally (Mac, Windows) works fine, but fails on CI (Azure with hosted Ubuntu).

Not sure how we can test/debug this. Any ideas @barbados-clemens?

@barbados-clemens
Copy link
Contributor

barbados-clemens commented Aug 12, 2022

So I just set this up in a GitHub action on Ubuntu latest and it worked

https://github.com/barbados-clemens/testing-validation-bench/runs/7811470886?check_suite_focus=true

Gonna keep looking into this but might be more going on than just OS?

barbados-clemens added a commit to barbados-clemens/nx that referenced this issue Aug 12, 2022
cypress env arg parsing has had multiple regressions
this change asserts the usage of commandline,
cypress.env.json file, and executor options will work properly

ISSUES CLOSED: nrwl#10808
@barbados-clemens
Copy link
Contributor

Status update. this looks to be related to DTE?
I enabled DTE on my test repo, and finally got the error @meeroslav ran into
> NX Property 'env' does not match the schema. '[object' should be a 'object'.

see cloud run: https://nx.app/runs/8nkrV8kxzNP

@ureciocais mentioned they have DTE on as well.

@danr-za and @rodrigomata are any of y'all using nx cloud + DTE with this error?

barbados-clemens added a commit to barbados-clemens/nx that referenced this issue Aug 12, 2022
cypress env arg parsing has had multiple regressions
this change asserts the usage of commandline,
cypress.env.json file, and executor options will work properly

ISSUES CLOSED: nrwl#10808
@danr-za
Copy link
Contributor Author

danr-za commented Aug 13, 2022

Hmm not us

@barbados-clemens
Copy link
Contributor

@danr-za are you getting any errors or just env vars being undefined with the usage of Cypress.env('my-var)?

@danr-za
Copy link
Contributor Author

danr-za commented Aug 15, 2022

An update on my side:
I have moved parallel and record to a ci configuration as you suggested (which should have been done from the beginning as they have constant values) and everything seems to work now, also the env variables passed into Cypress.
I assume that they are only logged this way --env=[object Object] but actually are passed correctly.

@barbados-clemens
Copy link
Contributor

@danr-za that's very interesting. presumably that should have just worked anyways, and also the fact it's influencing the --env params is also interesting. I'll investigate some on my side to see what I find, thanks for more info.

I assume that they are only logged this way --env=[object Object] but actually are passed correctly.

Correct, they will be still be passed to the executors as expected, unless you use DTE, where they are currently getting mangled, but presumably this recent change made will fix that.

I also have a PR up to document usage patterns with env that adds using --env.<value> to the cypress e2e tests so we can prevent any other regressions.

@acomben-cais
Copy link

The recent change doesn't appear to fix the issue

@ureciocais
Copy link

@barbados-clemens, I've tried with the latest version, but still arguments aren't passed in when using DTE

@barbados-clemens
Copy link
Contributor

@acomben-cais @ureciocais what are the exact values you are passing through the command line?

@ureciocais
Copy link

@barbados-clemens we are doing something like this:
yarn nx affected:e2e --base=remotes/origin/main --head=HEAD --parallel=1 --browser=chrome --env.E2E_USERNAME=${{ secrets.E2E_USERNAME }} --env.E2E_PASSWORD=${{ secrets.E2E_PASSWORD }} --env.E2E_AUTHO_CLIENT_SECRET=${{ secrets.E2E_AUTHO_CLIENT_SECRET }}

@barbados-clemens
Copy link
Contributor

@ureciocais can you run nx report and post the info here?

@github-actions
Copy link

github-actions bot commented Sep 8, 2022

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@barbados-clemens
Copy link
Contributor

Oops, not stale. sorry about that.

lukasalphta pushed a commit to lukasalphta/nx that referenced this issue Oct 10, 2022
Avoid outputting object args as [object Object].

Is related to nrwl#10808
@lukasalphta
Copy link
Contributor

I am facing the same issue with [object' should be a 'object'. when run in CI with DTE.
In my case I am passing --env.grepTags="tag1 tag2" to the nx.

11564 did not get rid completely of [object Object] in terminal output so I created another PR which might fix the problem. Would appreciate if it can be reviewed soon.

lukasalphta pushed a commit to lukasalphta/nx that referenced this issue Oct 14, 2022
Avoid outputting object args as [object Object].

Is related to nrwl#10808
@lukasalphta
Copy link
Contributor

@barbados-clemens @meeroslav In my PR I adjusted also the way how the section "With additional flags" will print the arguments as I think they should be printed in unparsed way mirroring the actual input.

So this way:

         With additional flags:
           --env.cliArg="i am from the cli args"

rather than

         With additional flags:
           --env={"cliArg": "i am from the cli args"} 

Maybe somebody of you will be willing to have a look at this?

FrozenPandaz pushed a commit to lukasalphta/nx that referenced this issue Oct 27, 2022
Avoid outputting object args as [object Object].

Is related to nrwl#10808
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug
Projects
None yet
8 participants