diff --git a/packages/gradle/src/generators/ci-workflow/__snapshots__/generator.spec.ts.snap b/packages/gradle/src/generators/ci-workflow/__snapshots__/generator.spec.ts.snap index 732167fefb..7040c27439 100644 --- a/packages/gradle/src/generators/ci-workflow/__snapshots__/generator.spec.ts.snap +++ b/packages/gradle/src/generators/ci-workflow/__snapshots__/generator.spec.ts.snap @@ -6,6 +6,9 @@ exports[`ci-workflow generator connected to nxCloud circleci pipeline should mat orbs: nx: nrwl/nx@1.6.2 +env: + NX_BATCH_MODE: true + jobs: main: environment: @@ -21,13 +24,14 @@ jobs: # Run this command as early as possible, before dependencies are installed # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun # Uncomment this line to enable task distribution - # - run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="build" + # - run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="check" - nx/set-shas: main-branch-name: 'main' - # Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected - - run: ./nx affected --base=$NX_BASE --head=$NX_HEAD -t build + # Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected. + # Change from check to check-ci if you turn on the atomizer. Learn more: https://nx.dev/nx-api/gradle#splitting-e2e-tests. + - run: ./nx affected --base=$NX_BASE --head=$NX_HEAD -t assemble check workflows: version: 2 @@ -51,6 +55,9 @@ permissions: actions: read contents: read +env: + NX_BATCH_MODE: true + jobs: main: runs-on: ubuntu-latest @@ -64,7 +71,7 @@ jobs: # Run this command as early as possible, before dependencies are installed # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun # Uncomment this line to enable task distribution - # - run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="build" + # - run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="check" - name: Set up JDK 21 for x64 uses: actions/setup-java@v4 @@ -74,12 +81,13 @@ jobs: architecture: x64 - name: Setup Gradle - uses: gradle/gradle-build-action@v4 + uses: gradle/actions/setup-gradle@v3 - uses: nrwl/nx-set-shas@v4 - # Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected - - run: ./nx affected -t build + # Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected. + # Change from check to check-ci if you turn on the atomizer. Learn more: https://nx.dev/nx-api/gradle#splitting-tests + - run: ./nx affected -t assemble check " `; @@ -89,6 +97,9 @@ exports[`ci-workflow generator not connected to nxCloud circleci pipeline should orbs: nx: nrwl/nx@1.6.2 +env: + NX_BATCH_MODE: true + jobs: main: environment: @@ -104,13 +115,14 @@ jobs: # Run this command as early as possible, before dependencies are installed # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun # Connect your workspace by running "nx connect" and uncomment this line to enable task distribution - # - run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="build" + # - run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="check" - nx/set-shas: main-branch-name: 'main' - # Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected - - run: ./nx affected --base=$NX_BASE --head=$NX_HEAD -t build + # Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected. + # Change from check to check-ci if you turn on the atomizer. Learn more: https://nx.dev/nx-api/gradle#splitting-e2e-tests. + - run: ./nx affected --base=$NX_BASE --head=$NX_HEAD -t assemble check workflows: version: 2 @@ -134,6 +146,9 @@ permissions: actions: read contents: read +env: + NX_BATCH_MODE: true + jobs: main: runs-on: ubuntu-latest @@ -147,7 +162,7 @@ jobs: # Run this command as early as possible, before dependencies are installed # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun # Connect your workspace by running "nx connect" and uncomment this line to enable task distribution - # - run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="build" + # - run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="check" - name: Set up JDK 21 for x64 uses: actions/setup-java@v4 @@ -157,11 +172,12 @@ jobs: architecture: x64 - name: Setup Gradle - uses: gradle/gradle-build-action@v4 + uses: gradle/actions/setup-gradle@v3 - uses: nrwl/nx-set-shas@v4 - # Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected - - run: ./nx affected -t build + # Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected. + # Change from check to check-ci if you turn on the atomizer. Learn more: https://nx.dev/nx-api/gradle#splitting-tests + - run: ./nx affected -t assemble check " `; diff --git a/packages/gradle/src/generators/ci-workflow/files/circleci/.circleci/config.yml.template b/packages/gradle/src/generators/ci-workflow/files/circleci/.circleci/config.yml.template index c7a6ba4cca..ea5fb0f82f 100644 --- a/packages/gradle/src/generators/ci-workflow/files/circleci/.circleci/config.yml.template +++ b/packages/gradle/src/generators/ci-workflow/files/circleci/.circleci/config.yml.template @@ -3,6 +3,9 @@ version: 2.1 orbs: nx: nrwl/nx@1.6.2 +env: + NX_BATCH_MODE: true + jobs: main: environment: @@ -18,13 +21,13 @@ jobs: # Run this command as early as possible, before dependencies are installed # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun <% if (connectedToCloud) { %># Uncomment this line to enable task distribution<% } else { %># Connect your workspace by running "nx connect" and uncomment this line to enable task distribution<% } %> - # - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="build" + # - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="check" - nx/set-shas: main-branch-name: '<%= mainBranch %>' - <% for (const command of commands) { %> - <% if (command.command) { %>- run: <%= command.command %><% } else if (command.comment) { %><%= command.comment %><% } else {%>- run: <%= command %><% } %><% } %> + <% if (command.command) { %>- run: <%= command.command %><% } else if (command.comments) { %><% for (const comment of command.comments) { %> + <%= comment %><% } %><% } else {%>- run: <%= command %><% } %><% } %> workflows: version: 2 diff --git a/packages/gradle/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml.template b/packages/gradle/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml.template index 2a384492c6..0a49119556 100644 --- a/packages/gradle/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml.template +++ b/packages/gradle/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml.template @@ -10,6 +10,9 @@ permissions: actions: read contents: read +env: + NX_BATCH_MODE: true + jobs: main: runs-on: ubuntu-latest @@ -23,7 +26,7 @@ jobs: # Run this command as early as possible, before dependencies are installed # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun <% if (connectedToCloud) { %># Uncomment this line to enable task distribution<% } else { %># Connect your workspace by running "nx connect" and uncomment this line to enable task distribution<% } %> - # - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="build" + # - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="check" - name: Set up JDK 21 for x64 uses: actions/setup-java@v4 @@ -33,9 +36,9 @@ jobs: architecture: x64 - name: Setup Gradle - uses: gradle/gradle-build-action@v4 + uses: gradle/actions/setup-gradle@v3 - uses: nrwl/nx-set-shas@v4 - <% for (const command of commands) { %> - <% if (command.command) { %>- run: <%= command.command %><% } else if (command.comment) { %><%= command.comment %><% } else {%>- run: <%= command %><% } %><% } %> + <% if (command.command) { %>- run: <%= command.command %><% } else if (command.comments) { %><% for (const comment of command.comments) { %> + <%= comment %><% } %><% } else {%>- run: <%= command %><% } %><% } %> diff --git a/packages/gradle/src/generators/ci-workflow/generator.ts b/packages/gradle/src/generators/ci-workflow/generator.ts index 1e817f0df1..37641f62fb 100644 --- a/packages/gradle/src/generators/ci-workflow/generator.ts +++ b/packages/gradle/src/generators/ci-workflow/generator.ts @@ -16,25 +16,31 @@ function getCiCommands(ci: Schema['ci']): Command[] { case 'circleci': { return [ { - comment: `# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected`, + comments: [ + `# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected.`, + `# Change from check to check-ci if you turn on the atomizer. Learn more: https://nx.dev/nx-api/gradle#splitting-e2e-tests.`, + ], }, { - command: `./nx affected --base=$NX_BASE --head=$NX_HEAD -t build`, + command: `./nx affected --base=$NX_BASE --head=$NX_HEAD -t assemble check`, }, ]; } default: { return [ { - comment: `# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected`, + comments: [ + `# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected.`, + `# Change from check to check-ci if you turn on the atomizer. Learn more: https://nx.dev/nx-api/gradle#splitting-tests`, + ], }, - { command: `./nx affected -t build` }, + { command: `./nx affected -t assemble check` }, ]; } } } -export type Command = { command: string } | { comment: string } | string; +export type Command = { command: string } | { comments: string[] } | string; export interface Schema { name: string;