From 8cda56ed36c0e150042a668b1b390181230bcc96 Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 13 May 2024 17:50:30 +0400 Subject: [PATCH] fix(nx-cloud): ensure generated ci workflows use dlx for nx-cloud (#23333) --- .eslintrc.base.json | 35 ------------------- nx-dev/ui-blog/.eslintrc.json | 2 +- .../__snapshots__/ci-workflow.spec.ts.snap | 14 ++++---- .../src/generators/ci-workflow/ci-workflow.ts | 9 +++-- .../files/azure/azure-pipelines.yml__tmpl__ | 2 +- .../bitbucket-pipelines.yml__tmpl__ | 4 +-- .../circleci/.circleci/config.yml__tmpl__ | 2 +- .../__workflowFileName__.yml__tmpl__ | 2 +- .../files/gitlab/.gitlab-ci.yml__tmpl__ | 2 +- 9 files changed, 21 insertions(+), 51 deletions(-) delete mode 100644 .eslintrc.base.json diff --git a/.eslintrc.base.json b/.eslintrc.base.json deleted file mode 100644 index 9ca2e830cbddf..0000000000000 --- a/.eslintrc.base.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "root": true, - "ignorePatterns": ["**/*"], - "plugins": ["@nx"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": { - "@nx/enforce-module-boundaries": [ - "error", - { - "enforceBuildableLibDependency": true, - "allow": [], - "depConstraints": [ - { - "sourceTag": "*", - "onlyDependOnLibsWithTags": ["*"] - } - ] - } - ] - } - }, - { - "files": ["*.ts", "*.tsx"], - "extends": ["plugin:@nx/typescript"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "extends": ["plugin:@nx/javascript"], - "rules": {} - } - ] -} diff --git a/nx-dev/ui-blog/.eslintrc.json b/nx-dev/ui-blog/.eslintrc.json index 8d4e2111db39b..9d9c0db55bb1e 100644 --- a/nx-dev/ui-blog/.eslintrc.json +++ b/nx-dev/ui-blog/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": ["../../.eslintrc.base.json"], + "extends": ["../../.eslintrc.json"], "ignorePatterns": ["!**/*"], "overrides": [ { diff --git a/packages/workspace/src/generators/ci-workflow/__snapshots__/ci-workflow.spec.ts.snap b/packages/workspace/src/generators/ci-workflow/__snapshots__/ci-workflow.spec.ts.snap index c78cc7cd472e0..af00d5f5de5c2 100644 --- a/packages/workspace/src/generators/ci-workflow/__snapshots__/ci-workflow.spec.ts.snap +++ b/packages/workspace/src/generators/ci-workflow/__snapshots__/ci-workflow.spec.ts.snap @@ -502,7 +502,7 @@ jobs: # Connect your workspace on nx.app and uncomment this to enable task distribution. # The "--stop-agents-after" is optional, but allows idle agents to shut down once the "build" targets have been requested - # - script: pnpm exec nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" + # - script: pnpm dlx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" - script: pnpm install --frozen-lockfile - script: git branch --track main origin/main @@ -532,7 +532,7 @@ pipelines: # Connect your workspace on nx.app and uncomment this to enable task distribution. # The "--stop-agents-after" is optional, but allows idle agents to shut down once the "build" targets have been requested - # - pnpm exec nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" + # - pnpm dlx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" - pnpm install --frozen-lockfile @@ -547,7 +547,7 @@ pipelines: - export NX_BRANCH=$BITBUCKET_BRANCH # Connect your workspace on nx.app and uncomment this to enable task distribution. # The "--stop-agents-after" is optional, but allows idle agents to shut down once the "build" targets have been requested - # - pnpm exec nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" + # - pnpm dlx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" - npm install --prefix=$HOME/.local -g pnpm@8 @@ -578,7 +578,7 @@ jobs: # Connect your workspace on nx.app and uncomment this to enable task distribution. # The "--stop-agents-after" is optional, but allows idle agents to shut down once the "build" targets have been requested - # - run: pnpm exec nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" + # - run: pnpm dlx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" - run: pnpm install --frozen-lockfile - nx/set-shas: @@ -624,7 +624,7 @@ jobs: # Connect your workspace on nx.app and uncomment this to enable task distribution. # The "--stop-agents-after" is optional, but allows idle agents to shut down once the "build" targets have been requested - # - run: pnpm exec nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" + # - run: pnpm dlx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" # Cache node_modules - uses: actions/setup-node@v3 @@ -667,7 +667,7 @@ jobs: # Connect your workspace on nx.app and uncomment this to enable task distribution. # The "--stop-agents-after" is optional, but allows idle agents to shut down once the "build" targets have been requested - # - run: pnpm exec nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" + # - run: pnpm dlx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" # Cache node_modules - uses: actions/setup-node@v3 @@ -699,7 +699,7 @@ CI: # Connect your workspace on nx.app and uncomment this to enable task distribution. # The "--stop-agents-after" is optional, but allows idle agents to shut down once the "build" targets have been requested - # - pnpm exec nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" + # - pnpm dlx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" - pnpm install --frozen-lockfile - NX_HEAD=$CI_COMMIT_SHA diff --git a/packages/workspace/src/generators/ci-workflow/ci-workflow.ts b/packages/workspace/src/generators/ci-workflow/ci-workflow.ts index d1e021420ff52..b8a1fb59abb63 100644 --- a/packages/workspace/src/generators/ci-workflow/ci-workflow.ts +++ b/packages/workspace/src/generators/ci-workflow/ci-workflow.ts @@ -38,6 +38,7 @@ interface Substitutes { packageManager: string; packageManagerInstall: string; packageManagerPrefix: string; + packageManagerPreInstallPrefix: string; nxCloudHost: string; hasE2E: boolean; tmpl: ''; @@ -48,8 +49,11 @@ function normalizeOptions(options: Schema, tree: Tree): Substitutes { options.name ); const packageManager = detectPackageManager(); - const { exec: packageManagerPrefix, ciInstall: packageManagerInstall } = - getPackageManagerCommand(packageManager); + const { + exec: packageManagerPrefix, + ciInstall: packageManagerInstall, + dlx: packageManagerPreInstallPrefix, + } = getPackageManagerCommand(packageManager); let nxCloudHost: string = 'nx.app'; try { @@ -72,6 +76,7 @@ function normalizeOptions(options: Schema, tree: Tree): Substitutes { packageManager, packageManagerInstall, packageManagerPrefix, + packageManagerPreInstallPrefix, mainBranch: deduceDefaultBase(), hasE2E, nxCloudHost, diff --git a/packages/workspace/src/generators/ci-workflow/files/azure/azure-pipelines.yml__tmpl__ b/packages/workspace/src/generators/ci-workflow/files/azure/azure-pipelines.yml__tmpl__ index 9f41119d0641f..6fc0575516b5f 100644 --- a/packages/workspace/src/generators/ci-workflow/files/azure/azure-pipelines.yml__tmpl__ +++ b/packages/workspace/src/generators/ci-workflow/files/azure/azure-pipelines.yml__tmpl__ @@ -48,7 +48,7 @@ jobs: <% } %> # Connect your workspace on <%= nxCloudHost %> and uncomment this to enable task distribution. # The "--stop-agents-after" is optional, but allows idle agents to shut down once the "<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" targets have been requested - # - script: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" + # - script: <%= packageManagerPreInstallPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" - script: <%= packageManagerInstall %> - script: git branch --track <%= mainBranch %> origin/<%= mainBranch %> diff --git a/packages/workspace/src/generators/ci-workflow/files/bitbucket-pipelines/bitbucket-pipelines.yml__tmpl__ b/packages/workspace/src/generators/ci-workflow/files/bitbucket-pipelines/bitbucket-pipelines.yml__tmpl__ index fb7862127882e..daa1690e19934 100644 --- a/packages/workspace/src/generators/ci-workflow/files/bitbucket-pipelines/bitbucket-pipelines.yml__tmpl__ +++ b/packages/workspace/src/generators/ci-workflow/files/bitbucket-pipelines/bitbucket-pipelines.yml__tmpl__ @@ -17,7 +17,7 @@ pipelines: <% } %> # Connect your workspace on <%= nxCloudHost %> and uncomment this to enable task distribution. # The "--stop-agents-after" is optional, but allows idle agents to shut down once the "<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" targets have been requested - # - <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" + # - <%= packageManagerPreInstallPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" - <%= packageManagerInstall %> @@ -33,7 +33,7 @@ pipelines: - export NX_BRANCH=$BITBUCKET_BRANCH # Connect your workspace on <%= nxCloudHost %> and uncomment this to enable task distribution. # The "--stop-agents-after" is optional, but allows idle agents to shut down once the "<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" targets have been requested - # - <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" + # - <%= packageManagerPreInstallPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" <% if(packageManager == 'pnpm'){ %> - npm install --prefix=$HOME/.local -g pnpm@8 diff --git a/packages/workspace/src/generators/ci-workflow/files/circleci/.circleci/config.yml__tmpl__ b/packages/workspace/src/generators/ci-workflow/files/circleci/.circleci/config.yml__tmpl__ index a68fefd724b0a..84f5cba7961da 100644 --- a/packages/workspace/src/generators/ci-workflow/files/circleci/.circleci/config.yml__tmpl__ +++ b/packages/workspace/src/generators/ci-workflow/files/circleci/.circleci/config.yml__tmpl__ @@ -17,7 +17,7 @@ jobs: # Connect your workspace on <%= nxCloudHost %> and uncomment this to enable task distribution. # The "--stop-agents-after" is optional, but allows idle agents to shut down once the "<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" targets have been requested - # - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" + # - run: <%= packageManagerPreInstallPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" - run: <%= packageManagerInstall %> - nx/set-shas: diff --git a/packages/workspace/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml__tmpl__ b/packages/workspace/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml__tmpl__ index 28484062e46a3..36eeb588f503f 100644 --- a/packages/workspace/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml__tmpl__ +++ b/packages/workspace/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml__tmpl__ @@ -25,7 +25,7 @@ jobs: # Connect your workspace on <%= nxCloudHost %> and uncomment this to enable task distribution. # The "--stop-agents-after" is optional, but allows idle agents to shut down once the "<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" targets have been requested - # - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" + # - run: <%= packageManagerPreInstallPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" # Cache node_modules - uses: actions/setup-node@v3 diff --git a/packages/workspace/src/generators/ci-workflow/files/gitlab/.gitlab-ci.yml__tmpl__ b/packages/workspace/src/generators/ci-workflow/files/gitlab/.gitlab-ci.yml__tmpl__ index 21d17d309e043..fa6edae8017ea 100644 --- a/packages/workspace/src/generators/ci-workflow/files/gitlab/.gitlab-ci.yml__tmpl__ +++ b/packages/workspace/src/generators/ci-workflow/files/gitlab/.gitlab-ci.yml__tmpl__ @@ -14,7 +14,7 @@ variables: <% } %> # Connect your workspace on <%= nxCloudHost %> and uncomment this to enable task distribution. # The "--stop-agents-after" is optional, but allows idle agents to shut down once the "<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" targets have been requested - # - <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" + # - <%= packageManagerPreInstallPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="<% if(hasE2E){ %>e2e-ci<% } else { %>build<% } %>" - <%= packageManagerInstall %> - NX_HEAD=$CI_COMMIT_SHA