// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`CI Workflow generator with npm should generate azure CI config 1`] = `
"name: CI

trigger:
  - main
pr:
  - main

variables:
  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
    pool:
      vmImage: 'ubuntu-latest'
    steps:
      - script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
        displayName: Install PNPM
      - script: pnpm install --frozen-lockfile
        displayName: NPM Install Dependencies
      - script: npx nx-cloud start-agent
        displayName: Start Nx-Cloud agent

  - job: main
    displayName: Nx Cloud Main
    pool:
      vmImage: 'ubuntu-latest'
    steps:
      - script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
        displayName: Install PNPM
      - script: pnpm install --frozen-lockfile
        displayName: NPM Install Dependencies
      - script: pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
        displayName: Start CI run
      - script: pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA)
        displayName: Check format
      - script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=lint --parallel=3
        displayName: Run lint
      - script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=test --parallel=3 --ci --code-coverage
        displayName: Run test
      - script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=build --parallel=3
        displayName: Run build
      - script: pnpm exec nx-cloud stop-all-agents
        condition: always()
        displayName: Stop all Nx-Cloud agents
"
`;

exports[`CI Workflow generator with npm should generate bitbucket pipelines config 1`] = `
"image: node:16.18

clone:
  depth: full

definitions:
  steps:
    - step: &agent
        name: Agent
        script:
          - export NX_BRANCH=$BITBUCKET_PR_ID

          - npm install --prefix=$HOME/.local -g pnpm@8.2.0

          - pnpm install --frozen-lockfile
          - pnpm exec nx-cloud start-agent

pipelines:
  pull-requests:
    '**':
      - parallel:
          - step:
              name: CI
              script:
                - export NX_BRANCH=$BITBUCKET_PR_ID

                - npm install --prefix=$HOME/.local -g pnpm@8.2.0

                - pnpm install --frozen-lockfile
                - pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
                - pnpm exec nx-cloud record -- pnpm exec nx format:check
                - pnpm exec nx affected --target=lint & pnpm exec nx affected --target=test & pnpm exec nx affected --target=build
                - pnpm exec nx-cloud stop-all-agents
          - step: *agent
          - step: *agent
          - step: *agent
"
`;

exports[`CI Workflow generator with npm should generate circleci CI config 1`] = `
"version: 2.1

orbs:
  nx: nrwl/nx@1.6.1

jobs:
  agent:
    docker:
      - image: cimg/node:lts-browsers
    parameters:
      ordinal:
        type: integer
    steps:
      - checkout

      - run:
          name: Install PNPM
          command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
      - run:
          name: Install dependencies
          command: pnpm install --frozen-lockfile
      - run:
          name: Start the agent << parameters.ordinal >>
          command: pnpm exec nx-cloud start-agent
          no_output_timeout: 60m
  main:
    docker:
      - image: cimg/node:lts-browsers
    environment:
      NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
    steps:
      - checkout

      - run:
          name: Install PNPM
          command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
      - run:
          name: Install dependencies
          command: pnpm install --frozen-lockfile
      - nx/set-shas:
          main-branch-name: 'main'
      - run:
          name: Initialize the Nx Cloud distributed CI run
          command: pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
      - run:
          name: Check format
          command: pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$NX_BASE --head=$NX_HEAD
      - run:
          name: Run lint
          command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3
      - run:
          name: Run test
          command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage
      - run:
          name: Run build
          command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
      - run:
          name: Stop all agents
          command: pnpm exec nx-cloud stop-all-agents
          when: always

workflows:
  version: 2

  ci:
    jobs:
      - agent:
          name: Nx Cloud Agent << matrix.ordinal >>
          matrix:
            parameters:
              ordinal: [1, 2, 3]
      - main:
          name: Nx Cloud Main
