Skip to content

Commit 9661135

Browse files
leosvelperezFrozenPandaz
authored andcommitted
fix(core): do not run sync generators when running tasks in ci (#30591)
## Current Behavior When running tasks, Nx will run and check the sync generators associated with the task graph. While locally this is desirable to ensure the code is always up to date while making changes, in CI, we don't make changes that need to be synced or checked for every task. This is suboptimal, and it results in duplicate processing. ## Expected Behavior Sync generators should not run when running tasks in CI. To validate the sync status, it is recommended to have a dedicated early step in the CI pipeline that runs `nx sync:check` once. ## Related Issue(s) Fixes # (cherry picked from commit 220023d)
1 parent 80d3ede commit 9661135

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

packages/nx/src/tasks-runner/run-command.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(
299299
extraOptions
300300
);
301301

302-
if (nxArgs.skipSync) {
302+
if (nxArgs.skipSync || isCI()) {
303303
return { projectGraph, taskGraph };
304304
}
305305

@@ -333,10 +333,9 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(
333333
const resultBodyLines = getSyncGeneratorSuccessResultsMessageLines(results);
334334
const fixMessage =
335335
'Make sure to run `nx sync` to apply the identified changes or set `sync.applyChanges` to `true` in your `nx.json` to apply them automatically when running tasks in interactive environments.';
336-
const willErrorOnCiMessage = 'This will result in an error in CI.';
337336

338-
if (isCI() || !process.stdout.isTTY) {
339-
// If the user is running in CI or is running in a non-TTY environment we
337+
if (!process.stdout.isTTY) {
338+
// If the user is running a non-TTY environment we
340339
// throw an error to stop the execution of the tasks.
341340
if (areAllResultsFailures) {
342341
output.error({
@@ -394,7 +393,6 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(
394393
...resultBodyLines,
395394
'',
396395
'Your workspace is set to not apply the identified changes automatically (`sync.applyChanges` is set to `false` in your `nx.json`).',
397-
willErrorOnCiMessage,
398396
fixMessage,
399397
],
400398
});
@@ -418,10 +416,12 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(
418416
title: outOfSyncTitle,
419417
bodyLines: [
420418
...resultBodyLines,
421-
'',
422-
nxJson.sync?.applyChanges === true
423-
? 'Proceeding to sync the identified changes automatically (`sync.applyChanges` is set to `true` in your `nx.json`).'
424-
: willErrorOnCiMessage,
419+
...(nxJson.sync?.applyChanges === true
420+
? [
421+
'',
422+
'Proceeding to sync the identified changes automatically (`sync.applyChanges` is set to `true` in your `nx.json`).',
423+
]
424+
: []),
425425
],
426426
});
427427

0 commit comments

Comments
 (0)