rescribet/link-lib

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
version: 2
defaults: &defaults
  docker:
    - image: circleci/node:13
  working_directory: ~/link-lib

jobs:
  build:
    <<: *defaults
    steps:
      - 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: tmp
          paths:
            - cc-test-reporter

  build-node-16:
    <<: *defaults
    docker:
      - image: circleci/node:16
    steps:
      - checkout
      - attach_workspace:
          at: ~/link-lib/tmp
      - restore_cache:
          keys:
            - v1-dependencies-16-{{ checksum "package.json" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-16-

      - run: yarn install

      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-16-{{ checksum "package.json" }}
      - run: yarn lint
      - run: yarn test -w 1
      - run: yarn build

  build-node-14:
    <<: *defaults
    docker:
      - image: circleci/node:14
    steps:
      - checkout
      - attach_workspace:
          at: ~/link-lib/tmp
      - restore_cache:
          keys:
            - v1-dependencies-14-{{ checksum "package.json" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-14-

      - run: yarn install

      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-14-{{ checksum "package.json" }}
      - run: yarn lint
      - run: yarn test -w 1
      - run: ./tmp/cc-test-reporter format-coverage -t lcov -o ~/link-lib/tmp/codeclimate.node-14.json coverage/lcov.info
      - run: yarn build
      - persist_to_workspace:
          root: tmp
          paths:
            - codeclimate.node-14.json

  build-node-12:
    <<: *defaults
    docker:
      - image: circleci/node:12
    steps:
      - checkout
      - restore_cache:
          keys:
            - v1-dependencies-12-{{ checksum "package.json" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-12-

      - run: yarn install

      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-12-{{ checksum "package.json" }}
      - run: yarn lint
      - run: yarn test -w 1
      - run: yarn build

  upload-coverage:
    <<: *defaults
    environment:
      CC_TEST_REPORTER_ID: f49a72b364886e0b9aae7a678c2fc1235276270cce13dc92f0b856f3438df624
    steps:
      - attach_workspace:
          at: ~/link-lib/tmp
      - run:
          name: Upload coverage results to Code Climate
          command: |
            ./tmp/cc-test-reporter sum-coverage tmp/codeclimate.*.json -p 1 -o tmp/codeclimate.total.json
            ./tmp/cc-test-reporter upload-coverage -i tmp/codeclimate.total.json

workflows:
  version: 2
  commit:
    jobs:
      - build
      - build-node-16
      - build-node-14:
          requires:
            - build
      - build-node-12
      - upload-coverage:
          requires:
            - build-node-14