nrwl / nx

Smart Monorepos · Fast CI

Home Page:https://nx.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

core:runCommands: explicit `--parallel` argument doesn't override env variable `NX_PARALLEL`

Hotell opened this issue · comments

Current Behavior

inline CLI arguments won't override global env variables.

NX_PARALLEL=8 yarn nx run-many -t e2e --parallel=1

will result in running e2e target in parallel process ( which in case of cypress will fail )

there is a bug within implementation:

if (args['parallel'] === 'false' || args['parallel'] === false) {
nxArgs['parallel'] = 1;
} else if (
args['parallel'] === 'true' ||
args['parallel'] === true ||
args['parallel'] === '' ||
process.env.NX_PARALLEL // dont require passing --parallel if NX_PARALLEL is set
) {
nxArgs['parallel'] = Number(
nxArgs['maxParallel'] ||
nxArgs['max-parallel'] ||
process.env.NX_PARALLEL ||
3
);
} else if (args['parallel'] !== undefined) {
nxArgs['parallel'] = Number(args['parallel']);
}

Expected Behavior

CLI arguments should override ENV NX_ variables.

NOTE: haven't checked all source but I think it would be good to have this behaviour consistent for all ENV variables vs inline provided arguments

GitHub Repo

Steps to Reproduce

  1. clone the PR branch
  2. NX_PARALLEL=8 yarn nx run-many -t e2e --parallel=1

Nx Report

Node   : 20.15.0
OS     : darwin-arm64
yarn   : 1.23.34

nx                 : 19.3.2
@nx/js             : 19.3.2
@nx/jest           : 19.3.2
@nx/linter         : 19.3.2
@nx/eslint         : 19.3.2
@nx/workspace      : 19.3.2
@nx/devkit         : 19.3.2
@nx/eslint-plugin  : 19.3.2
@nx/node           : 19.3.2
@nx/plugin         : 19.3.2
@nrwl/tao          : 19.3.2
typescript         : 5.0.4
---------------------------------------
Local workspace plugins:
         @fluentui/workspace-plugin

Failure Logs

No response

Package Manager Version

yarn v1

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Hey Martin 👋

Looking in to this now, I think what you are saying makes sense. Shouldn't be a terribly hard changeset.

Thanks.