language: python
sudo: false
python:
- 2.7
- 3.4
- 3.5
- pypy
before_install:
  - |
      if [ "$TRAVIS_PYTHON_VERSION" = "pypy" ]; then
        export PYENV_ROOT="$HOME/.pyenv"
        if [ -f "$PYENV_ROOT/bin/pyenv" ]; then
          cd "$PYENV_ROOT" && git pull
        else
          rm -rf "$PYENV_ROOT" && git clone --depth 1 https://github.com/yyuu/pyenv.git "$PYENV_ROOT"
        fi
        export PYPY_VERSION="4.0.1"
        "$PYENV_ROOT/bin/pyenv" install "pypy-$PYPY_VERSION"
        virtualenv --python="$PYENV_ROOT/versions/pypy-$PYPY_VERSION/bin/python" "$HOME/virtualenvs/pypy-$PYPY_VERSION"
        source "$HOME/virtualenvs/pypy-$PYPY_VERSION/bin/activate"
      fi
install:
- |
  if [ "$TEST_TYPE" = build ]; then
    pip install pytest==3.0.2 pytest-cov pytest-benchmark coveralls six pytest-django==2.9.1 mock django-filter
    pip install django==$DJANGO_VERSION
    pip install -e .
    python setup.py develop
  elif [ "$TEST_TYPE" = lint ]; then
    pip install flake8
  fi
script:
- |
  if [ "$TEST_TYPE" = lint ]; then
    echo "Checking Python code lint."
    flake8 graphene_django
    exit
  elif [ "$TEST_TYPE" = build ]; then
    py.test --cov=graphene_django graphene_django examples
  fi
after_success:
- |
  if [ "$TEST_TYPE" = build ]; then
      coveralls
  fi
env:
  matrix:
  - TEST_TYPE=build
matrix:
  fast_finish: true
  include:
  - python: '2.7'
    env: TEST_TYPE=build DJANGO_VERSION=1.6
  - python: '2.7'
    env: TEST_TYPE=build DJANGO_VERSION=1.7
  - python: '2.7'
    env: TEST_TYPE=build DJANGO_VERSION=1.8
  - python: '2.7'
    env: TEST_TYPE=build DJANGO_VERSION=1.9
  - python: '2.7'
    env: TEST_TYPE=lint