redbadger/website-honestly

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
version: 2
jobs:
  build:
    docker:
      - image: redbadger/website-honestly-deploy:17

    steps:
      - checkout

      - restore_cache:
          keys:
            - node_modules-v7-{{ checksum "yarn.lock" }}

      - run:
          name: Install Node modules
          command: yarn install --frozen-lockfile

      - save_cache:
          key: node_modules-v7-{{ checksum "yarn.lock" }}
          paths:
            - ./node_modules

      - persist_to_workspace:
          root: .
          paths:
            - node_modules/

  validate_formatting:
    docker:
      - image: redbadger/website-honestly-deploy:17
    steps:
      - checkout

      - attach_workspace:
          at: .

      - run:
          name: Validate formatting
          command: make prettier-fail

  lint:
    docker:
      - image: redbadger/website-honestly-deploy:17
    steps:
      - checkout

      - attach_workspace:
          at: .

      - run:
          name: Lint code
          command: make lint

  validate_types:
    docker:
      - image: redbadger/website-honestly-deploy:17
    steps:
      - checkout

      - attach_workspace:
          at: .

      - run:
          name: Validate types
          command: make flow

  test:
    docker:
      - image: redbadger/website-honestly-deploy:17
    steps:
      - checkout

      - attach_workspace:
          at: .

      - run:
          name: Notify Code Climate of build
          command: /cc-test-reporter before-build

      - run:
          name: Run tests
          command: make test-coverage

      - run:
          name: Send test coverage
          command: /cc-test-reporter after-build --exit-code 1
          when: on_fail

      - run:
          name: Send test coverage
          command: /cc-test-reporter after-build --exit-code 0
          when: on_success

  preview:
    docker:
      - image: redbadger/website-honestly-deploy:17
    steps:
      - checkout

      - attach_workspace:
          at: .

      - run:
          name: Deploy branch
          command: ./bin/ci-deploy.sh create-commit-site

  deploy_staging:
    docker:
      - image: redbadger/website-honestly-deploy:17
    steps:
      - checkout

      - attach_workspace:
          at: .

      - run:
          name: Deploy to staging
          command: ./bin/ci-deploy.sh master-to-staging

  deploy_production:
    docker:
      - image: redbadger/website-honestly-deploy:17
    steps:
      - checkout

      - run:
          name: Install Node modules
          command: yarn install --frozen-lockfile

      - run:
          name: Deploy to production
          command: ./bin/ci-deploy.sh master-to-production

workflows:
  version: 2

  build_and_deploy:
    jobs:
      - build

      - validate_formatting:
          requires:
            - build

      - lint:
          requires:
            - build

      - validate_types:
          requires:
            - build

      - test:
          requires:
            - build

      - preview:
          requires:
            - build
            - validate_formatting
            - lint
            - validate_types
            - test
          filters:
            branches:
              only: /^(?!.*master).*$/ # all branches except master

      - deploy_staging:
          requires:
            - build
            - validate_formatting
            - lint
            - validate_types
            - test
          filters:
            branches:
              only: master