version: 2 # use CircleCI 2.0
jobs: # a collection of steps
  build: # runs not using Workflows must have a `build` job as entry point
    working_directory: ~/blockstack-keychain # directory where steps will run
    docker: # run the steps with Docker
      - image: circleci/node:10.16.3
    steps: # a collection of executable commands
      - checkout # special step to check out source code to working directory
      - restore_cache: # special step to restore the dependency cache
          # Read about caching dependencies: https://circleci.com/docs/2.0/caching/
          key: yarn-packages-{{ checksum "package.json" }}
      - run:
          name: Install Dependencies
          command: yarn install --frozen-lockfile
      - save_cache: # special step to save the dependency cache
          key: yarn-packages-{{ checksum "package.json" }}
          paths:
            - ./.cache/yarn
      - run: # run tests
          name: test
          command: yarn test
      # - run: # run coverage report
      #     name: code-coverage
      #     command: './node_modules/.bin/nyc report --reporter=text-lcov'
      - run: # run lint
          name: lint
          command: yarn lint
      - run: # run lint
          name: type check
          command: yarn typecheck
      - run:
          name: depcheck
          command: yarn depcheck
      - run:
          name: coverage
          command: yarn codecov
      - store_artifacts: # special step to save test results as as artifact
          # Upload test summary for display in Artifacts: https://circleci.com/docs/2.0/artifacts/ 
          path: test-results.xml
          prefix: tests
      - store_test_results: # for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
          path: test-results.xml
      # See https://circleci.com/docs/2.0/deployment-integrations/ for deploy examples