version: 2
jobs:
  build:
    working_directory: ~/project
    docker:
      - image: circleci/node:8-browsers
        environment:
          CHROME_BIN: "/usr/bin/google-chrome"
    steps:
      - checkout
      - run:
          name: update-npm 
          command: 'sudo npm install -g npm@latest'
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: install-npm
          command: npm install
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules
      - run:
          name: test
          command: npm test
      - run:
          name: upload coverage
          command: bash <(curl -s https://codecov.io/bash)
      - store_artifacts:
          path: dst
          destination: dst
      - store_artifacts:
          path: test-results.xml
          destination: tests
      - store_artifacts:
          path: coverage
          destination: coverage
      - store_test_results:
          path: ./build/test-results.xml
workflows:
  version: 2
  build:
    jobs:
      - build:
          # All branches, all tags.
          filters:
            tags:
              only: /.*/
