version: 2.1

jobs:
  build-and-test:
    docker:
      - image: circleci/python:3.7.9-stretch
      - image: circleci/postgres:9.6.5-alpine-ram

    steps:
      - checkout

      - restore_cache:
                key: deps1-{{ .Branch }}

      - run:
          name: "Run Tests - Postgres"
          environment:
            CI_DBT_HOST: localhost
            CI_DBT_USER: root
            CI_DBT_PASS: ''
            CI_DBT_PORT: 5432
            CI_DBT_DBNAME: circle_test
          command: bash ./run_test.sh postgres

      - save_cache:
          key: deps1-{{ .Branch }}
          paths:
            - "venv"

workflows:
  main:
    jobs:
      - build-and-test
