From ab47f773c0465946a3751d3de8015bdaef132526 Mon Sep 17 00:00:00 2001 From: Miroslav Jonas Date: Thu, 2 May 2024 11:24:51 +0200 Subject: [PATCH] fix(core): remove obsolete git track from ci generators --- docs/shared/monorepo-ci-github-actions.md | 6 +-- .../__snapshots__/ci-workflow.spec.ts.snap | 40 ------------------- .../files/azure/azure-pipelines.yml__tmpl__ | 2 +- .../circleci/.circleci/config.yml__tmpl__ | 4 -- .../__workflowFileName__.yml__tmpl__ | 3 -- 5 files changed, 2 insertions(+), 53 deletions(-) diff --git a/docs/shared/monorepo-ci-github-actions.md b/docs/shared/monorepo-ci-github-actions.md index 129272e1a2292..36483191dc1d6 100644 --- a/docs/shared/monorepo-ci-github-actions.md +++ b/docs/shared/monorepo-ci-github-actions.md @@ -32,11 +32,7 @@ jobs: # - run: npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci" - run: npm ci - - uses: nrwl/nx-set-shas@v3 - - # This line is needed for nx affected to work when CI is running on a PR - - run: git branch --track main origin/main - if: ${{ github.event_name == 'pull_request' }} + - uses: nrwl/nx-set-shas@v4 - run: npx nx-cloud record -- nx format:check - run: npx nx affected -t lint test build e2e-ci 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 cbd08ccb09841..4e71999d898d5 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 @@ -118,10 +118,6 @@ jobs: - nx/set-shas: main-branch-name: 'main' - # Required for nx affected if we're on a branch - - run: git branch --track main origin/main - condition: eq(variables['Build.Reason'], 'PullRequest') - - run: npx nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD - run: npx nx affected --base=$NX_BASE --head=$NX_HEAD -t lint test build e2e-ci @@ -167,9 +163,6 @@ jobs: - run: npm ci - uses: nrwl/nx-set-shas@v4 - - run: git branch --track main origin/main - if: \${{ github.event_name == 'pull_request' }} - - run: npx nx-cloud record -- nx format:check - run: npx nx affected -t lint test build e2e-ci " @@ -208,9 +201,6 @@ jobs: - run: npm ci - uses: nrwl/nx-set-shas@v4 - - run: git branch --track main origin/main - if: \${{ github.event_name == 'pull_request' }} - - run: npx nx-cloud record -- nx format:check - run: npx nx affected -t lint test build e2e-ci " @@ -334,10 +324,6 @@ jobs: - nx/set-shas: main-branch-name: 'main' - # Required for nx affected if we're on a branch - - run: git branch --track main origin/main - condition: eq(variables['Build.Reason'], 'PullRequest') - - run: npx nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD - run: npx nx affected --base=$NX_BASE --head=$NX_HEAD -t lint test build @@ -383,9 +369,6 @@ jobs: - run: npm ci - uses: nrwl/nx-set-shas@v4 - - run: git branch --track main origin/main - if: \${{ github.event_name == 'pull_request' }} - - run: npx nx-cloud record -- nx format:check - run: npx nx affected -t lint test build " @@ -424,9 +407,6 @@ jobs: - run: npm ci - uses: nrwl/nx-set-shas@v4 - - run: git branch --track main origin/main - if: \${{ github.event_name == 'pull_request' }} - - run: npx nx-cloud record -- nx format:check - run: npx nx affected -t lint test build " @@ -588,10 +568,6 @@ jobs: - nx/set-shas: main-branch-name: 'main' - # Required for nx affected if we're on a branch - - run: git branch --track main origin/main - condition: eq(variables['Build.Reason'], 'PullRequest') - - run: pnpm exec nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD - run: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD -t lint test build @@ -641,9 +617,6 @@ jobs: - run: pnpm install --frozen-lockfile - uses: nrwl/nx-set-shas@v4 - - run: git branch --track main origin/main - if: \${{ github.event_name == 'pull_request' }} - - run: pnpm exec nx-cloud record -- nx format:check - run: pnpm exec nx affected -t lint test build " @@ -686,9 +659,6 @@ jobs: - run: pnpm install --frozen-lockfile - uses: nrwl/nx-set-shas@v4 - - run: git branch --track main origin/main - if: \${{ github.event_name == 'pull_request' }} - - run: pnpm exec nx-cloud record -- nx format:check - run: pnpm exec nx affected -t lint test build " @@ -841,10 +811,6 @@ jobs: - nx/set-shas: main-branch-name: 'main' - # Required for nx affected if we're on a branch - - run: git branch --track main origin/main - condition: eq(variables['Build.Reason'], 'PullRequest') - - run: yarn nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD - run: yarn nx affected --base=$NX_BASE --head=$NX_HEAD -t lint test build @@ -890,9 +856,6 @@ jobs: - run: yarn install --frozen-lockfile - uses: nrwl/nx-set-shas@v4 - - run: git branch --track main origin/main - if: \${{ github.event_name == 'pull_request' }} - - run: yarn nx-cloud record -- nx format:check - run: yarn nx affected -t lint test build " @@ -931,9 +894,6 @@ jobs: - run: yarn install --frozen-lockfile - uses: nrwl/nx-set-shas@v4 - - run: git branch --track main origin/main - if: \${{ github.event_name == 'pull_request' }} - - run: yarn nx-cloud record -- nx format:check - run: yarn nx affected -t lint test build " 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 a198599c570bc..5d4b9572bfefa 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__ @@ -51,7 +51,7 @@ jobs: # - script: <%= packageManagerPrefix %> 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 main origin/main + - script: git branch --track <%= mainBranch %> origin/<%= mainBranch %> condition: eq(variables['Build.Reason'], 'PullRequest') - script: <%= packageManagerPrefix %> nx-cloud record -- nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA) 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 d298e41a69682..b04698fea264a 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__ @@ -23,10 +23,6 @@ jobs: - nx/set-shas: main-branch-name: '<%= mainBranch %>' - # Required for nx affected if we're on a branch - - run: git branch --track main origin/main - condition: eq(variables['Build.Reason'], 'PullRequest') - - run: <%= packageManagerPrefix %> nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD - run: <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD -t lint test build<% if(hasE2E){ %> e2e-ci<% } %> 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 b7ae0118de5a3..d316cdb7a1b14 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__ @@ -35,8 +35,5 @@ jobs: - run: <%= packageManagerInstall %> - uses: nrwl/nx-set-shas@v4 - - run: git branch --track main origin/main - if: ${{ github.event_name == 'pull_request' }} - - run: <%= packageManagerPrefix %> nx-cloud record -- nx format:check - run: <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasE2E){ %> e2e-ci<% } %>