Use granular caching

This commit is contained in:
rschamp committed 2019-09-23 21:26:06 -04:00
1 parent 41296a9624
commit 2df4df0791
1 file changed
+62 -25
+62 -25
View File
@@ -1,12 +1,42 @@
version: 2.1
aliases:
- &persist
persist_to_workspace:
root: .
paths: .
- &restore
attach_workspace:
at: ~/repo
- &save_git_cache
save_cache:
paths:
- .git
key: v1-git-{{ .Revision }}
- &restore_git_cache
restore_cache:
keys:
- v1-git-{{ .Revision }}
- v1-git-
- &save_build_cache
save_cache:
paths:
- build
key: v1-build-{{ .Revision }}
- &restore_build_cache
restore_cache:
keys:
- v1-build-{{ .Revision }}
- &save_dist_cache
save_cache:
paths:
- dist
key: v1-dist-{{ .Revision }}
- &restore_dist_cache
restore_cache:
keys:
- v1-dist-{{ .Revision }}
- &save_npm_cache
save_cache:
paths:
- node_modules
key: v1-npm-{{ checksum "package-lock.json" }}
- &restore_npm_cache
restore_cache:
keys:
- v1-npm-{{ checksum "package-lock.json" }}
- &defaults
docker:
- image: circleci/node:8.16-browsers
@@ -16,21 +46,17 @@ jobs:
setup:
<<: *defaults
steps:
- restore_cache:
keys:
- v1-git-{{ .Revision }}
- v1-git-
- *restore_git_cache
- checkout
- save_cache:
paths:
- .git
key: v1-git-{{ .Revision }}
- *save_git_cache
- run: npm ci
- *persist
- *save_npm_cache
lint:
<<: *defaults
steps:
- *restore
- *restore_git_cache
- *restore_npm_cache
- checkout
- run:
name: Lint
command: npm run test:lint -- --quiet --output-file test-results/eslint/results.xml --format junit
@@ -41,7 +67,9 @@ jobs:
environment:
JEST_JUNIT_OUTPUT_NAME: results.xml
steps:
- *restore
- *restore_git_cache
- *restore_npm_cache
- checkout
- run:
name: Unit
environment:
@@ -57,21 +85,24 @@ jobs:
NODE_ENV: production
NODE_OPTIONS: --max-old-space-size=4000
steps:
- *restore
- *restore_git_cache
- *restore_npm_cache
- checkout
- run:
name: Build
command: npm run build
- *persist
- *save_build_cache
- *save_dist_cache
store_build:
<<: *defaults
steps:
- *restore
- *restore_build_cache
- store_artifacts:
path: build
store_dist:
<<: *defaults
steps:
- *restore
- *restore_dist_cache
- store_artifacts:
path: dist
integration:
@@ -79,7 +110,9 @@ jobs:
environment:
JEST_JUNIT_OUTPUT_NAME: results.txt
steps:
- *restore
- *restore_git_cache
- *restore_npm_cache
- checkout
- run:
name: Integration
environment:
@@ -93,7 +126,9 @@ jobs:
environment:
NODE_OPTIONS: --max-old-space-size=4000
steps:
- *restore
- *restore_git_cache
- *restore_dist_cache
- checkout
- run: |
echo export RELEASE_VERSION="0.1.0-prerelease.$(date +'%Y%m%d%H%M%S')" >> $BASH_ENV
echo export NPM_TAG=circlelatest >> $BASH_ENV
@@ -113,7 +148,9 @@ jobs:
deploy-gh-pages:
<<: *defaults
steps:
- *restore
- *restore_git_cache
- *restore_npm_cache
- checkout
- run: |
git config --global user.email $(git log --pretty=format:"%ae" -n1)
git config --global user.name $(git log --pretty=format:"%an" -n1)