diff --git a/docs/generated/packages/workspace.json b/docs/generated/packages/workspace.json index 155260334865e..597dd83bec7a5 100644 --- a/docs/generated/packages/workspace.json +++ b/docs/generated/packages/workspace.json @@ -684,7 +684,7 @@ "type": "string", "description": "Workflow name.", "$default": { "$source": "argv", "index": 0 }, - "default": "build", + "default": "CI", "x-prompt": "How should we name your workflow?", "pattern": "^[a-zA-Z].*$" } diff --git a/docs/shared/monorepo-ci-azure.md b/docs/shared/monorepo-ci-azure.md index 6a32792e4c023..321be2194b2d5 100644 --- a/docs/shared/monorepo-ci-azure.md +++ b/docs/shared/monorepo-ci-azure.md @@ -27,21 +27,15 @@ pr: - main variables: - - name: NX_BRANCH - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - value: $(System.PullRequest.PullRequestNumber) - ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: - value: $(Build.SourceBranchName) - - name: TARGET_BRANCH - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - value: $[replace(variables['System.PullRequest.TargetBranch'],'refs/heads/','origin/')] - - name: BASE_SHA - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - value: $(git merge-base $(TARGET_BRANCH) HEAD) - ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: - value: $(git rev-parse HEAD~1) - - name: HEAD_SHA - value: $(git rev-parse HEAD) + CI: 'true' + ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: + NX_BRANCH: $(System.PullRequest.PullRequestNumber) + TARGET_BRANCH: $[replace(variables['System.PullRequest.TargetBranch'],'refs/heads/','origin/')] + BASE_SHA: $(git merge-base $(TARGET_BRANCH) HEAD) + ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: + NX_BRANCH: $(Build.SourceBranchName) + BASE_SHA: $(git rev-parse HEAD~1) + HEAD_SHA: $(git rev-parse HEAD) jobs: - job: main @@ -75,29 +69,22 @@ pr: - main variables: - - name: NX_CLOUD_DISTRIBUTED_EXECUTION - value: 'true' - - name: NX_BRANCH - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - value: $(System.PullRequest.PullRequestNumber) - ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: - value: $(Build.SourceBranchName) - - name: TARGET_BRANCH - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - value: $[replace(variables['System.PullRequest.TargetBranch'],'refs/heads/','origin/')] - - name: BASE_SHA - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - value: $(git merge-base $(TARGET_BRANCH) HEAD) - ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: - value: $(git rev-parse HEAD~1) - - name: HEAD_SHA - value: $(git rev-parse HEAD) + CI: 'true' + NX_CLOUD_DISTRIBUTED_EXECUTION: 'true' + ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: + NX_BRANCH: $(System.PullRequest.PullRequestNumber) + TARGET_BRANCH: $[replace(variables['System.PullRequest.TargetBranch'],'refs/heads/','origin/')] + BASE_SHA: $(git merge-base $(TARGET_BRANCH) HEAD) + ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: + NX_BRANCH: $(Build.SourceBranchName) + BASE_SHA: $(git rev-parse HEAD~1) + HEAD_SHA: $(git rev-parse HEAD) jobs: - job: agents strategy: parallel: 3 - displayName: 'Agent $(imageName)' + displayName: Nx Cloud Agent pool: vmImage: 'ubuntu-latest' steps: @@ -105,14 +92,15 @@ jobs: - script: npx nx-cloud start-agent - job: main + displayName: Nx Cloud Main pool: vmImage: 'ubuntu-latest' steps: - script: npm ci - script: npx nx-cloud start-ci-run - - script: npx nx workspace-lint - - script: npx nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA) + - script: npx nx-cloud record -- npx nx workspace-lint + - script: npx nx-cloud record -- npx nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA) - script: npx nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=lint --parallel=3 - script: npx nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=test --parallel=3 --ci --code-coverage - script: npx nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=build --parallel=3 diff --git a/docs/shared/monorepo-ci-circle-ci.md b/docs/shared/monorepo-ci-circle-ci.md index 4e5f5aaed6ded..dcdf69aaa9789 100644 --- a/docs/shared/monorepo-ci-circle-ci.md +++ b/docs/shared/monorepo-ci-circle-ci.md @@ -87,8 +87,8 @@ jobs: - nx/set-shas - run: npx nx-cloud start-ci-run - - run: npx nx workspace-lint - - run: npx nx format:check + - run: npx nx-cloud record -- npx nx workspace-lint + - run: npx nx-cloud record -- npx nx format:check - run: npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 - run: npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage - run: npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3 diff --git a/docs/shared/monorepo-ci-github-actions.md b/docs/shared/monorepo-ci-github-actions.md index ba22b36cfe978..191f03bf742e6 100644 --- a/docs/shared/monorepo-ci-github-actions.md +++ b/docs/shared/monorepo-ci-github-actions.md @@ -68,8 +68,8 @@ jobs: uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.2 with: parallel-commands: | - npx nx workspace-lint - npx nx format:check + npx nx-cloud record -- npx nx workspace-lint + npx nx-cloud record -- npx nx format:check parallel-commands-on-agents: | npx nx affected --target=lint --parallel=3 npx nx affected --target=test --parallel=3 --ci --code-coverage 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 a36a7bbcbe7a7..0d643987b9a5f 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 @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`lib should generate azure CI config 1`] = ` -"name: build +"name: CI trigger: - main @@ -9,39 +9,32 @@ pr: - main variables: - - name: NX_CLOUD_DISTRIBUTED_EXECUTION - value: 'true' - - name: NX_BRANCH - \${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - value: $(System.PullRequest.PullRequestNumber) - \${{ if ne(variables['Build.Reason'], 'PullRequest') }}: - value: $(Build.SourceBranchName) - - name: TARGET_BRANCH - \${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - value: $[replace(variables['System.PullRequest.TargetBranch'],'refs/heads/','origin/')] - - name: BASE_SHA - \${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - value: $(git merge-base $(TARGET_BRANCH) HEAD) - \${{ if ne(variables['Build.Reason'], 'PullRequest') }}: - value: $(git rev-parse HEAD~1) - - name: HEAD_SHA - value: $(git rev-parse HEAD) + CI: 'true' + NX_CLOUD_DISTRIBUTED_EXECUTION: 'true' + \${{ if eq(variables['Build.Reason'], 'PullRequest') }}: + NX_BRANCH: $(System.PullRequest.PullRequestNumber) + TARGET_BRANCH: $[replace(variables['System.PullRequest.TargetBranch'],'refs/heads/','origin/')] + BASE_SHA: $(git merge-base $(TARGET_BRANCH) HEAD) + \${{ if ne(variables['Build.Reason'], 'PullRequest') }}: + NX_BRANCH: $(Build.SourceBranchName) + BASE_SHA: $(git rev-parse HEAD~1) + HEAD_SHA: $(git rev-parse HEAD) jobs: - job: agents strategy: parallel: 3 - displayName: 'Nx Cloud Agent' + displayName: Nx Cloud Agent pool: vmImage: 'ubuntu-latest' steps: - script: yarn --frozen-lockfile displayName: NPM Install Dependencies - script: npx nx-cloud start-agent - displayName: 'Start Nx-Cloud agent + displayName: Start Nx-Cloud agent - job: main - displayName: 'Nx Cloud Main' + displayName: Nx Cloud Main pool: vmImage: 'ubuntu-latest' steps: @@ -49,9 +42,9 @@ jobs: displayName: NPM Install Dependencies - script: yarn nx-cloud start-ci-run displayName: Start CI run - - script: yarn nx workspace-lint + - script: yarn nx-cloud record -- yarn nx workspace-lint displayName: Run workspace lint - - script: yarn nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA) + - script: yarn nx-cloud record -- yarn nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA) displayName: Check format - script: yarn nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=lint --parallel=3 displayName: Run lint @@ -104,10 +97,10 @@ jobs: command: yarn nx-cloud start-ci-run - run: name: Run workspace lint - command: yarn nx workspace-lint + command: yarn nx-cloud record -- yarn nx workspace-lint - run: name: Check format - command: yarn nx format:check --base=$NX_BASE --head=$NX_HEAD + command: yarn nx-cloud record -- yarn nx format:check --base=$NX_BASE --head=$NX_HEAD - run: name: Run lint command: yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 @@ -125,20 +118,20 @@ jobs: workflows: version: 2 - build: + ci: jobs: - agent: name: Nx Cloud Agent << matrix.ordinal >> matrix: parameters: ordinal: [1, 2, 3] - - main + - main: name: Nx Cloud Main " `; exports[`lib should generate github CI config 1`] = ` -"name: build +"name: CI on: push: @@ -152,8 +145,8 @@ jobs: uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.2 with: parallel-commands: | - yarn nx workspace-lint - yarn nx format:check + yarn nx-cloud record -- yarn nx workspace-lint + yarn nx-cloud record -- yarn nx format:check parallel-commands-on-agents: | yarn nx affected --target=lint --parallel=3 yarn nx affected --target=test --parallel=3 --ci --code-coverage @@ -182,8 +175,8 @@ jobs: uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.2 with: parallel-commands: | - yarn nx workspace-lint - yarn nx format:check + yarn nx-cloud record -- yarn nx workspace-lint + yarn nx-cloud record -- yarn nx format:check parallel-commands-on-agents: | yarn nx affected --target=lint --parallel=3 yarn nx affected --target=test --parallel=3 --ci --code-coverage diff --git a/packages/workspace/src/generators/ci-workflow/ci-workflow.spec.ts b/packages/workspace/src/generators/ci-workflow/ci-workflow.spec.ts index b60b101cbfc79..80d9ee442ee99 100644 --- a/packages/workspace/src/generators/ci-workflow/ci-workflow.spec.ts +++ b/packages/workspace/src/generators/ci-workflow/ci-workflow.spec.ts @@ -13,7 +13,7 @@ describe('lib', () => { setNxCloud(tree); await ciWorkflowGenerator(tree, { ci: 'github' }); - expect(tree.read('.github/workflows/build.yml', 'utf-8')).toMatchSnapshot(); + expect(tree.read('.github/workflows/ci.yml', 'utf-8')).toMatchSnapshot(); }); it('should generate circleci CI config', async () => { diff --git a/packages/workspace/src/generators/ci-workflow/ci-workflow.ts b/packages/workspace/src/generators/ci-workflow/ci-workflow.ts index 61b233ac76576..6ecd659410a40 100644 --- a/packages/workspace/src/generators/ci-workflow/ci-workflow.ts +++ b/packages/workspace/src/generators/ci-workflow/ci-workflow.ts @@ -42,7 +42,7 @@ interface Substitutes { function normalizeOptions(options: Schema): Substitutes { const { name: workflowName, fileName: workflowFileName } = names( - options.name || 'build' + options.name || 'CI' ); const { exec: packageManagerPrefix, ciInstall: packageManagerInstall } = getPackageManagerCommand(); 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 933996dddd53a..a29e564edfd33 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__ @@ -6,29 +6,22 @@ pr: - <%= mainBranch %> variables: - - name: NX_CLOUD_DISTRIBUTED_EXECUTION - value: 'true' - - name: NX_BRANCH - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - value: $(System.PullRequest.PullRequestNumber) - ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: - value: $(Build.SourceBranchName) - - name: TARGET_BRANCH - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - value: $[replace(variables['System.PullRequest.TargetBranch'],'refs/heads/','origin/')] - - name: BASE_SHA - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - value: $(git merge-base $(TARGET_BRANCH) HEAD) - ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: - value: $(git rev-parse HEAD~1) - - name: HEAD_SHA - value: $(git rev-parse HEAD) + CI: 'true' + NX_CLOUD_DISTRIBUTED_EXECUTION: 'true' + ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: + NX_BRANCH: $(System.PullRequest.PullRequestNumber) + TARGET_BRANCH: $[replace(variables['System.PullRequest.TargetBranch'],'refs/heads/','origin/')] + BASE_SHA: $(git merge-base $(TARGET_BRANCH) HEAD) + ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: + NX_BRANCH: $(Build.SourceBranchName) + BASE_SHA: $(git rev-parse HEAD~1) + HEAD_SHA: $(git rev-parse HEAD) jobs: - job: agents strategy: parallel: 3 - displayName: 'Nx Cloud Agent' + displayName: Nx Cloud Agent pool: vmImage: 'ubuntu-latest' steps: @@ -38,10 +31,10 @@ jobs: <% } %>- script: <%= packageManagerInstall %> displayName: NPM Install Dependencies - script: npx nx-cloud start-agent - displayName: 'Start Nx-Cloud agent + displayName: Start Nx-Cloud agent - job: main - displayName: 'Nx Cloud Main' + displayName: Nx Cloud Main pool: vmImage: 'ubuntu-latest' steps: @@ -52,9 +45,9 @@ jobs: displayName: NPM Install Dependencies - script: <%= packageManagerPrefix %> nx-cloud start-ci-run displayName: Start CI run - - script: <%= packageManagerPrefix %> nx workspace-lint + - script: <%= packageManagerPrefix %> nx-cloud record -- <%= packageManagerPrefix %> nx workspace-lint displayName: Run workspace lint - - script: <%= packageManagerPrefix %> nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA) + - script: <%= packageManagerPrefix %> nx-cloud record -- <%= packageManagerPrefix %> nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA) displayName: Check format - script: <%= packageManagerPrefix %> nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=lint --parallel=3 displayName: Run lint 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 6134d7ca297ca..97f6c96adfa17 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__ @@ -44,10 +44,10 @@ jobs: command: <%= packageManagerPrefix %> nx-cloud start-ci-run - run: name: Run workspace lint - command: <%= packageManagerPrefix %> nx workspace-lint + command: <%= packageManagerPrefix %> nx-cloud record -- <%= packageManagerPrefix %> nx workspace-lint - run: name: Check format - command: <%= packageManagerPrefix %> nx format:check --base=$NX_BASE --head=$NX_HEAD + command: <%= packageManagerPrefix %> nx-cloud record -- <%= packageManagerPrefix %> nx format:check --base=$NX_BASE --head=$NX_HEAD - run: name: Run lint command: <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 @@ -72,5 +72,5 @@ workflows: matrix: parameters: ordinal: [1, 2, 3] - - main + - main: name: Nx Cloud Main 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 7f4b2f8de8cf0..3a4ee856223f0 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__ @@ -12,8 +12,8 @@ jobs: uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.2 with: parallel-commands: | - <%= packageManagerPrefix %> nx workspace-lint - <%= packageManagerPrefix %> nx format:check + <%= packageManagerPrefix %> nx-cloud record -- <%= packageManagerPrefix %> nx workspace-lint + <%= packageManagerPrefix %> nx-cloud record -- <%= packageManagerPrefix %> nx format:check parallel-commands-on-agents: | <%= packageManagerPrefix %> nx affected --target=lint --parallel=3 <%= packageManagerPrefix %> nx affected --target=test --parallel=3 --ci --code-coverage diff --git a/packages/workspace/src/generators/ci-workflow/schema.json b/packages/workspace/src/generators/ci-workflow/schema.json index c181dfb85adfd..2851e7aadf945 100644 --- a/packages/workspace/src/generators/ci-workflow/schema.json +++ b/packages/workspace/src/generators/ci-workflow/schema.json @@ -27,7 +27,7 @@ "$source": "argv", "index": 0 }, - "default": "build", + "default": "CI", "x-prompt": "How should we name your workflow?", "pattern": "^[a-zA-Z].*$" }