Set up CircleCI (#4491)

master
Lucas Duailibe 2018-05-18 00:58:37 -03:00 committed by GitHub
parent 6d49a224c9
commit 507e4cd411
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 118 additions and 11 deletions

97
.circleci/config.yml Normal file
View File

@ -0,0 +1,97 @@
aliases:
# Cache management
- &restore_yarn_cache
restore_cache:
keys:
- v1-yarn-cache
- &save_yarn_cache
save_cache:
paths:
- ~/.cache/yarn
key: v1-yarn-cache
- &restore_deps_cache
restore_cache:
keys:
- v1-deps-cache-{{ checksum "yarn.lock" }}
- &save_deps_cache
save_cache:
paths:
- node_modules
key: v1-yarn-deps-{{ checksum "yarn.lock" }}
# Default
- &defaults
working_directory: ~/prettier
docker:
- image: circleci/node:9
version: 2
jobs:
# Install dependencies and cache everything
checkout_code:
<<: *defaults
steps:
- checkout
- *restore_yarn_cache
- *restore_deps_cache
- run: yarn install
- run: yarn check-deps
- *save_deps_cache
- *save_yarn_cache
- persist_to_workspace:
root: .
paths:
- .
# Create the production bundle and cache
build_prod:
<<: *defaults
environment:
NODE_ENV: production
steps:
- attach_workspace:
at: ~/prettier
- run: yarn build
- persist_to_workspace:
root: .
paths:
- dist
# Run tests on the production bundle
test_prod_node4:
<<: *defaults
docker:
- image: circleci/node:4
steps:
- attach_workspace:
at: ~/prettier
- run: yarn test:dist
# Run tests on the production bundle
test_prod_node9:
<<: *defaults
steps:
- attach_workspace:
at: ~/prettier
- run: yarn test:dist
workflows:
version: 2
branches:
only:
- master
prod:
jobs:
- checkout_code
- build_prod:
requires:
- checkout_code
- test_prod_node4:
requires:
- build_prod
- test_prod_node9:
requires:
- build_prod

View File

@ -1,28 +1,38 @@
---
language: node_js
node_js:
- 4
- stable
- node
- "4"
cache:
yarn: true
directories:
- node_modules
env:
- NODE_ENV=development
- NODE_ENV=production
global:
- NODE_ENV=development
matrix:
- JOB=test AST_COMPARE=1
matrix:
fast_finish: true
include:
- node_js: "node"
env: JOB=lint
install:
- NODE_ENV=development yarn install
- yarn install
before_script:
- yarn check-deps
- if [ "${NODE_ENV}" = "production" ]; then yarn build; fi
script:
- yarn lint
- yarn lint-docs
- if [ "${NODE_ENV}" = "production" ]; then yarn test:dist; fi
- if [ "${NODE_ENV}" = "development" ]; then AST_COMPARE=1 yarn test -- --runInBand; fi
- if [ "${NODE_ENV}" = "development" ]; then yarn codecov; fi
- if [ "${JOB}" = "lint" ]; then yarn lint && yarn lint-docs; fi
- if [ "${JOB}" = "test" ]; then yarn test --maxWorkers=4 --ci; fi
- if [ "${JOB}" = "test" ]; then yarn codecov; fi
branches:
only:
- master