version: 2
jobs:
  build:
    working_directory: ~/kszkepzes
    docker:
      - image: circleci/python:3.6.4
    steps:
      - checkout
      - run: sudo chown -R circleci:circleci /usr/local/bin
      - run: sudo chown -R circleci:circleci /usr/local/lib/python3.6/site-packages
      - restore_cache:
          key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
      - run:
          command: |
            sudo pip install -r requirements/development.txt
      - save_cache:
          key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
          paths:
            - ".venv"
            - "/usr/local/bin"
            - "/usr/local/lib/python3.6/site-packages"
      - run:
          command: |
            flake8 --max-line-length=125 --exclude=src/kszkepzes,migrations
            python src/manage.py migrate
            python src/manage.py test
      - store_test_results:
          path: test-results
      - store_artifacts:
          path: test-results
          destination: tr1