sumcumo/vue-history

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
version: 2

defaults: &defaults
  working_directory: ~/repo
  docker:
    - image: circleci/node:lts

jobs:
  checkout-code:
    <<: *defaults
    steps:
      - checkout
      - persist_to_workspace:
          root: ~/repo
          paths:
            - ./
      - save_cache:
          key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
          paths:
            - ~/repo

  npm:
    <<: *defaults
    steps:
      - attach_workspace:
          at: ~/repo
      - restore_cache:
          keys:
            - v1-npm-{{ checksum "package-lock.json" }}
            - v1-npm-
      - run:
          name: Install
          command: npm ci
      - persist_to_workspace:
          root: ~/repo
          paths:
            - node_modules
      - save_cache:
          key: v1-npm-{{ checksum "package-lock.json" }}
          paths:
            - ~/repo/node_modules

  audit:
    <<: *defaults
    steps:
      - attach_workspace:
          at: ~/repo
      - run:
          name: Audit
          command: npm audit

  lint:
    <<: *defaults
    steps:
      - attach_workspace:
          at: ~/repo
      - run:
          name: Lint
          command: npm run lint

  test:
    <<: *defaults
    steps:
      - attach_workspace:
          at: ~/repo
      - run:
          name: Setup Code Climate test-reporter
          command: |
            # download test reporter as a static binary
                     curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
                     chmod +x ./cc-test-reporter
      - run:
          name: Run tests
          command: |
                     # notify Code Climate of a pending test report using `before-build`
                     ./cc-test-reporter before-build
                     npm run test.coverage
                     # upload test report to Code Climate using `after-build`
                     ./cc-test-reporter after-build --coverage-input-type lcov --exit-code $?

  build:
    <<: *defaults
    steps:
      - attach_workspace:
          at: ~/repo
      - run:
          name: Build from source
          command: npm run build

workflows:
  version: 2
  check:
    triggers:
      - schedule:
          cron: "0 20 * * *"
          filters:
            branches:
              only: master
    jobs:
      - checkout-code
      - npm:
          requires:
            - checkout-code
      - audit:
          requires:
            - npm

  main:
    jobs:
      - checkout-code
      - npm:
          requires:
            - checkout-code
      - audit:
          requires:
            - npm
      - lint:
          requires:
            - npm
      - test:
          requires:
            - npm
      - build:
          requires:
            - lint
            - audit