version: 2.1

orbs:
  codecov: codecov/codecov@1.0.4

workflows:
  version: 2
  test:
    jobs:
      - py27
      - py35
      - py37
      - black
      - flake8

jobs:
  py37: &test-template
    docker:
      - image: circleci/python:3.7
    steps:
      - checkout
      - run:
          name: Install test dependencies
          command: sudo pip install tox || pip install tox
      - restore_cache:
          name: Restoring tox cache
          keys:
            - tox-v1-{{ .Environment.CIRCLE_JOB }}-{{ .BuildNum }}
            - tox-v1-{{ .Environment.CIRCLE_JOB }}
      - run:
          name: Run tests
          command: |
            tox -e $CIRCLE_JOB -- \
              --junit-xml=test-results/pytest/results.xml \
              --cov-report=xml
      - save_cache:
          name: Saving tox cache
          key: tox-v1-{{ .Environment.CIRCLE_JOB }}-{{ .BuildNum }}
          paths:
            - ./.tox
            - ~/.cache/pip
      - codecov/upload:
          file: coverage.xml
      - store_test_results:
          path: test-results

  py27:
    <<: *test-template
    docker:
      - image: circleci/python:2.7

  py35:
    <<: *test-template
    docker:
      - image: circleci/python:3.5

  flake8: *test-template

  black: *test-template

version: 2.1

orbs:
  codecov: codecov/codecov@1.0.4

workflows:
  version: 2
  test:
    jobs:
      - py27
      - py37
      - py38
      - black
      - flake8

jobs:
  py38: &test-template
    docker:
      - image: circleci/python:3.8
    steps:
      - checkout
      - run:
          name: Install test dependencies
          command: sudo pip install tox || pip install tox
      - restore_cache:
          name: Restoring tox cache
          keys:
            - tox-v1-{{ .Environment.CIRCLE_JOB }}-{{ .BuildNum }}
            - tox-v1-{{ .Environment.CIRCLE_JOB }}
      - run:
          name: Run tests
          command: |
            tox -e $CIRCLE_JOB -- \
              --junit-xml=test-results/pytest/results.xml \
              --cov-report=xml
      - save_cache:
          name: Saving tox cache
          key: tox-v1-{{ .Environment.CIRCLE_JOB }}-{{ .BuildNum }}
          paths:
            - ./.tox
            - ~/.cache/pip
      - codecov/upload:
          file: coverage.xml
      - store_test_results:
          path: test-results

  py27:
    <<: *test-template
    docker:
      - image: circleci/python:2.7

  py37:
    <<: *test-template
    docker:
      - image: circleci/python:3.7

  flake8: *test-template

  black: *test-template

Test test on 2.7, 3.7 and 3.8 for CircleCI
Test test on 2.7, 3.7 and 3.8 for CircleCI
