BeameryHQ/Ditto

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
# 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:
    - image: circleci/node:7.10

jobs:
  build:
    <<: *defaults
    environment:
      CC_TEST_REPORTER_ID: 571fde0d7c7a5c441d9d768838cf38cc2cb5f1b2b5a6396eb598c957fbd6ce09
    steps:
      - checkout

      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "package.json" }}
            - v1-dependencies-

      - run: npm install

      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}
  test:
    <<: *defaults
    steps:
      - 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: npm test

      - run:
          name: Run coverage
          command: |
              sudo npm install -g istanbul
              ./cc-test-reporter before-build
              npm run cover
              ./cc-test-reporter after-build --coverage-input-type lcov coverage/lcvo.info --exit-code $?
  deploy:
    <<: *defaults
    steps:
      - run:
          name: NPM Deploy
          command: |
              echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
              npm publish
workflows:
  version: 2
  untagged-build:
    jobs:
      - build
      - test
  tagged-build:
    jobs:
      - build
      - test
      - deploy:
          filters:
            tags:
              only: /^v.*/