"
`;

exports[`CI Workflow generator with npm should generate github CI config 1`] = `
"name: CI

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  main:
    name: Nx Cloud - Main Job
    uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.13.0
    with:
      main-branch-name: main
      number-of-agents: 3
      init-commands: |
        pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
      parallel-commands: |
        pnpm exec nx-cloud record -- pnpm exec nx format:check
      parallel-commands-on-agents: |
        pnpm exec nx affected --target=lint --parallel=3
        pnpm exec nx affected --target=test --parallel=3 --ci --code-coverage
        pnpm exec nx affected --target=build --parallel=3

  agents:
    name: Nx Cloud - Agents
    uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.13.0
    with:
      number-of-agents: 3
"
`;

exports[`CI Workflow generator with npm should generate github CI config with custom name 1`] = `
"name: My custom-workflow

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  main:
    name: Nx Cloud - Main Job
    uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.13.0
    with:
      main-branch-name: main
      number-of-agents: 3
      init-commands: |
        pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
      parallel-commands: |
        pnpm exec nx-cloud record -- pnpm exec nx format:check
      parallel-commands-on-agents: |
        pnpm exec nx affected --target=lint --parallel=3
        pnpm exec nx affected --target=test --parallel=3 --ci --code-coverage
        pnpm exec nx affected --target=build --parallel=3

  agents:
    name: Nx Cloud - Agents
    uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.13.0
    with:
      number-of-agents: 3
"
`;

exports[`CI Workflow generator with npm should generate gitlab config 1`] = `
"image: node:18
variables:
  CI: 'true'

# Creating template for DTE agents
.dte-agent:
  interruptible: true
  script:
    - npm install --prefix=$HOME/.local -g pnpm@8.2.0

    - pnpm install --frozen-lockfile
    - pnpm exec nx-cloud start-agent

# Creating template for a job running DTE (orchestrator)
.base-pipeline:
  interruptible: true
  only:
    - main
    - merge_requests
  before_script:
    - npm install --prefix=$HOME/.local -g pnpm@8.2.0

    - pnpm install --frozen-lockfile
    - NX_HEAD=$CI_COMMIT_SHA
    - NX_BASE=\${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}

# Main job running DTE
CI:
  stage: affected
  extends: .base-pipeline
  script:
    - pnpm exec nx-cloud start-ci-run --stop-agents-after="build"
    - pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$NX_BASE --head=$NX_HEAD
    - pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=e2e --parallel=3 --ci --code-coverage & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3

# Create as many agents as you want
nx-dte-agent1:
  extends: .dte-agent
  stage: affected
nx-dte-agent2:
  extends: .dte-agent
  stage: affected
nx-dte-agent3:
  extends: .dte-agent
  stage: affected
"
`;

exports[`CI Workflow generator with npm should throw error is nx cloud is not set 1`] = `"This workspace is not connected to Nx Cloud."`;

exports[`CI Workflow generator with pnpm should generate azure CI config 1`] = `
"name: CI

trigger:
  - main
pr:
  - main

variables:
  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
    pool:
      vmImage: 'ubuntu-latest'
    steps:
      - script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
        displayName: Install PNPM
      - script: pnpm install --frozen-lockfile
        displayName: NPM Install Dependencies
      - script: npx nx-cloud start-agent
        displayName: Start Nx-Cloud agent

  - job: main
    displayName: Nx Cloud Main
    pool:
      vmImage: 'ubuntu-latest'
    steps:
      - script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
        displayName: Install PNPM
      - script: pnpm install --frozen-lockfile
        displayName: NPM Install Dependencies
      - script: pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
        displayName: Start CI run
      - script: pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA)
        displayName: Check format
      - script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=lint --parallel=3
        displayName: Run lint
      - script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=test --parallel=3 --ci --code-coverage
        displayName: Run test
      - script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=build --parallel=3
        displayName: Run build
      - script: pnpm exec nx-cloud stop-all-agents
        condition: always()
        displayName: Stop all Nx-Cloud agents
"
`;

exports[`CI Workflow generator with pnpm should generate bitbucket pipelines config 1`] = `
"image: node:16.18

clone:
  depth: full

