language: python
stages:
  - name: test
  - name: deploy
    if: tag is present
cache: pip
before_script:
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
  - chmod +x ./cc-test-reporter
  - ./cc-test-reporter before-build
  - pip install -r requirements.txt
  - pip install pytest coverage pytest-cov
after_script:
  - coverage xml
  - coverage report
  - ./cc-test-reporter after-build -t coverage.py --exit-code ${TRAVIS_TEST_RESULT}
jobs:
  include:
    - stage: test
      python: "pypy3.5"
      script:
        - python setup.py install
        - pytest
      after_script:
        - echo "Do nothing"
    - stage: test
      python: "3.8"
      script:
        - DEBUG=1 python setup.py install
        - pytest --cov=./ --cov-report=xml
    - stage: test
      python: "3.5"
      script:
        - DEBUG=1 python setup.py install
        - pytest --cov=./ --cov-report=xml
    - stage: test
      python: "3.6"
      script:
        - DEBUG=1 python setup.py install
        - pytest --cov=./ --cov-report=xml
    - stage: test
      python: "3.7"
      script:
        - DEBUG=1 python setup.py install
        - pytest --cov=./ --cov-report=xml
    - stage: test
      python: "3.9"
      script:
        - DEBUG=1 python setup.py install
        - pytest --cov=./ --cov-report=xml
    - stage: deploy
      python: "3.8"
      before_script:
        - sudo apt-get update
        - sudo apt-get install -y patchelf
        - pip install wheel auditwheel twine doctor-wheel cython
      script:
        - python setup.py bdist_wheel
        - cd dist
        - doctor-wheel *.whl
        - auditwheel repair --plat manylinux2014_x86_64 *.whl
        - cd wheelhouse
        - twine upload -u $PYPI_USER -p $PYPI_PWD *.whl
      after_script:
        - echo "Done"
    - stage: deploy
      python: "3.9"
      before_script:
        - sudo apt-get update
        - sudo apt-get install -y patchelf
        - pip install wheel auditwheel twine doctor-wheel cython
      script:
        - python setup.py bdist_wheel
        - cd dist
        - doctor-wheel *.whl
        - auditwheel repair --plat manylinux2014_x86_64 *.whl
        - cd wheelhouse
        - twine upload -u $PYPI_USER -p $PYPI_PWD *.whl
      after_script:
        - echo "Done"
    - stage: deploy
      python: "3.7"
      before_script:
        - sudo apt-get update
        - sudo apt-get install -y patchelf
        - pip install wheel auditwheel twine doctor-wheel cython
      script:
        - python setup.py bdist_wheel
        - cd dist
        - doctor-wheel *.whl
        - auditwheel repair --plat manylinux2014_x86_64 *.whl
        - cd wheelhouse
        - twine upload -u $PYPI_USER -p $PYPI_PWD *.whl
      after_script:
        - echo "Done"
    - stage: deploy
      python: "3.6"
      before_script:
        - sudo apt-get update
        - sudo apt-get install -y patchelf
        - pip install wheel auditwheel twine doctor-wheel cython
      script:
        - python setup.py bdist_wheel
        - cd dist
        - doctor-wheel *.whl
        - auditwheel repair --plat manylinux2014_x86_64 *.whl
        - cd wheelhouse
        - twine upload -u $PYPI_USER -p $PYPI_PWD *.whl
      after_script:
        - echo "Done"
    - stage: deploy
      python: "3.5"
      before_script:
        - sudo apt-get update
        - sudo apt-get install -y patchelf
        - pip install wheel auditwheel twine doctor-wheel cython
      script:
        - python setup.py bdist_wheel
        - cd dist
        - doctor-wheel *.whl
        - auditwheel repair --plat manylinux2014_x86_64 *.whl
        - cd wheelhouse
        - twine upload -u $PYPI_USER -p $PYPI_PWD *.whl
      after_script:
        - echo "Done"
    - stage: deploy
      python: "pypy3.5"
      before_script:
        - sudo apt-get update
        - sudo apt-get install -y patchelf
        - pip install wheel auditwheel twine doctor-wheel cython
      script:
        - python setup.py bdist_wheel
        - cd dist
        - doctor-wheel *.whl
        - auditwheel repair --plat manylinux2014_x86_64 *.whl
        - cd wheelhouse
        - twine upload -u $PYPI_USER -p $PYPI_PWD *.whl
      after_script:
        - echo "Done"


