cleanup(core): remove NX_INVOKED_BY_RUNNER (#9693)

This commit is contained in:
Victor Savkin 2022-04-05 16:58:13 -04:00 committed by GitHub
parent 671fed8846
commit 48769dc4bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 19 deletions

View File

@ -211,6 +211,31 @@ nx connect-to-nx-cloud
You can also distribute the cache manually using your own storage mechanisms.
### Using Distributed Caching for Internal Commands
By default, Nx Cloud is not used for Nx commands invoked from within other Nx commands.
For example, in the following configuration build1 and build2 won't be cached individually.
```json
{
"executor": "@nrwl/workspace:run-commands",
"options": {
"commands": ["nx build1 proj", "nx build2 proj"]
}
}
```
If you would like them to be cached individually, and a separate run to be created for each of them, add the following:
```json
{
"executor": "@nrwl/workspace:run-commands",
"options": {
"commands": ["NX_CLOUD=true nx build1 proj", "NX_CLOUD=true nx build2 proj"]
}
}
```
## Example
- [This is an example repo](https://github.com/vsavkin/large-monorepo) benchmarking Nx's computation caching. It also explains why Nx's computation caching tends to be a lot faster than the caching of other build systems.

View File

@ -354,7 +354,6 @@ export function runCommandAsync(
env: {
...(opts.env || process.env),
FORCE_COLOR: 'false',
NX_INVOKED_BY_RUNNER: undefined,
},
encoding: 'utf-8',
},
@ -382,7 +381,6 @@ export function runCommandUntil(
env: {
...process.env,
FORCE_COLOR: 'false',
NX_INVOKED_BY_RUNNER: undefined,
},
encoding: 'utf-8',
});
@ -440,7 +438,7 @@ export function runNgAdd(
packageInstall(packageName, null, version);
return execSync(pmc.run(`ng g ${packageName}:ng-add`, command), {
cwd: tmpProjPath(),
env: { ...(opts.env || process.env), NX_INVOKED_BY_RUNNER: undefined },
env: { ...(opts.env || process.env) },
encoding: 'utf-8',
})
.toString()
@ -473,7 +471,7 @@ export function runCLI(
let r = stripConsoleColors(
execSync(`${pm.runNx} ${command}`, {
cwd: opts.cwd || tmpProjPath(),
env: { ...(opts.env || process.env), NX_INVOKED_BY_RUNNER: undefined },
env: { ...(opts.env || process.env) },
encoding: 'utf-8',
maxBuffer: 50 * 1024 * 1024,
})
@ -529,7 +527,6 @@ export function runCommand(
env: {
...process.env,
FORCE_COLOR: 'false',
NX_INVOKED_BY_RUNNER: undefined,
},
encoding: 'utf-8',
...options,

View File

@ -67,7 +67,7 @@
"@nrwl/linter": "13.10.0-beta.9",
"@nrwl/next": "13.10.0-beta.9",
"@nrwl/node": "13.10.0-beta.9",
"@nrwl/nx-cloud": "13.2.1",
"@nrwl/nx-cloud": "13.3.0-beta.0",
"@nrwl/react": "13.10.0-beta.9",
"@nrwl/web": "13.10.0-beta.9",
"@nrwl/workspace": "13.10.0-beta.9",

View File

@ -276,7 +276,6 @@ export class ForkedProcessTaskRunner {
) {
const env: NodeJS.ProcessEnv = {
FORCE_COLOR: forceColor,
NX_INVOKED_BY_RUNNER: 'true',
NX_WORKSPACE_ROOT: this.workspaceRoot,
NX_SKIP_NX_CACHE: this.options.skipNxCache ? 'true' : undefined,
};

View File

@ -27,9 +27,6 @@ export class StaticRunOneTerminalOutputLifeCycle implements LifeCycle {
) {}
startCommand(): void {
if (process.env.NX_INVOKED_BY_RUNNER) {
return;
}
const numberOfDeps = this.tasks.length - 1;
if (numberOfDeps > 0) {
@ -46,10 +43,6 @@ export class StaticRunOneTerminalOutputLifeCycle implements LifeCycle {
}
endCommand(): void {
// Silent for a single task
if (process.env.NX_INVOKED_BY_RUNNER) {
return;
}
output.addNewline();
if (this.failedTasks.length === 0) {

View File

@ -133,7 +133,7 @@ function build(nxVersion: string) {
`npx nx run-many --target=build --all --parallel=8 --exclude=${projectsToExclude}`,
{
stdio: ['pipe', 'pipe', 'pipe'],
env: { ...process.env, NX_INVOKED_BY_RUNNER: 'false' },
env: { ...process.env, NX_CLOUD: 'true' },
}
);
const a = new Date();

View File

@ -2837,12 +2837,13 @@
webpack-merge "^5.8.0"
webpack-node-externals "^3.0.0"
"@nrwl/nx-cloud@13.2.1":
version "13.2.1"
resolved "https://registry.yarnpkg.com/@nrwl/nx-cloud/-/nx-cloud-13.2.1.tgz#14388d7122761e09bacc1da4ee8b26adb24309b0"
integrity sha512-fiZg0Y6U1amfOnv29wp3gBKc6eqNcEFj6iAlTBFF6ZW+JylH1aVzMHGiBdNLGX2y4aMVPILIfz61LY0Hphi0Gg==
"@nrwl/nx-cloud@13.3.0-beta.0":
version "13.3.0-beta.0"
resolved "https://registry.yarnpkg.com/@nrwl/nx-cloud/-/nx-cloud-13.3.0-beta.0.tgz#2d4a6cf5c35dd0ce5dcc4457735e87a371436afe"
integrity sha512-y2k06YbVc0vd7PszI8km3cRDTR8GWGVKtOgNfi/yg588234q+ugHwW2R2BDV7auAQqSmNZegraCZBloS70QKvA==
dependencies:
axios "^0.21.1"
chalk "4.1.0"
node-machine-id "^1.1.12"
strip-json-comments "^3.1.1"
tar "6.1.11"