bitranox/lib_detect_encoding

View on GitHub
.travis.yml

Summary

Maintainability
Test Coverage
language: python
group: travis_latest
dist: xenial
sudo: true

env:
    global:
        - github_master="git+https://github.com/${TRAVIS_REPO_SLUG}.git"
        - pip_command="pip"
        - python_command="python"
        - WINEDEBUG=fixme-all       # switch off wine fix me messages
        # pypi_password for rst_include
        # This works for sure - the Travis deploy is somehow buggy.
        # create the secret :
        # cd /<repository>
        # travis encrypt pypi_password=*****
        # copy and paste the encrypted password here
        # - secure: "....."

addons:
    apt:
        packages:
            - xvfb      # install xvfb virtual framebuffer - this we need for WINE
            - winbind   # needed for WINE

services:   # start services
  - xvfb    # is needed for WINE on headless installation


matrix:
    include:

    - os: windows
      language: sh
      name: "Windows Python 3.8"

      # oddly a secure password under env: global: causes that choco fails
      # so we need to put the option : filter_secrets: false
      # this can be a security issue, check that You dont leak secrets here !
      filter_secrets: false
      before_install:
          - git clone https://github.com/bitranox/lib_bash.git /usr/local/lib_bash
          - chmod -R 0755 /usr/local/lib_bash
          - chmod -R +x /usr/local/lib_bash/*.sh
          - /usr/local/lib_bash/lib_retry.sh retry choco install python3
          - export PATH="/c/Python38:/c/Python38/Scripts:$PATH"

    - os: linux
      language: python
      python: '3.5'

    - os: linux
      language: python
      python: '3.6'
      # we can do that also with env - but we dont want to show it on the travis build overview
      before_install:
          - export mypy_static_typecheck="True"
          - export build_docs="True"
          - export deploy_on_pypi="False"

    - os: linux
      language: python
      python: '3.7'

    - os: linux
      language: python
      python: '3.8'

    - os: linux
      language: python
      python: '3.8-dev'

    - os: linux
      language: python
      python: 'pypy3'

    - os: linux
      language: python
      name: "WINE stable 32 Bit Python 3.7, Windows XP"
      env:
          - WINEARCH="win32"
          - WINEPREFIX="${HOME}/wine/wine32"
          - CMDPREFIX="wine"
          - wine_windows_version="winxp"
          - wine_release="stable"
          - wine_python_version="python3"

    - os: linux
      language: python
      name: "WINE stable 64 Bit Python 3.7, Windows XP"
      env:
          - WINEPREFIX="${HOME}/wine/wine64"
          - CMDPREFIX="wine"
          - wine_windows_version="winxp"
          - wine_release="stable"
          - wine_python_version="python3"

    - os: linux
      language: python
      name: "WINE stable 32 Bit Python 3.7, Windows 10"
      env:
          - WINEARCH="win32"
          - WINEPREFIX="${HOME}/wine/wine32"
          - CMDPREFIX="wine"
          - wine_windows_version="win10"
          - wine_release="stable"
          - wine_python_version="python3"

    - os: linux
      language: python
      name: "WINE stable 64 Bit Python 3.7, Windows 10"
      env:
          - WINEPREFIX="${HOME}/wine/wine64"
          - CMDPREFIX="wine"
          - wine_windows_version="win10"
          - wine_release="stable"
          - wine_python_version="python3"

    - os: linux
      language: python
      name: "WINE devel 32 Bit Python 3.7, Windows XP"
      env:
          - WINEARCH="win32"
          - WINEPREFIX="${HOME}/wine/wine32"
          - CMDPREFIX="wine"
          - wine_windows_version="winxp"
          - wine_release="devel"
          - wine_python_version="python3"

    - os: linux
      language: python
      name: "WINE devel 64 Bit Python 3.7, Windows XP"
      env:
          - WINEPREFIX="${HOME}/wine/wine64"
          - CMDPREFIX="wine"
          - wine_windows_version="winxp"
          - wine_release="devel"
          - wine_python_version="python3"

    - os: linux
      language: python
      name: "WINE devel 32 Bit Python 3.7, Windows 10"
      env:
          - WINEARCH="win32"
          - WINEPREFIX="${HOME}/wine/wine32"
          - CMDPREFIX="wine"
          - wine_windows_version="win10"
          - wine_release="devel"
          - wine_python_version="python3"

    - os: linux
      language: python
      name: "WINE devel 64 Bit Python 3.7, Windows 10"
      env:
          - WINEPREFIX="${HOME}/wine/wine64"
          - CMDPREFIX="wine"
          - wine_windows_version="win10"
          - wine_release="devel"
          - wine_python_version="python3"

    - os: linux
      language: python
      name: "WINE staging 32 Bit Python 3.7, Windows XP"
      env:
          - WINEARCH="win32"
          - WINEPREFIX="${HOME}/wine/wine32"
          - CMDPREFIX="wine"
          - wine_windows_version="winxp"
          - wine_release="staging"
          - wine_python_version="python3"

    - os: linux
      language: python
      name: "WINE staging 64 Bit Python 3.7, Windows XP"
      env:
          - WINEPREFIX="${HOME}/wine/wine64"
          - CMDPREFIX="wine"
          - wine_windows_version="winxp"
          - wine_release="staging"
          - wine_python_version="python3"

    - os: linux
      language: python
      name: "WINE staging 32 Bit Python 3.7, Windows 10"
      env:
          - WINEARCH="win32"
          - WINEPREFIX="${HOME}/wine/wine32"
          - CMDPREFIX="wine"
          - wine_windows_version="win10"
          - wine_release="staging"
          - wine_python_version="python3"

    - os: linux
      language: python
      name: "WINE staging 64 Bit Python 3.7, Windows 10"
      env:
          - WINEPREFIX="${HOME}/wine/wine64"
          - CMDPREFIX="wine"
          - wine_windows_version="win10"
          - wine_release="staging"
          - wine_python_version="python3"

    - os: osx
      language: sh
      name: "osX Python 3.8"
      python: "3.8"
      osx_image: xcode11
      env:
        # on osx pip and python points to python 2.7 - therefore we have to use pip3 and python3 here
        - pip_command="pip3"
        - python_command="python3"


install:
    - ${pip_command} install git+https://github.com/bitranox/lib_log_utils.git;
    - ${pip_command} install git+https://github.com/bitranox/rst_include.git;
    # install lib_bash_wine - this installs also lib_bash
    - $(command -v sudo 2>/dev/null) git clone https://github.com/bitranox/lib_bash_wine.git /usr/local/lib_bash_wine
    - $(command -v sudo 2>/dev/null) chmod -R 0755 /usr/local/lib_bash_wine
    - $(command -v sudo 2>/dev/null) chmod -R +x /usr/local/lib_bash_wine/*.sh
    - $(command -v sudo 2>/dev/null) /usr/local/lib_bash_wine/install_or_update.sh
    - export lib_bash_color="/usr/local/lib_bash/lib_color.sh"
    - export lib_bash_banner="/usr/local/lib_bash/lib_helpers.sh banner"
    - export lib_bash_banner_warning="/usr/local/lib_bash/lib_helpers.sh banner_warning"
    - export lib_bash_wine="/usr/local/lib_bash_wine"

    - export REPOSITORY_NAME=${TRAVIS_REPO_SLUG#*/} && ${lib_bash_color} clr_bold clr_green "Export Repository Name ${REPOSITORY_NAME}"
    - if [[ ${CMDPREFIX} == "wine" ]]; then ${lib_bash_wine}/001_000_install_wine.sh ; fi
    - if [[ ${CMDPREFIX} == "wine" ]]; then ${lib_bash_wine}/002_000_install_wine_machine.sh ; fi
    - if [[ ${wine_python_version} == "python3" ]]; then ${lib_bash_wine}/003_000_install_wine_python3_preinstalled.sh ; fi
    - if [[ ${CMDPREFIX} == "wine" ]]; then ${lib_bash_wine}/004_000_install_wine_git_portable.sh ; fi
    - if [[ ${CMDPREFIX} == "wine" ]]; then ${lib_bash_wine}/005_000_install_wine_powershell_core.sh ; fi

    - ${lib_bash_banner} "upgrading pip"; ${CMDPREFIX} ${python_command} -m pip install --upgrade pip

    - if [[ ${build_docs} == "True" ]]; then
          ${lib_bash_banner} "install rst_include (Building Docs)";
          ${CMDPREFIX} ${pip_command} install git+https://github.com/bitranox/rst_include.git;
      fi

    - if [[ -f ./setup.py ]]; then
          ${lib_bash_banner} "setup.py found, Installing Application via pip install -e";
          ${CMDPREFIX} ${pip_command} install -e . ;
              if [[ $? -eq 0 ]]; then
                  ${lib_bash_banner} "pip install -e - OK";
              else
                  ${lib_bash_banner_warning} "pip install -e - FAILED";
                  exit 1;
              fi

      else
          ${lib_bash_banner_warning} "no setup.py found, skipping Installation";
      fi

