Skip to content

Commit

Permalink
chore(repo): cleanup & optimize circleci config (#6680)
Browse files Browse the repository at this point in the history
* chore(repo): optimize circleci config

* chore(repo): add package manager property to all jobs

* chore(repo): add more agents and fix config
  • Loading branch information
meeroslav committed Aug 11, 2021
1 parent 305c6a3 commit 9c676a3
Showing 1 changed file with 90 additions and 16 deletions.
106 changes: 90 additions & 16 deletions .circleci/config.yml
@@ -1,8 +1,14 @@
version: 2.1

# Variables
var_1: &working_directory ~/repo
# -------------------------
# ORBS
# -------------------------
orbs:
nx: nrwl/nx@1.0.0

# -------------------------
# DEFAULTS
# -------------------------
machine:
pre:
- mkdir ~/.cache/yarn
Expand All @@ -11,36 +17,51 @@ dependencies:
cache_directories:
- ~/.cache/yarn

orbs:
nx: nrwl/nx@1.0.0
defaults: &defaults
working_directory: ~/repo

# -------------------------
# EXECUTORS
# -------------------------
executors:
linux:
working_directory: *working_directory
<<: *defaults
docker:
- image: cimg/node:14.17-browsers

windows:
working_directory: *working_directory
<<: *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:
setup:
run-yarn:
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
- restore_cache:
name: Restore Yarn Package Cache
keys:
Expand All @@ -50,11 +71,15 @@ commands:
command: yarn install --prefer-offline --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

install-pnpm:
parameters:
os:
type: string
steps:
- when:
condition:
equal: [<< parameters.os >>, linux]
Expand All @@ -70,7 +95,32 @@ commands:
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 >>

# -------------------------
# JOBS
# -------------------------
jobs:
# -------------------------
# JOBS: Agent
# -------------------------
agent:
parameters:
os:
Expand Down Expand Up @@ -98,6 +148,10 @@ jobs:
name: Agent
command: npx nx-cloud start-agent
no_output_timeout: 60m

# -------------------------
# JOBS: Pull request
# -------------------------
pr-main:
parameters:
os:
Expand All @@ -113,6 +167,7 @@ jobs:
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 >>
steps:
- setup:
Expand Down Expand Up @@ -151,6 +206,10 @@ jobs:
- run:
name: Stop All Running Agents for This CI Run
command: npx nx-cloud stop-all-agents

# -------------------------
# JOBS: Commit on main
# -------------------------
trunk-main:
parameters:
os:
Expand All @@ -166,6 +225,7 @@ jobs:
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: 'true'
steps:
Expand All @@ -189,7 +249,13 @@ jobs:
- run:
name: Stop All Running Agents for This CI Run
command: npx nx-cloud stop-all-agents

# -------------------------
# WORKFLOWS
# -------------------------
workflows:
version: 2

build:
jobs:
- agent:
Expand All @@ -204,6 +270,14 @@ workflows:
name: 'agent5'
- agent:
name: 'agent6'
- agent:
name: 'agent7'
- agent:
name: 'agent8'
- agent:
name: 'agent9'
- agent:
name: 'agent10'
- pr-main:
filters:
branches:
Expand Down

1 comment on commit 9c676a3

@vercel
Copy link

@vercel vercel bot commented on 9c676a3 Aug 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.