nx/.circleci/config.yml
2021-04-29 12:00:21 -04:00

195 lines
5.1 KiB
YAML

version: 2.1
# Variables
var_1: &working_directory ~/repo
executors:
linux:
working_directory: *working_directory
docker:
- image: cimg/node:12.20-browsers
windows:
working_directory: *working_directory
resource_class: windows.medium
machine:
image: windows-server-2019-vs2019:stable
shell: cmd.exe
commands:
setup:
parameters:
os:
type: string
steps:
- checkout
- when:
condition:
equal: [<< parameters.os >>, windows]
steps:
- run: nvm install 12.20
- run: nvm use 12.20
- run: npm install -g yarn@1.19.0
- restore_cache:
name: Restore Yarn Package Cache
keys:
- nrwl-nx-yarn-packages-<< parameters.os >>-{{ checksum "yarn.lock" }}
- run:
name: Install dependencies
command: yarn install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn
- save_cache:
name: Save Yarn Package Cache
# Windows needs its own cache key because binaries in node_modules are different.
key: nrwl-nx-yarn-packages-<< parameters.os >>-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- when:
condition:
equal: [<< parameters.os >>, linux]
steps:
- run:
name: Install PNPM
command: npm install --prefix=$HOME/.local -g pnpm@5.18.9
- when:
condition:
equal: [<< parameters.os >>, windows]
steps:
- run:
name: Install PNPM
command: npm install -g pnpm@5.18.9
jobs:
agent:
parameters:
os:
type: string
default: 'linux'
cli:
type: string
default: ''
pm:
type: string
default: pnpm
executor: << parameters.os >>
environment:
GIT_AUTHOR_NAME: test@test.com
GIT_AUTHOR_EMAIL: Test
GIT_COMMITTER_EMAIL: test@test.com
GIT_COMMITTER_NAME: Test
NX_E2E_CI_CACHE_KEY: e2e-circleci-<< parameters.os >>-<< parameters.pm >>
SELECTED_PM: << parameters.pm >>
SELECTED_CLI: << parameters.cli >>
steps:
- setup:
os: << parameters.os >>
- run:
name: Agent
command: npx nx-cloud start-agent
no_output_timeout: 60m
pr-main:
parameters:
os:
type: string
default: 'linux'
cli:
type: string
default: ''
pm:
type: string
default: pnpm
executor: << parameters.os >>
environment:
NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
SELECTED_CLI: << parameters.cli >>
NX_E2E_CI_CACHE_KEY: e2e-circleci-<< parameters.os >>-<< parameters.pm >>
steps:
- setup:
os: << parameters.os >>
- run:
name: Check Documentation
command: yarn documentation
- run:
name: Check Imports
command: yarn check-imports
- run:
name: Check Formatting
command: yarn check-format
- run:
name: Check Package dependencies
command: yarn depcheck
- run:
name: Run Builds
command: npx nx affected --target=build
- run:
name: Run Unit Tests
command: npx nx affected --target=test
- run:
name: Run Lint Checks
command: npx nx affected --target=lint
- run:
name: Run E2E Tests
command: npx nx affected --target=e2e
no_output_timeout: 45m
- run:
name: Stop All Running Agents for This CI Run
command: npx nx-cloud stop-all-agents
trunk-main:
parameters:
os:
type: string
default: 'linux'
cli:
type: string
default: ''
pm:
type: string
default: pnpm
executor: << parameters.os >>
environment:
NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
SELECTED_CLI: << parameters.cli >>
NX_E2E_CI_CACHE_KEY: e2e-circleci-<< parameters.os >>-<< parameters.pm >>
steps:
- setup:
os: << parameters.os >>
- run:
name: Run Builds
command: npx nx affected --target=build --base=HEAD~1
- run:
name: Run Unit Tests
command: npx nx affected --target=test --base=HEAD~1
- run:
name: Run Lint Checks
command: npx nx affected --target=lint --base=HEAD~1
- run:
name: Run E2E Tests
command: npx nx affected --target=e2e --base=HEAD~1
no_output_timeout: 45m
- run:
name: Stop All Running Agents for This CI Run
command: npx nx-cloud stop-all-agents
workflows:
build:
jobs:
- agent:
name: 'agent1'
- agent:
name: 'agent2'
- agent:
name: 'agent3'
- agent:
name: 'agent4'
- agent:
name: 'agent5'
- agent:
name: 'agent6'
- trunk-main:
filters:
branches:
only: master
- pr-main:
filters:
branches:
ignore: master