|
|
|
@ -1,13 +1,26 @@ |
|
|
|
version: 2 |
|
|
|
# --- Constants --- # |
|
|
|
|
|
|
|
globals: |
|
|
|
images: |
|
|
|
node: &node cimg/node:lts |
|
|
|
postgres: &postgres circleci/postgres:9.6.5 |
|
|
|
caches: |
|
|
|
dependencies: &dependencies dependencies-{{ checksum "package.json" }} |
|
|
|
|
|
|
|
# --- Commands --- # |
|
|
|
|
|
|
|
commands: |
|
|
|
init: |
|
|
|
description: Setup the environment |
|
|
|
steps: |
|
|
|
- checkout |
|
|
|
- restore_cache: |
|
|
|
keys: |
|
|
|
- *dependencies |
|
|
|
|
|
|
|
# --- Jobs definitions --- # |
|
|
|
|
|
|
|
version: 2 |
|
|
|
jobs: |
|
|
|
build: &shared-config |
|
|
|
docker: |
|
|
|
@ -17,20 +30,18 @@ jobs: |
|
|
|
- checkout |
|
|
|
- restore_cache: |
|
|
|
keys: |
|
|
|
- dependencies-{{ checksum "package.json" }} |
|
|
|
- *dependencies |
|
|
|
# fallback to using the latest cache if no exact match is found |
|
|
|
- dependencies- |
|
|
|
- run: yarn install |
|
|
|
- save_cache: |
|
|
|
paths: |
|
|
|
- node_modules |
|
|
|
key: dependencies-{{ checksum "package.json" }} |
|
|
|
key: *dependencies |
|
|
|
test: |
|
|
|
<<: *shared-config |
|
|
|
steps: |
|
|
|
- checkout |
|
|
|
- restore_cache: |
|
|
|
key: dependencies-{{ checksum "package.json" }} |
|
|
|
- init |
|
|
|
- run: yarn test |
|
|
|
|
|
|
|
test-e2e: |
|
|
|
@ -43,16 +54,25 @@ jobs: |
|
|
|
POSTGRES_USER: postgres |
|
|
|
POSTGRES_PASSWORD: postgres |
|
|
|
steps: |
|
|
|
- checkout |
|
|
|
- restore_cache: |
|
|
|
keys: |
|
|
|
- dependencies-{{ checksum "package.json" }} |
|
|
|
- init |
|
|
|
- run: |
|
|
|
command: yarn test:e2e |
|
|
|
environment: |
|
|
|
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres |
|
|
|
|
|
|
|
lint: |
|
|
|
<<: *shared-config |
|
|
|
steps: |
|
|
|
- init |
|
|
|
- run: |
|
|
|
name: Check files format |
|
|
|
command: yarn format:check |
|
|
|
|
|
|
|
- run: |
|
|
|
name: Lint files |
|
|
|
command: yarn lint |
|
|
|
|
|
|
|
# --- Workflow definition --- # |
|
|
|
|
|
|
|
workflows: |
|
|
|
version: 2 |
|
|
|
@ -65,3 +85,6 @@ workflows: |
|
|
|
- test-e2e: |
|
|
|
requires: |
|
|
|
- build |
|
|
|
- lint: |
|
|
|
requires: |
|
|
|
- build |