definitions:
  steps:
    - step: &agent
        name: Agent
        script:
          - export NX_BRANCH=$BITBUCKET_PR_ID

          - npm install --prefix=$HOME/.local -g pnpm@8.2.0

          - pnpm install --frozen-lockfile
          - pnpm exec nx-cloud start-agent

pipelines:
  pull-requests:
    '**':
      - parallel:
          - step:
              name: CI
              script:
                - export NX_BRANCH=$BITBUCKET_PR_ID

                - npm install --prefix=$HOME/.local -g pnpm@8.2.0

                - pnpm install --frozen-lockfile
                - pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
                - pnpm exec nx-cloud record -- pnpm exec nx format:check
                - pnpm exec nx affected --target=lint & pnpm exec nx affected --target=test & pnpm exec nx affected --target=build
                - pnpm exec nx-cloud stop-all-agents
          - step: *agent
          - step: *agent
          - step: *agent
"
`;

exports[`CI Workflow generator with pnpm should generate circleci CI config 1`] = `
"version: 2.1

orbs:
  nx: nrwl/nx@1.6.1

jobs:
  agent:
    docker:
      - image: cimg/node:lts-browsers
    parameters:
      ordinal:
        type: integer
    steps:
      - checkout

      - run:
          name: Install PNPM
          command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
      - run:
          name: Install dependencies
          command: pnpm install --frozen-lockfile
      - run:
          name: Start the agent << parameters.ordinal >>
          command: pnpm exec nx-cloud start-agent
          no_output_timeout: 60m
  main:
    docker:
      - image: cimg/node:lts-browsers
    environment:
      NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
    steps:
      - checkout

      - run:
          name: Install PNPM
          command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
      - run:
          name: Install dependencies
          command: pnpm install --frozen-lockfile
      - nx/set-shas:
          main-branch-name: 'main'
      - run:
          name: Initialize the Nx Cloud distributed CI run
          command: pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
      - run:
          name: Check format
          command: pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$NX_BASE --head=$NX_HEAD
      - run:
          name: Run lint
          command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3
      - run:
          name: Run test
          command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage
      - run:
          name: Run build
          command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
      - run:
          name: Stop all agents
          command: pnpm exec nx-cloud stop-all-agents
          when: always

workflows:
  version: 2

  ci:
    jobs:
      - agent:
          name: Nx Cloud Agent << matrix.ordinal >>
          matrix:
            parameters:
              ordinal: [1, 2, 3]
      - main:
          name: Nx Cloud Main
"
`;

exports[`CI Workflow generator with pnpm should generate github CI config 1`] = `
"name: CI

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  main:
    name: Nx Cloud - Main Job
    uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.13.0
    with:
      main-branch-name: main
      number-of-agents: 3
      init-commands: |
        pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
      parallel-commands: |
        pnpm exec nx-cloud record -- pnpm exec nx format:check
      parallel-commands-on-agents: |
        pnpm exec nx affected --target=lint --parallel=3
        pnpm exec nx affected --target=test --parallel=3 --ci --code-coverage
        pnpm exec nx affected --target=build --parallel=3

  agents:
    name: Nx Cloud - Agents
    uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.13.0
    with:
      number-of-agents: 3
"
`;

exports[`CI Workflow generator with pnpm should generate github CI config with custom name 1`] = `
"name: My custom-workflow

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  main:
    name: Nx Cloud - Main Job
    uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.13.0
    with:
      main-branch-name: main
      number-of-agents: 3
      init-commands: |
        pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
      parallel-commands: |
        pnpm exec nx-cloud record -- pnpm exec nx format:check
      parallel-commands-on-agents: |
        pnpm exec nx affected --target=lint --parallel=3
        pnpm exec nx affected --target=test --parallel=3 --ci --code-coverage
        pnpm exec nx affected --target=build --parallel=3

  agents:
    name: Nx Cloud - Agents
    uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.13.0
    with:
      number-of-agents: 3
"
`;

exports[`CI Workflow generator with pnpm should generate gitlab config 1`] = `
"image: node:18
variables:
  CI: 'true'

