Skip to content

Commit

Permalink
Update cirleci configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
tusbar committed May 26, 2021
1 parent f449d60 commit 0c03c43
Showing 1 changed file with 66 additions and 21 deletions.
87 changes: 66 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 2
version: 2.1

defaults:
workspace_root: &workspace_root
Expand All @@ -7,19 +7,54 @@ defaults:
nodejs_container: &nodejs_container
working_directory: *workspace_root
docker:
- image: circleci/node:12-stretch

- image: cimg/node:lts
attach_workspace: &attach_workspace
attach_workspace:
at: *workspace_root

restore_node_modules: &restore_node_modules
restore_cache:
name: Restore node_modules cache
keys:
- v2-amazon-ids-node-{{ .Branch }}-{{ checksum "yarn.lock" }}
- v2-amazon-ids-node-master-{{ checksum "yarn.lock" }}
- v2-amazon-ids-node-master-
commands:
restore-nodejs:
description: "Restore Node.js dependencies"
parameters:
key:
type: string
working_directory:
type: string
default: *workspace_root
default_branch:
type: string
default: master
steps:
- restore_cache:
name: Restore node_modules cache
keys:
- << parameters.key >>-nodejs-{{ .Branch }}-{{ checksum "<< parameters.working_directory >>/yarn.lock" }}
- << parameters.key >>-nodejs-<< parameters.default_branch >>-{{ checksum "<< parameters.working_directory >>/yarn.lock" }}
- << parameters.key >>-nodejs-<< parameters.default_branch >>-

install-nodejs:
description: "Install Node.js dependencies"
parameters:
key:
type: string
working_directory:
type: string
default: *workspace_root
steps:
- restore-nodejs:
key: << parameters.key >>
working_directory: << parameters.working_directory >>

- run:
name: Install dependencies
command: yarn --frozen-lockfile --non-interactive
working_directory: << parameters.working_directory >>

- save_cache:
name: Save node_modules cache
key: << parameters.key >>-nodejs-{{ .Branch }}-{{ checksum "<< parameters.working_directory >>/yarn.lock" }}
paths:
- << parameters.working_directory >>/node_modules

jobs:
checkout:
Expand All @@ -36,28 +71,34 @@ jobs:
<<: *nodejs_container
steps:
- *attach_workspace
- *restore_node_modules

- run:
name: Install dependencies
command: yarn --frozen-lockfile

- save_cache:
name: Save node_modules cache
key: v2-amazon-ids-node-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths:
- node_modules/
- install-nodejs:
key: v1-amazon-ids

lint:
<<: *nodejs_container
steps:
- *attach_workspace
- *restore_node_modules

- restore-nodejs:
key: v1-amazon-ids

- run:
name: Lint JavaScript
command: yarn xo

test:
<<: *nodejs_container
steps:
- *attach_workspace

- restore-nodejs:
key: v1-amazon-ids

- run:
name: Test
command: yarn test --ci

workflows:
version: 2

Expand All @@ -72,3 +113,7 @@ workflows:
- lint:
requires:
- install

- test:
requires:
- install

0 comments on commit 0c03c43

Please sign in to comment.