264 lines
7.8 KiB
YAML
264 lines
7.8 KiB
YAML
version: 2.1
|
|
|
|
# -------------------------
|
|
# ORBS
|
|
# -------------------------
|
|
orbs:
|
|
nx: nrwl/nx@1.5.1
|
|
node: circleci/node@5.0.2
|
|
|
|
# -------------------------
|
|
# DEFAULTS
|
|
# -------------------------
|
|
machine:
|
|
pre:
|
|
- mkdir ~/.cache/yarn
|
|
- mkdir ~/.cache/Cypress
|
|
- mkdir ~/Library/Caches/Homebrew
|
|
- mkdir /usr/local/Homebrew
|
|
|
|
dependencies:
|
|
cache_directories:
|
|
- ~/.cache/yarn
|
|
- ~/.cache/Cypress
|
|
- /usr/local/Homebrew
|
|
- ~/Library/Caches/Homebrew
|
|
override:
|
|
- yarn install
|
|
- brew install
|
|
|
|
defaults: &defaults
|
|
working_directory: ~/repo
|
|
|
|
# -------------------------
|
|
# EXECUTORS
|
|
# -------------------------
|
|
executors:
|
|
linux:
|
|
<<: *defaults
|
|
docker:
|
|
- image: cimg/node:lts-browsers
|
|
resource_class: medium+
|
|
|
|
macos:
|
|
<<: *defaults
|
|
macos:
|
|
xcode: &_XCODE_VERSION '13.0.0'
|
|
|
|
# -------------------------
|
|
# COMMANDS
|
|
# -------------------------
|
|
commands:
|
|
run-yarn-install:
|
|
parameters:
|
|
os:
|
|
type: string
|
|
steps:
|
|
- restore_cache:
|
|
name: Restore Yarn Package Cache
|
|
keys:
|
|
- node-deps-{{ arch }}-v1-{{ checksum "package.json" }}-{{ 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: node-deps-{{ arch }}-v1-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
|
|
paths:
|
|
- node_modules
|
|
- ~/.cache/yarn
|
|
- ~/.cache/Cypress
|
|
install-pnpm:
|
|
steps:
|
|
- run:
|
|
name: Install PNPM
|
|
command: npm install --prefix=$HOME/.local -g pnpm@6.32.4
|
|
|
|
setup:
|
|
parameters:
|
|
os:
|
|
type: string
|
|
steps:
|
|
- checkout
|
|
- when:
|
|
condition:
|
|
equal: [<< parameters.os >>, macos]
|
|
steps:
|
|
- restore_cache:
|
|
name: Restore Homebrew packages
|
|
keys:
|
|
- nrwl-nx-homebrew-packages
|
|
- run:
|
|
name: Configure Detox Environment, Install applesimutils
|
|
command: |
|
|
HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew >/dev/null
|
|
HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils >/dev/null
|
|
xcrun simctl shutdown all && xcrun simctl erase all
|
|
no_output_timeout: 20m
|
|
- save_cache:
|
|
name: Save Homebrew Cache
|
|
key: nrwl-nx-homebrew-packages
|
|
paths:
|
|
- /usr/local/Homebrew
|
|
- ~/Library/Caches/Homebrew
|
|
- when:
|
|
condition:
|
|
equal: [<< parameters.os >>, linux]
|
|
steps:
|
|
- run:
|
|
command: sudo apt-get install -y ca-certificates
|
|
- run-yarn-install:
|
|
os: << parameters.os >>
|
|
- when:
|
|
condition:
|
|
equal: [<< parameters.os >>, linux]
|
|
steps:
|
|
- install-pnpm
|
|
|
|
# -------------------------
|
|
# JOBS
|
|
# -------------------------
|
|
jobs:
|
|
# -------------------------
|
|
# JOBS: Agent
|
|
# -------------------------
|
|
agent:
|
|
parameters:
|
|
os:
|
|
type: string
|
|
default: 'linux'
|
|
pm:
|
|
type: string
|
|
default: 'pnpm'
|
|
executor: << parameters.os >>
|
|
environment:
|
|
GIT_AUTHOR_EMAIL: test@test.com
|
|
GIT_AUTHOR_NAME: Test
|
|
GIT_COMMITTER_EMAIL: test@test.com
|
|
GIT_COMMITTER_NAME: Test
|
|
NX_E2E_CI_CACHE_KEY: e2e-circleci-<< parameters.os >>
|
|
SELECTED_PM: << parameters.pm >>
|
|
NX_E2E_RUN_CYPRESS: 'false'
|
|
NX_VERBOSE_LOGGING: 'false'
|
|
steps:
|
|
- run:
|
|
name: Set dynamic nx run variable
|
|
command: |
|
|
echo "export NX_RUN_GROUP=\"run-group-<< parameters.os >>-$CIRCLE_WORKFLOW_ID\";" >> $BASH_ENV
|
|
- setup:
|
|
os: << parameters.os >>
|
|
- run:
|
|
name: Agent
|
|
command: npx nx-cloud start-agent
|
|
no_output_timeout: 60m
|
|
|
|
# -------------------------
|
|
# JOBS: Main Linux
|
|
# -------------------------
|
|
main-linux:
|
|
executor: linux
|
|
environment:
|
|
NX_E2E_CI_CACHE_KEY: e2e-circleci-linux
|
|
NX_VERBOSE_LOGGING: 'false'
|
|
steps:
|
|
- run:
|
|
name: Set dynamic nx run variable
|
|
command: |
|
|
echo "export NX_RUN_GROUP=\"run-group-linux-$CIRCLE_WORKFLOW_ID\";" >> $BASH_ENV
|
|
- setup:
|
|
os: linux
|
|
- nx/set-shas:
|
|
main-branch-name: 'master'
|
|
- run: npx nx-cloud start-ci-run --stop-agents-after="e2e"
|
|
- run:
|
|
name: Check Documentation
|
|
command: npx nx-cloud record yarn documentation
|
|
no_output_timeout: 20m
|
|
- run:
|
|
name: Run Checks/Lint/Test/Build
|
|
command: |
|
|
pids=()
|
|
|
|
(npx nx-cloud record yarn check-imports &&
|
|
npx nx-cloud record yarn nx format:check --base=$NX_BASE --head=$NX_HEAD &&
|
|
npx nx-cloud record yarn check-commit &&
|
|
npx nx-cloud record yarn check-lock-files &&
|
|
npx nx-cloud record yarn nx workspace-lint &&
|
|
npx nx-cloud record yarn depcheck) &
|
|
pids+=($!)
|
|
|
|
(yarn nx affected --target=build --base=$NX_BASE --head=$NX_HEAD --parallel=3 &&
|
|
npx nx affected --target=e2e --base=$NX_BASE --head=$NX_HEAD --exclude=e2e-storybook,e2e-storybook-angular,e2e-react-native,e2e-detox,e2e-make-angular-cli-faster --parallel=1) &
|
|
pids+=($!)
|
|
yarn nx affected --target=lint --base=$NX_BASE --head=$NX_HEAD --parallel=3 &
|
|
pids+=($!)
|
|
yarn nx affected --target=test --base=$NX_BASE --head=$NX_HEAD --parallel=1 &
|
|
pids+=($!)
|
|
for pid in "${pids[@]}"; do
|
|
wait "$pid"
|
|
done
|
|
# -------------------------
|
|
# JOBS: Main-MacOS
|
|
# -------------------------
|
|
mainmacos:
|
|
executor: macos
|
|
environment:
|
|
NX_E2E_CI_CACHE_KEY: e2e-circleci-macos
|
|
steps:
|
|
- run:
|
|
name: Set dynamic nx run variable
|
|
command: |
|
|
echo "export NX_RUN_GROUP=\"run-group-macos-$CIRCLE_WORKFLOW_ID\";" >> $BASH_ENV
|
|
- setup:
|
|
os: macos
|
|
- nx/set-shas:
|
|
main-branch-name: 'master'
|
|
- run:
|
|
name: Check if "detox" or "react-native" were modified directly
|
|
command: |
|
|
COUNT=`git diff --name-only $NX_BASE $NX_HEAD | (grep -E 'packages/detox|packages/react-native|e2e/detox|e2e/react-native' || true) | wc -l`
|
|
if [[ $COUNT -gt 0 ]]; then
|
|
echo "React Native and Detox were touched directly"
|
|
echo "export E2E_AFFECTED=true;" >> $BASH_ENV
|
|
else
|
|
echo "React Native and Detox were not touched directly"
|
|
echo "export E2E_AFFECTED=false;" >> $BASH_ENV
|
|
fi
|
|
- run:
|
|
name: Run E2E Tests
|
|
command: |
|
|
if $E2E_AFFECTED; then
|
|
npx nx affected --target=e2e --base=$NX_BASE --head=$NX_HEAD --exclude=e2e-make-angular-cli-faster,e2e-detox,e2e-js,e2e-next,e2e-workspace-create,e2e-nx-run,e2e-nx-misc,e2e-react,e2e-web,e2e-angular-extensions,e2e-angular-core,e2e-nx-plugin,e2e-cypress,e2e-node,e2e-linter,e2e-jest,e2e-add-nx-to-monorepo,nx-dev-e2e,e2e-nx-init,e2e-graph-client --parallel=1;
|
|
else
|
|
echo "Skipping E2E tests";
|
|
fi
|
|
no_output_timeout: 45m
|
|
|
|
# -------------------------
|
|
# WORKFLOWS(JOBS)
|
|
# -------------------------
|
|
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'
|
|
- main-linux
|
|
- mainmacos:
|
|
name: main-macos-e2e
|