# Creating template for DTE agents
.dte-agent:
  interruptible: true
  script:
    - npm install --prefix=$HOME/.local -g pnpm@8.2.0

    - pnpm install --frozen-lockfile
    - pnpm exec nx-cloud start-agent

# Creating template for a job running DTE (orchestrator)
.base-pipeline:
  interruptible: true
  only:
    - main
    - merge_requests
  before_script:
    - npm install --prefix=$HOME/.local -g pnpm@8.2.0

    - pnpm install --frozen-lockfile
    - NX_HEAD=$CI_COMMIT_SHA
    - NX_BASE=\${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}

# Main job running DTE
CI:
  stage: affected
  extends: .base-pipeline
  script:
    - pnpm exec nx-cloud start-ci-run --stop-agents-after="build"
    - pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$NX_BASE --head=$NX_HEAD
    - pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=e2e --parallel=3 --ci --code-coverage & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3

# Create as many agents as you want
nx-dte-agent1:
  extends: .dte-agent
  stage: affected
nx-dte-agent2:
  extends: .dte-agent
  stage: affected
nx-dte-agent3:
  extends: .dte-agent
  stage: affected
"
`;

exports[`CI Workflow generator with pnpm should throw error is nx cloud is not set 1`] = `"This workspace is not connected to Nx Cloud."`;

exports[`CI Workflow generator with yarn should generate azure CI config 1`] = `
"name: CI

trigger:
  - main
pr:
  - main

variables:
  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
    pool:
      vmImage: 'ubuntu-latest'
    steps:
      - script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
        displayName: Install PNPM
      - script: pnpm install --frozen-lockfile
        displayName: NPM Install Dependencies
      - script: npx nx-cloud start-agent
        displayName: Start Nx-Cloud agent

  - job: main
    displayName: Nx Cloud Main
    pool:
      vmImage: 'ubuntu-latest'
    steps:
      - script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
        displayName: Install PNPM
      - script: pnpm install --frozen-lockfile
        displayName: NPM Install Dependencies
      - script: pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
        displayName: Start CI run
      - script: pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA)
        displayName: Check format
      - script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=lint --parallel=3
        displayName: Run lint
      - script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=test --parallel=3 --ci --code-coverage
        displayName: Run test
      - script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=build --parallel=3
        displayName: Run build
      - script: pnpm exec nx-cloud stop-all-agents
        condition: always()
        displayName: Stop all Nx-Cloud agents
"
`;

exports[`CI Workflow generator with yarn should generate bitbucket pipelines config 1`] = `
"image: node:16.18

clone:
  depth: full

definitions:
  steps:
    - step: &agent
        name: Agent
        script:
          - export NX_BRANCH=$BITBUCKET_PR_ID

          - npm install --prefix=$HOME/.local -g pnpm@8.2.0

          - pnpm install --frozen-lockfile
          - pnpm exec nx-cloud start-agent

pipelines:
  pull-requests:
    '**':
      - parallel:
          - step:
              name: CI
              script:
                - export NX_BRANCH=$BITBUCKET_PR_ID

                - npm install --prefix=$HOME/.local -g pnpm@8.2.0

                - pnpm install --frozen-lockfile
                - pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
                - pnpm exec nx-cloud record -- pnpm exec nx format:check
                - pnpm exec nx affected --target=lint & pnpm exec nx affected --target=test & pnpm exec nx affected --target=build
                - pnpm exec nx-cloud stop-all-agents
          - step: *agent
          - step: *agent
          - step: *agent
"
`;

exports[`CI Workflow generator with yarn should generate circleci CI config 1`] = `
"version: 2.1

orbs:
  nx: nrwl/nx@1.6.1