script:
    - if [[ -f ./setup.py ]]; then
          ${lib_bash_banner} "Installing Pytest requirements";
          ${CMDPREFIX} ${pip_command} install -r ./requirements_pytest.txt;
          ${CMDPREFIX} ${pip_command} install codecov;
          ${CMDPREFIX} ${pip_command} install pytest-cov;

          ${lib_bash_banner} "running setup.py test";
          ${CMDPREFIX} ${python_command} ./setup.py test;
              if [[ $? -eq 0 ]]; then
                  ${lib_bash_banner} "setup.py test - OK";
              else
                  ${lib_bash_banner_warning} "setup.py test - FAILED";
                  exit 1;
              fi

          ${lib_bash_banner} "running pip install --upgrade";
          ${CMDPREFIX} ${pip_command} install ${github_master} --upgrade;
              if [[ $? -eq 0 ]]; then
                  ${lib_bash_banner} "pip install --upgrade - OK";
              else
                  ${lib_bash_banner_warning} "pip install --upgrade - FAILED";
                  exit 1;
              fi

          ${lib_bash_banner} "running pytest";
          ${CMDPREFIX} ${python_command} -m pytest --cov;
              if [[ $? -eq 0 ]]; then
                  ${lib_bash_banner} "pytest - OK";
              else
                  ${lib_bash_banner_warning} "pytest - FAILED";
                  exit 1;
              fi

          if [[ ${mypy_static_typecheck} == "True" ]]; then
              ${lib_bash_banner} "running mypy static typechecks --strict";
              ${CMDPREFIX} ${python_command} -m mypy -p ${REPOSITORY_NAME} --strict --no-warn-unused-ignores;
                  if [[ $? -eq 0 ]]; then
                      ${lib_bash_banner} "mypy static typechecks --strict OK";
                  else
                      ${lib_bash_banner_warning} "mypy static typechecks --strict FAILED";
                      exit 1;
                  fi
          else
              ${lib_bash_banner_warning} "static typechecking disabled on this build";
          fi
      else
          ${lib_bash_banner_warning} "no setup.py found, skipping pip install with --install-option test";
          ${lib_bash_banner_warning} "no setup.py found, skipping pip install";
          ${lib_bash_banner_warning} "no setup.py found, skipping install pytest requirements";
          ${lib_bash_banner_warning} "no setup.py found, skipping pytest";
          ${lib_bash_banner_warning} "no setup.py found, skipping static typechecking";
      fi

    # Check Commandline Registration
    - if [[ ! -z ${commandline_registration_check} ]]; then
          ${lib_bash_banner} "Testing Commandline Registration";
          bash -c "${commandline_registration_check}";
          if [[ $? -eq 0 ]]; then
              ${lib_bash_banner} "Commandline Registration - OK";
          else
              ${lib_bash_banner_warning} "Commandline Registration - FAILED";
              exit 1;
          fi
      else
          ${lib_bash_banner_warning} "Commandline Registration Check disabled on this build";
      fi

    # Bild Docs
    - if [[ -f build_docs.py ]] && [[ "${build_docs}" == "True" ]]; then
          ${lib_bash_banner} "Building Docs";
          ${CMDPREFIX} ${python_command} build_docs.py ${TRAVIS_REPO_SLUG};
          if [[ $? -eq 0 ]]; then
              ${lib_bash_banner} "Building Docs OK";
          else
              ${lib_bash_banner_warning} "Building Docs FAILED";
              exit 1;
          fi
      else
          ${lib_bash_banner_warning} "Building Docs disabled on this build" ;
      fi

    # Check if Deployment would work on non-tagged builds
    - if [[ -f setup.py ]] && [[ -z ${TRAVIS_TAG} ]] && [[ -f build_docs.py ]] && [[ ${build_docs} == "True" ]]; then
          ${lib_bash_banner} "Testing PyPi Deployment";
          ${CMDPREFIX} ${pip_command} install readme_renderer > /dev/null 2>&1;
          ${CMDPREFIX} ${pip_command} install --upgrade twine > /dev/null 2>&1;
          ${CMDPREFIX} ${pip_command} install wheel > /dev/null 2>&1;
          ${CMDPREFIX} ${python_command} setup.py sdist bdist_wheel || ${lib_bash_banner_warning} "Building Wheels failed" 1>&2;
          ${CMDPREFIX} twine check dist/*;
              if [[ $? -eq 0 ]]; then
                  ${lib_bash_banner} "PyPi Deployment would be OK";
              else
                  ${lib_bash_banner_warning} "PyPi Deployment would fail";
                  exit 1;
              fi
      else
          ${lib_bash_banner_warning} "Check PyPi Deployment disabled on this build" ;
      fi

after_success:
    - ${CMDPREFIX} coverage report
    - ${CMDPREFIX} codecov

    # This works for sure - the Travis deploy is somehow buggy.
    # create the secret :
    # cd /<repository>
    # travis encrypt pypi_password=*****
    # and put it under :
    # env:
    #   global:
    #     -secure: *******
    - if [[ ${deploy_on_pypi} == "True" ]] && [[ -n ${TRAVIS_TAG} ]]; then
          ${lib_bash_banner} "Deploy on PyPi";
          export travis_deploy="True";
          ${CMDPREFIX} ${pip_command} install readme_renderer;
          ${CMDPREFIX} ${pip_command} install --upgrade twine;
          ${CMDPREFIX} ${pip_command} install wheel;
          ${CMDPREFIX} ${python_command} setup.py sdist bdist_wheel;
          ${CMDPREFIX} twine check dist/*;
          ${CMDPREFIX} twine upload --repository-url https://upload.pypi.org/legacy/ -u bitranox -p ${pypi_password} dist/*;
      fi


notifications:
  email:
    recipients:
        - rnowotny@rotek.at
    on_success: never # default: change
    on_failure: always # default: always