version: 2.1

workflows:
  main:
    jobs:
      - unit-tests
      - build-docs:
          filters:
            branches:
              only:
                - master

jobs:
  build-docs:
    docker:
      - image: circleci/python:latest
    steps:
      - add_ssh_keys:
          fingerprints:
            - "0d:4c:70:90:eb:cd:33:d2:51:d7:7b:9a:d9:8d:67:0e"
      - checkout
      - run:
          command: |
            sudo pip install -r requirements.txt
            python -m docs.build
            git config user.email "workflow@circleci.com"
            git config user.name "CircleCI"
            git add docs
            git diff-index --quiet HEAD || git commit -m 'Automated README [ci skip]'
            git push origin master
          name: Building docs
  unit-tests:
    docker:
      - image: circleci/python:latest
    steps:
      - checkout
      - run:
          command: |
            sudo pip install -r requirements.txt
            sudo pip install pytest
            python -m pytest ./tests/unit
          name: Unit tests