.circleci/config.yml
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
defaults: &defaults
working_directory: ~/repo
docker:
# specify the version you desire here
- image: circleci/node:8
environment:
CC_TEST_REPORTER_ID: a9ab1a49ce83c61a51c08a1d737297decf5c39315e8361c71aa644a705e0d100
jobs:
build:
<<: *defaults
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- persist_to_workspace:
root: .
paths: node_modules
lint:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/repo
- run:
name: Eslint
command: yarn lint --format junit -o reports/eslint/js-lint-results.xml
- store_test_results:
path: reports
- store_artifacts:
path: reports
test:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/repo
- run:
name: Setup Code Climate test-reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- run:
name: Jest
environment:
JEST_JUNIT_OUTPUT: "reports/jest/js-test-results.xml"
command: |
./cc-test-reporter before-build
yarn test:coverage --ci
./cc-test-reporter format-coverage ./coverage/lcov.info -t lcov
./cc-test-reporter upload-coverage
- store_test_results:
path: reports
- store_artifacts:
path: reports
path: coverage
publish:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/repo
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run: npm publish
workflows:
version: 2
build-test:
jobs:
- build:
filters:
tags:
only: /.*/
- lint:
requires:
- build
filters:
tags:
only: /.*/
- test:
requires:
- build
filters:
tags:
only: /.*/
- publish:
requires:
- build
- lint
- test
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*/