Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 32 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,53 @@
version: 2
version: 2.1

defaults: &defaults
working_directory: ~/repo
docker:
- image: circleci/node:10.15.0
- image: cimg/node:14.19

_steps:
restore_npm_cache: &restore_npm_cache
restore_cache:
keys:
- npm-v1-{{ .Branch }}-{{ checksum "package-lock.json" }}
- npm-v1-{{ .Branch }}-
- npm-v1-
save_npm_cache: &save_npm_cache
save_cache:
paths:
- .npm-cache
key: npm-v1-{{ .Branch }}-{{ checksum "package-lock.json" }}
configure_registry_auth: &configure_registry_auth
run:
name: Configure registry auth
command: echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" >> ~/repo/.npmrc

jobs:
test_and_build:
test:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package-lock.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: npm ci
- *restore_npm_cache
- *configure_registry_auth
- run: npm ci --cache .npm-cache
- run:
name: Run coverage tests
command: npm run test:coverage
- run:
name: Build
name: Run build
command: npm run build
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package-lock.json" }}
- persist_to_workspace:
root: ~/repo
paths: .
- store_artifacts:
path: ~/repo/dist
- *save_npm_cache
deploy:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- run:
name: Configure registry auth
command: echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" >> ~/repo/.npmrc
- *configure_registry_auth
- run:
name: Publish package
# For now we only publish on tags here and assume the version number is already correct.
Expand All @@ -49,13 +58,17 @@ workflows:
version: 2
test-deploy:
jobs:
- test_and_build:
- test:
context:
- "NPM Read"
filters:
tags:
only: /^v.*/
- deploy:
context:
- "NPM Write"
requires:
- test_and_build
- test
filters:
tags:
only: /^v.*/
Expand Down