441 lines
12 KiB
YAML
441 lines
12 KiB
YAML
version: 2.1
|
|
|
|
# -------------------------
|
|
# ORBS
|
|
# -------------------------
|
|
orbs:
|
|
nx: nrwl/nx@1.0.0
|
|
|
|
# -------------------------
|
|
# DEFAULTS
|
|
# -------------------------
|
|
machine:
|
|
pre:
|
|
- mkdir ~/.cache/yarn
|
|
|
|
dependencies:
|
|
cache_directories:
|
|
- ~/.cache/yarn
|
|
|
|
defaults: &defaults
|
|
working_directory: ~/repo
|
|
|
|
# -------------------------
|
|
# EXECUTORS
|
|
# -------------------------
|
|
executors:
|
|
linux:
|
|
<<: *defaults
|
|
docker:
|
|
- image: cimg/node:14.17-browsers
|
|
|
|
windows:
|
|
<<: *defaults
|
|
resource_class: windows.medium
|
|
machine:
|
|
image: windows-server-2019-vs2019:stable
|
|
shell: cmd.exe
|
|
|
|
macos:
|
|
<<: *defaults
|
|
macos:
|
|
xcode: &_XCODE_VERSION '12.5.0'
|
|
|
|
android:
|
|
<<: *defaults
|
|
docker:
|
|
- image: reactnativecommunity/react-native-android:4.0
|
|
resource_class: 'large'
|
|
environment:
|
|
- TERM: 'dumb'
|
|
- ADB_INSTALL_TIMEOUT: 10
|
|
- _JAVA_OPTIONS: '-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap'
|
|
- GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-XX:+HeapDumpOnOutOfMemoryError"'
|
|
- BUILD_THREADS: 2
|
|
|
|
# -------------------------
|
|
# COMMANDS
|
|
# -------------------------
|
|
commands:
|
|
run-yarn:
|
|
parameters:
|
|
os:
|
|
type: string
|
|
steps:
|
|
- restore_cache:
|
|
name: Restore Yarn Package Cache
|
|
keys:
|
|
- nrwl-nx-yarn-packages-<< parameters.os >>-{{ checksum "yarn.lock" }}
|
|
- run:
|
|
name: Install dependencies
|
|
command: yarn install --prefer-offline --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn
|
|
- save_cache:
|
|
name: Save Yarn Package Cache
|
|
key: nrwl-nx-yarn-packages-<< parameters.os >>-{{ checksum "yarn.lock" }}
|
|
paths:
|
|
- ~/.cache/yarn
|
|
|
|
install-pnpm:
|
|
parameters:
|
|
os:
|
|
type: string
|
|
steps:
|
|
- when:
|
|
condition:
|
|
equal: [<< parameters.os >>, linux]
|
|
steps:
|
|
- run:
|
|
name: Install PNPM
|
|
command: npm install --prefix=$HOME/.local -g pnpm@6.9.1
|
|
- when:
|
|
condition:
|
|
equal: [<< parameters.os >>, windows]
|
|
steps:
|
|
- run:
|
|
name: Install PNPM
|
|
command: npm install -g pnpm@6.9.1
|
|
|
|
setup:
|
|
parameters:
|
|
os:
|
|
type: string
|
|
steps:
|
|
- checkout
|
|
- when:
|
|
condition:
|
|
equal: [<< parameters.os >>, windows]
|
|
steps:
|
|
- run: nvm install 14.17
|
|
- run: nvm use 14.17
|
|
- run: npm install -g yarn@1.22.10
|
|
|
|
- run-yarn:
|
|
os: << parameters.os >>
|
|
- install-pnpm:
|
|
os: << parameters.os >>
|
|
|
|
run-checks:
|
|
steps:
|
|
- 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 Formatting
|
|
command: yarn check-commit
|
|
- run:
|
|
name: Check Package dependencies
|
|
command: yarn depcheck
|
|
|
|
run-targets:
|
|
parameters:
|
|
run-builds:
|
|
type: string
|
|
default: 'true'
|
|
run-unit-tests:
|
|
type: string
|
|
default: 'true'
|
|
run-linting:
|
|
type: string
|
|
default: 'true'
|
|
run-e2e-tests:
|
|
type: string
|
|
default: 'true'
|
|
# Filters for tests
|
|
unit-test-filter:
|
|
type: string
|
|
default: ''
|
|
e2e-test-filter:
|
|
type: string
|
|
default: ''
|
|
steps:
|
|
- nx/set-shas:
|
|
main-branch-name: 'master'
|
|
- when:
|
|
condition:
|
|
equal: [<< parameters.run-builds >>, 'true']
|
|
steps:
|
|
- run:
|
|
name: Run Builds
|
|
command: |
|
|
npx nx affected --target=build --base=$NX_BASE --parallel --max-parallel=3
|
|
- when:
|
|
condition:
|
|
equal: [<< parameters.run-unit-tests >>, 'true']
|
|
steps:
|
|
- when:
|
|
condition:
|
|
equal: [<< parameters.e2e-test-filter >>, '']
|
|
steps:
|
|
- run:
|
|
name: Run Unit Tests
|
|
command: |
|
|
npx nx affected --target=test --base=$NX_BASE --parallel --max-parallel=2
|
|
- unless:
|
|
condition:
|
|
equal: [<< parameters.e2e-test-filter >>, '']
|
|
steps:
|
|
- run:
|
|
name: Run Unit Tests with Filter "<< parameters.e2e-test-filter >>"
|
|
command: |
|
|
npx nx affected --target=test --base=$NX_BASE --parallel --max-parallel=2 -- --t="<< parameters.e2e-test-filter >>"
|
|
- when:
|
|
condition:
|
|
equal: [<< parameters.run-linting >>, 'true']
|
|
steps:
|
|
- run:
|
|
name: Run Linting
|
|
command: |
|
|
npx nx affected --target=lint --base=$NX_BASE --parallel --max-parallel=4
|
|
- when:
|
|
condition:
|
|
equal: [<< parameters.run-e2e-tests >>, 'true']
|
|
steps:
|
|
- when:
|
|
condition:
|
|
equal: [<< parameters.e2e-test-filter >>, '']
|
|
steps:
|
|
- run:
|
|
name: Run E2E Tests
|
|
command: |
|
|
npx nx affected --target=e2e --no-parallel --max-parallel=1 --base=$NX_BASE
|
|
no_output_timeout: 45m
|
|
- unless:
|
|
condition:
|
|
equal: [<< parameters.e2e-test-filter >>, '']
|
|
steps:
|
|
- run:
|
|
name: Run E2E Tests with Filter "<< parameters.e2e-test-filter >>"
|
|
command: |
|
|
npx nx affected --target=e2e --base=$NX_BASE -- --t="<< parameters.e2e-test-filter >>"
|
|
no_output_timeout: 45m
|
|
|
|
# -------------------------
|
|
# JOBS
|
|
# -------------------------
|
|
jobs:
|
|
# -------------------------
|
|
# JOBS: Agent
|
|
# -------------------------
|
|
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 >>
|
|
NX_VERBOSE_LOGGING: 'true'
|
|
steps:
|
|
- setup:
|
|
os: << parameters.os >>
|
|
- run:
|
|
name: Agent
|
|
command: npx nx-cloud start-agent
|
|
no_output_timeout: 60m
|
|
|
|
# -------------------------
|
|
# JOBS: Agent cleanup
|
|
# -------------------------
|
|
agent-cleanup:
|
|
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 >>
|
|
NX_VERBOSE_LOGGING: 'true'
|
|
steps:
|
|
- setup:
|
|
os: << parameters.os >>
|
|
- run:
|
|
name: Stop All Running Agents for This CI Run
|
|
command: npx nx-cloud stop-all-agents
|
|
|
|
# -------------------------
|
|
# JOBS: Main
|
|
# -------------------------
|
|
main:
|
|
parameters:
|
|
# -------------------------
|
|
# Environment setup
|
|
# -------------------------
|
|
os:
|
|
type: string
|
|
default: 'linux'
|
|
cli:
|
|
type: string
|
|
default: ''
|
|
pm:
|
|
type: string
|
|
default: pnpm
|
|
# -------------------------
|
|
# Flags
|
|
# -------------------------
|
|
run-checks:
|
|
type: string
|
|
default: 'true'
|
|
run-builds:
|
|
type: string
|
|
default: 'true'
|
|
run-unit-tests:
|
|
type: string
|
|
default: 'true'
|
|
run-linting:
|
|
type: string
|
|
default: 'true'
|
|
run-e2e-tests:
|
|
type: string
|
|
default: 'true'
|
|
run-cypress-tests:
|
|
type: string
|
|
default: 'false'
|
|
# -------------------------
|
|
# Filters for tests
|
|
# -------------------------
|
|
unit-test-filter:
|
|
type: string
|
|
default: ''
|
|
e2e-test-filter:
|
|
type: string
|
|
default: ''
|
|
executor: << parameters.os >>
|
|
environment:
|
|
NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
|
|
SELECTED_CLI: << parameters.cli >>
|
|
SELECTED_PM: << parameters.pm >>
|
|
NX_E2E_CI_CACHE_KEY: e2e-circleci-<< parameters.os >>-<< parameters.pm >>
|
|
NX_E2E_RUN_CYPRESS: << parameters.run-cypress-tests >>
|
|
NX_VERBOSE_LOGGING: 'true'
|
|
steps:
|
|
- setup:
|
|
os: << parameters.os >>
|
|
- when:
|
|
condition:
|
|
equal: [<< parameters.run-checks >>, 'true']
|
|
steps:
|
|
- run-checks
|
|
- run-targets:
|
|
run-builds: << parameters.run-builds >>
|
|
run-unit-tests: << parameters.run-unit-tests >>
|
|
run-linting: << parameters.run-linting >>
|
|
run-e2e-tests: << parameters.run-e2e-tests >>
|
|
unit-test-filter: << parameters.unit-test-filter >>
|
|
e2e-test-filter: << parameters.e2e-test-filter >>
|
|
|
|
# -------------------------
|
|
# WORKFLOWS
|
|
# -------------------------
|
|
workflows:
|
|
version: 2
|
|
|
|
build:
|
|
jobs:
|
|
- agent:
|
|
name: 'agent1'
|
|
- agent:
|
|
name: 'agent2'
|
|
- agent:
|
|
name: 'agent3'
|
|
- agent:
|
|
name: 'agent4'
|
|
- agent:
|
|
name: 'agent5'
|
|
- agent:
|
|
name: 'agent6'
|
|
- agent:
|
|
name: 'agent7'
|
|
- agent:
|
|
name: 'agent8'
|
|
- agent:
|
|
name: 'agent9'
|
|
# - agent:
|
|
# name: 'agent10'
|
|
# os: 'macos'
|
|
# -------------------------
|
|
# Pull request logic
|
|
# -------------------------
|
|
- main:
|
|
name: pull-request
|
|
run-checks: 'true'
|
|
filters:
|
|
branches:
|
|
ignore: master
|
|
# - main:
|
|
# name: pull-request-osx
|
|
# pm: 'yarn'
|
|
# os: 'macos'
|
|
# run-checks: 'false'
|
|
# run-builds: 'false'
|
|
# run-unit-tests: 'false'
|
|
# run-linting: 'false'
|
|
# e2e-test-filter: 'MACOS-Tests'
|
|
# filters:
|
|
# branches:
|
|
# ignore: master
|
|
# - main:
|
|
# name: pull-request-android
|
|
# pm: 'yarn'
|
|
# os: 'android'
|
|
# run-checks: 'false'
|
|
# run-builds: 'false'
|
|
# run-unit-tests: 'false'
|
|
# run-linting: 'false'
|
|
# e2e-test-filter: 'Android-Tests'
|
|
# filters:
|
|
# branches:
|
|
# ignore: master
|
|
- agent-cleanup:
|
|
requires:
|
|
- pull-request
|
|
# - pull-request-osx
|
|
# - pull-request-android
|
|
filters:
|
|
branches:
|
|
ignore: master
|
|
# -------------------------
|
|
# Commit to master
|
|
# -------------------------
|
|
- main:
|
|
name: commit-to-master
|
|
run-cypress-tests: 'true'
|
|
filters:
|
|
branches:
|
|
only: master
|
|
- agent-cleanup:
|
|
requires:
|
|
- commit-to-master
|
|
filters:
|
|
branches:
|
|
only: master
|