Skip to content

Commit

Permalink
feat(core): update generated ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Apr 13, 2022
1 parent d54cf35 commit 5344390
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ jobs:
displayName: NPM Install Dependencies
- script: yarn nx-cloud start-ci-run
displayName: Start CI run
- script: yarn nx workspace-lint
displayName: Run workspace lint
- script: yarn nx format:check
displayName: Check format
- script: yarn nx affected --base=$(BASE_SHA) --target=lint --parallel=3
displayName: Run lint
- script: yarn nx affected --base=$(BASE_SHA) --target=test --parallel=3 --ci --code-coverage
displayName: Run test
- script: yarn nx affected --base=$(BASE_SHA) --target=build --parallel=3
displayName: Run build
- script: yarn nx affected --base=$(BASE_SHA) --target=test --parallel=2
displayName: Run test
- script: yarn nx-cloud stop-all-agents
condition: always()
displayName: Stop all Nx-Cloud agents"
Expand Down Expand Up @@ -103,20 +107,28 @@ jobs:
- run:
name: Initialize the Nx Cloud distributed CI run
command: yarn nx-cloud start-ci-run
- run:
name: Run workspace lint
command: nx workspace-lint
- run:
name: Check format
command: nx format:check
- run:
name: Run lint
command: yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3
- run:
name: Run test
command: yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage
- run:
name: Run build
command: yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
- run:
name: Run test
command: yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=2
- run:
name: Stop all agents
command: yarn nx-cloud stop-all-agents
workflows:
version: 2
build:
jobs:
- agent:
Expand All @@ -137,50 +149,21 @@ on:
jobs:
main:
runs-on: ubuntu-latest
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: true
NX_BRANCH: \${{ github.event.number || github.ref_name }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for \`nx affected\` commands
uses: nrwl/nx-set-shas@v2
with:
main-branch-name: 'main'
- uses: actions/setup-node@v1
with:
node-version: '16'
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Initialize the Nx Cloud distributed CI run
run: yarn nx-cloud start-ci-run
- name: Run lint
run: yarn nx affected --target=lint --parallel=3
- name: Run build
run: yarn nx affected --target=build --parallel=3
- name: Run test
run: yarn nx affected --target=test --parallel=2
- name: Stop all running agents for this CI run
if: \${{ always() }}
run: yarn nx-cloud stop-all-agents
name: Nx Cloud - Main Job
uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.2
with:
parallel-commands: |
yarn nx workspace-lint
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
yarn nx affected --target=build --parallel=3
agents:
runs-on: ubuntu-latest
name: Agent \${{ matrix.agent }}
strategy:
matrix:
agent: [1, 2, 3]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: '16'
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Start Nx Agent \${{ matrix.agent }}
run: yarn nx-cloud start-agent"
name: Nx Cloud - Agents
uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.2
with:
number-of-agents: 3
"
`;
2 changes: 0 additions & 2 deletions packages/workspace/src/generators/ci-workflow/ci-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
names,
generateFiles,
joinPathFragments,
detectPackageManager,
getPackageManagerCommand,
} from '@nrwl/devkit';
import { deduceDefaultBase } from '../../utilities/default-base';
Expand All @@ -18,7 +17,6 @@ export async function ciWorkflowGenerator(host: Tree, schema: Schema) {
const options = normalizeOptions(schema);

generateFiles(host, joinPathFragments(__dirname, 'files', ci), '', options);
// TODO: Implement error handling when file already exists
}

interface Substitutes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ jobs:
displayName: NPM Install Dependencies
- script: <%= packageManagerPrefix %> nx-cloud start-ci-run
displayName: Start CI run
- script: <%= packageManagerPrefix %> nx workspace-lint
displayName: Run workspace lint
- script: <%= packageManagerPrefix %> nx format:check
displayName: Check format
- script: <%= packageManagerPrefix %> nx affected --base=$(BASE_SHA) --target=lint --parallel=3
displayName: Run lint
- script: <%= packageManagerPrefix %> nx affected --base=$(BASE_SHA) --target=test --parallel=3 --ci --code-coverage
displayName: Run test
- script: <%= packageManagerPrefix %> nx affected --base=$(BASE_SHA) --target=build --parallel=3
displayName: Run build
- script: <%= packageManagerPrefix %> nx affected --base=$(BASE_SHA) --target=test --parallel=2
displayName: Run test
- script: <%= packageManagerPrefix %> nx-cloud stop-all-agents
condition: always()
displayName: Stop all Nx-Cloud agents
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,28 @@ jobs:
- run:
name: Initialize the Nx Cloud distributed CI run
command: <%= packageManagerPrefix %> nx-cloud start-ci-run
- run:
name: Run workspace lint
command: <% packageManagerPrefix %> nx workspace-lint
- run:
name: Check format
command: <% packageManagerPrefix %> nx format:check
- run:
name: Run lint
command: <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3
- run:
name: Run test
command: <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage
- run:
name: Run build
command: <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
- run:
name: Run test
command: <%= packageManagerPrefix %> nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=2
- run:
name: Stop all agents
command: <%= packageManagerPrefix %> nx-cloud stop-all-agents

workflows:
version: 2

<%= workflowName %>:
jobs:
- agent:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,19 @@ on:

jobs:
main:
runs-on: ubuntu-latest
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: true
NX_BRANCH: ${{ github.event.number || github.ref_name }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
with:
main-branch-name: '<%= mainBranch %>'
- uses: actions/setup-node@v1
with:
node-version: '16'
- name: Install dependencies
run: <%= packageManagerInstall %>
- name: Initialize the Nx Cloud distributed CI run
run: <%= packageManagerPrefix %> nx-cloud start-ci-run
- name: Run lint
run: <%= packageManagerPrefix %> nx affected --target=lint --parallel=3
- name: Run build
run: <%= packageManagerPrefix %> nx affected --target=build --parallel=3
- name: Run test
run: <%= packageManagerPrefix %> nx affected --target=test --parallel=2
- name: Stop all running agents for this CI run
if: ${{ always() }}
run: <%= packageManagerPrefix %> nx-cloud stop-all-agents
name: Nx Cloud - Main Job
uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.2
with:
parallel-commands: |
<%= packageManagerPrefix %> nx workspace-lint
<%= 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
<%= packageManagerPrefix %> nx affected --target=build --parallel=3

agents:
runs-on: ubuntu-latest
name: Agent ${{ matrix.agent }}
strategy:
matrix:
agent: [1, 2, 3]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: '16'
- name: Install dependencies
run: <%= packageManagerInstall %>
- name: Start Nx Agent ${{ matrix.agent }}
run: <%= packageManagerPrefix %> nx-cloud start-agent
name: Nx Cloud - Agents
uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.2
with:
number-of-agents: 3

0 comments on commit 5344390

Please sign in to comment.