jobs:
  agent:
    docker:
      - image: cimg/node:lts-browsers
    parameters:
      ordinal:
        type: integer
    steps:
      - checkout

      - run:
          name: Install PNPM
          command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
      - run:
          name: Install dependencies
          command: pnpm install --frozen-lockfile
      - run:
          name: Start the agent << parameters.ordinal >>
          command: pnpm exec nx-cloud start-agent
          no_output_timeout: 60m
  main:
    docker:
      - image: cimg/node:lts-browsers
    environment:
      NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
    steps:
      - checkout

      - run:
          name: Install PNPM
          command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
      - run:
          name: Install dependencies
          command: pnpm install --frozen-lockfile
      - nx/set-shas:
          main-branch-name: 'main'
      - run:
          name: Initialize the Nx Cloud distributed CI run
          command: pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
      - run:
          name: Check format
          command: pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$NX_BASE --head=$NX_HEAD
      - run:
          name: Run lint
          command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3
      - run:
          name: Run test
          command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage
      - run:
          name: Run build
          command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
      - run:
          name: Stop all agents
          command: pnpm exec nx-cloud stop-all-agents
          when: always

workflows:
  version: 2

  ci:
    jobs:
      - agent:
          name: Nx Cloud Agent << matrix.ordinal >>
          matrix:
            parameters:
              ordinal: [1, 2, 3]
      - main:
          name: Nx Cloud Main
"
`;

exports[`CI Workflow generator with yarn should generate github CI config 1`] = `
"name: CI

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  main:
    name: Nx Cloud - Main Job
    uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.13.0
    with:
      main-branch-name: main
      number-of-agents: 3
      init-commands: |
        pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
      parallel-commands: |
        pnpm exec nx-cloud record -- pnpm exec nx format:check
      parallel-commands-on-agents: |
        pnpm exec nx affected --target=lint --parallel=3
        pnpm exec nx affected --target=test --parallel=3 --ci --code-coverage
        pnpm exec nx affected --target=build --parallel=3

  agents:
    name: Nx Cloud - Agents
    uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.13.0
    with:
      number-of-agents: 3
"
`;

exports[`CI Workflow generator with yarn should generate github CI config with custom name 1`] = `
"name: My custom-workflow

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  main:
    name: Nx Cloud - Main Job
    uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.13.0
    with:
      main-branch-name: main
      number-of-agents: 3
      init-commands: |
        pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
      parallel-commands: |
        pnpm exec nx-cloud record -- pnpm exec nx format:check
      parallel-commands-on-agents: |
        pnpm exec nx affected --target=lint --parallel=3
        pnpm exec nx affected --target=test --parallel=3 --ci --code-coverage
        pnpm exec nx affected --target=build --parallel=3

  agents:
    name: Nx Cloud - Agents
    uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.13.0
    with:
      number-of-agents: 3
"
`;

exports[`CI Workflow generator with yarn should generate gitlab config 1`] = `
"image: node:18
variables:
  CI: 'true'

# Creating template for DTE agents
.dte-agent:
  interruptible: true
  script:
    - npm install --prefix=$HOME/.local -g pnpm@8.2.0

    - pnpm install --frozen-lockfile
    - pnpm exec nx-cloud start-agent

# Creating template for a job running DTE (orchestrator)
.base-pipeline:
  interruptible: true
  only:
    - main
    - merge_requests
  before_script:
    - npm install --prefix=$HOME/.local -g pnpm@8.2.0

    - pnpm install --frozen-lockfile
    - NX_HEAD=$CI_COMMIT_SHA
    - NX_BASE=\${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}

# Main job running DTE
CI:
  stage: affected
  extends: .base-pipeline
  script:
    - pnpm exec nx-cloud start-ci-run --stop-agents-after="build"
    - pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$NX_BASE --head=$NX_HEAD
    - pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=e2e --parallel=3 --ci --code-coverage & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3

# Create as many agents as you want
nx-dte-agent1:
  extends: .dte-agent
  stage: affected
nx-dte-agent2:
  extends: .dte-agent
  stage: affected
nx-dte-agent3:
  extends: .dte-agent
  stage: affected
"
`;

exports[`CI Workflow generator with yarn should throw error is nx cloud is not set 1`] = `"This workspace is not connected to Nx Cloud."`;
