uktrade/directory-sso

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
version: 2
jobs:
  test:
    working_directory: ~/directory-sso
    docker:
      - image: cimg/python:3.9.13
      - image: cimg/postgres:16.2
        environment:
          POSTGRES_USER: debug
          POSTGRES_PASSWORD: debug
          POSTGRES_DB: sso_debug
      - image: cimg/redis:7.2.4
    steps:
      - checkout
      - setup_remote_docker:
          docker_layer_caching: true
      - restore_cache:
          key: v1-deps-{{ checksum "requirements_test.txt" }}
      - run:
          name: Create virtualenv and install dependencies
          command: |
            python3 -m venv venv
            . venv/bin/activate
            pip install --upgrade pip
            pip install -r requirements_test.txt
      - save_cache:
          key: v1-deps-{{ checksum "requirements_test.txt" }}
          paths:
            - "venv"
      - run:
          name: Install dockerize
          command: wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && sudo tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
          environment:
            DOCKERIZE_VERSION: v0.3.0
      - run:
          name: Wait for db
          command: dockerize -wait tcp://localhost:5432 -timeout 1m
      - run:
          name: Install psql
          command: |
            sudo apt-get update --allow-releaseinfo-change
            sudo apt-get install postgresql-client
      - run:
          name: Run tests
          command: |
            . venv/bin/activate
            make pytest_codecov -- --codecov-token=${CODECOV_TOKEN}
  flake8:
    docker:
      - image: cimg/python:3.9.13
    steps:
      - checkout
      - run:
          name: Run flake8
          command: |
            python3 -m venv venv
            . venv/bin/activate
            pip install flake8
            flake8
  black:
    docker:
      - image: cimg/python:3.9.13
    steps:
      - checkout
      - run:
          name: Run Black in check mode
          command: |
            python3 -m venv .venv
            . .venv/bin/activate
            pip install black
            black ./ --check

workflows:
  version: 2
  test_and_code_checks:
    jobs:
      - test
      - flake8
      - black