.circleci/config.yml
version: 2
defaults: &defaults
docker:
- image: circleci/node:14.4.0
jobs:
dependencies:
<<: *defaults
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: Npm Install
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
paths:
- node_modules
- persist_to_workspace:
root: .
paths:
- node_modules/
lint:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Lint
command: npm run lint
build:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: .
- run: npm run build
- persist_to_workspace:
root: .
paths:
- dist/
test_pre:
<<: *defaults
steps:
- attach_workspace:
at: .
- run:
name: Download cc-test-reporter
command: |
mkdir -p tmp/
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
chmod +x ./tmp/cc-test-reporter
- persist_to_workspace:
root: .
paths:
- tmp/cc-test-reporter
test_post:
<<: *defaults
steps:
- attach_workspace:
at: .
- run:
name: Upload coverage results to Code Climate
command: |
tmp/cc-test-reporter sum-coverage tmp/coverage/codeclimate.*.json -p 1 -o tmp/coverage/codeclimate.total.json
CC_TEST_REPORTER_ID=$CODE_CLIMATE_REPORTER_ID tmp/cc-test-reporter upload-coverage -i tmp/coverage/codeclimate.total.json
test_unit:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Unit Tests
command: |
npm run test:unit:coverage
- run:
name: Code Climate Coverage
command: |
ls
ls tmp/
tmp/cc-test-reporter format-coverage -t lcov -o tmp/coverage/codeclimate.unit.json tests/reports/unit/coverage/lcov.info
- store_artifacts:
path: tests/reports/unit/junit.xml
prefix: tests
- store_artifacts:
path: tests/reports/unit/coverage
prefix: coverage
- store_test_results:
path: tests/reports/unit
- persist_to_workspace:
root: .
paths:
- tmp/coverage
# - run:
# name: Coveralls
# command: export COVERALLS_GIT_COMMIT=$CIRCLE_SHA1 && npm run coveralls < tests/reports/unit/coverage/lcov.info
test_int: #TODO - multiple node envs
<<: *defaults
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Integrations Tests
command: npm run test:int
- store_artifacts:
path: tests/reports/int/junit.xml
prefix: tests
- store_test_results:
path: tests/reports/int
release:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
- run:
name: Publish package
command: npm publish
workflows:
version: 2
build_and_test:
jobs:
- dependencies
- lint:
requires:
- dependencies
- build:
requires:
- lint
- test_pre
- test_unit:
requires:
- lint
- test_pre
- test_int:
requires:
- build
- test_pre
- test_post:
requires:
- test_unit
- test_int
release:
jobs:
- dependencies:
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- lint:
requires:
- dependencies
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- test_pre:
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- test_unit:
requires:
- lint
- test_pre
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- build:
requires:
- lint
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- test_int:
requires:
- build
- test_pre
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- test_post:
requires:
- test_unit
- test_int
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- release:
requires:
- test_unit
- test_int
- build
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/