version: 2

jobs:
  python2-test:
    docker:
      - image: "python:2.7-stretch"
    steps:
      - checkout
      - run: pip install -e .[all] .[test]
      - run: py.test -v test/
      - run: pylint pyls test
      - run: pycodestyle pyls test
      - run: pyflakes pyls test

  python3-test:
    docker:
      - image: "python:3.6-stretch"
    steps:
      - checkout
      # To test Jedi environments
      - run: python3 -m venv /tmp/pyenv
      - run: /tmp/pyenv/bin/python -m pip install loghub
      - run: pip install -e .[all] .[test]
      - run: py.test -v test/

  lint:
    docker:
    - image: "python:2.7-stretch"
    steps:
    - checkout
    - run: pip install -e .[all] .[test]
    - run: pylint pyls test
    - run: pycodestyle pyls test
    - run: pyflakes pyls test

  publish:
    docker:
      - image: "python:3.6-stretch"
    steps:
      - checkout
      - run: ./scripts/circle/pypi.sh


workflows:
  version: 2
  build:
    jobs:
      - python2-test:
          filters: { tags: { only: /.*/ } }
      - python3-test:
          filters: { tags: { only: /.*/ } }
      - publish:
          filters:
            tags:
              only: /[0-9]+(\.[0-9]+)+((-(beta|rc)[0-9]{1,2})(\.[0-9])?)?/
            branches:
              ignore: /.*/
          requires:
            - python2-test
            - python3-test
