瀏覽代碼

Comments, explanations and improvements for Travis CI builds

finefoot 5 年之前
父節點
當前提交
60d976ede8
共有 2 個文件被更改,包括 71 次插入56 次删除
  1. 13 17
      .travis.yml
  2. 58 39
      .travis/install.sh

+ 13 - 17
.travis.yml

@@ -7,19 +7,19 @@ cache:
 matrix:
     fast_finish: true
     include:
-        - python: 3.5
+        - python: "3.5"
           os: linux
           dist: trusty
           env: TOXENV=py35
-        - python: 3.6
+        - python: "3.6"
           os: linux
           dist: trusty
           env: TOXENV=py36
-        - python: 3.7
+        - python: "3.7"
           os: linux
           dist: xenial
           env: TOXENV=py37
-        - python: 3.8
+        - python: "3.8"
           os: linux
           dist: xenial
           env: TOXENV=py38
@@ -31,22 +31,22 @@ matrix:
           os: linux
           dist: xenial
           env: TOXENV=py38
-        - python: 3.5
+        - python: "3.5"
           os: linux
           dist: xenial
           env: TOXENV=flake8
         - language: generic
           os: osx
-          osx_image: xcode8.3
+          osx_image: xcode8.3  # This is the latest working xcode image with osxfuse compatibility; later images come with an OS X version which doesn't allow kernel extensions
           env: TOXENV=py35
         - language: generic
           os: osx
-          osx_image: xcode8.3
-          env: TOXENV=py37
+          osx_image: xcode11.3
+          env: TOXENV=py37 SKIPFUSE=true
     allow_failures:
-        - os: osx
+        - os: osx  # OS X builds often take too long and time out, even though tests don't actually fail
 
-before_install:
+before_install: # Abort installation and don't run tests for pull requests if commit only changed the docs
 - |
     test $TRAVIS_EVENT_TYPE != "pull_request" || {
         echo Checking whether $TRAVIS_COMMIT_RANGE changed only docs
@@ -56,15 +56,11 @@ before_install:
         }
     }
 
-install:
-    - git fetch --unshallow --tags
-    - ./.travis/install.sh
+install: ./.travis/install.sh
 
-script:
-    - ./.travis/run.sh
+script: ./.travis/run.sh
 
-after_success:
-    - ./.travis/upload_coverage.sh
+after_success: ./.travis/upload_coverage.sh
 
 notifications:
     irc:

+ 58 - 39
.travis/install.sh

@@ -3,54 +3,73 @@
 set -e
 set -x
 
-if [[ "$(uname -s)" == 'Darwin' ]]; then
-    export HOMEBREW_NO_AUTO_UPDATE=1
-    export HOMEBREW_LOGS=~/brew-logs
-    export HOMEBREW_TEMP=~/brew-temp
-    mkdir $HOMEBREW_LOGS
-    mkdir $HOMEBREW_TEMP
-    brew update > /dev/null
-    brew cleanup > /dev/null  # do this here, so it won't automatically trigger in the middle of other stuff
-    brew outdated pkg-config || brew upgrade pkg-config
-    # do NOT update openssl 1.0.x, brew will also update a lot of dependent pkgs (and their dependencies) then!
-    #brew outdated openssl || brew upgrade openssl
-    export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig:$PKG_CONFIG_PATH"
-    brew install readline
-    export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig:$PKG_CONFIG_PATH"
-    brew install zstd
-    brew install lz4
-    brew install xz  # required for python lzma module
-    brew install Caskroom/cask/osxfuse
-
-    brew outdated pyenv || brew upgrade pyenv
-    if which pyenv > /dev/null; then
-        eval "$(pyenv init -)"
-    fi
+# Travis clones with depth=50 which might be too shallow for git describe, see https://github.com/pypa/setuptools_scm/issues/93
+git fetch --unshallow --tags
+
+if [ "${TRAVIS_OS_NAME}" = "osx" ]
+then
+
+    # Update brew itself
+    export HOMEBREW_NO_AUTO_UPDATE=1  # Auto-updating everything would take too much time
+    brew update
+    brew cleanup  # Preempt possible scheduled clean-up so it doesn't clutter the log later
+
+    # Install and/or upgrade dependencies
+    #brew install zstd || brew upgrade zstd  # Installation takes very long due to CMake dependency and isn't necessary for the tests as borg comes bundled with zstd anyway
+    brew install lz4 || brew upgrade lz4
+    brew install xz || brew upgrade xz  # Required for Python lzma module
+    brew install Caskroom/cask/osxfuse || brew upgrade Caskroom/cask/osxfuse  # Required for Python llfuse module
+    brew install pyenv || brew upgrade pyenv
 
-    case "${TOXENV}" in
-        py35)
-            pyenv install 3.5.3  # minimum for openssl 1.1.x
-            pyenv global 3.5.3
-            ;;
-        py37)
-            pyenv install 3.7.0
-            pyenv global 3.7.0
-            ;;
-    esac
+    # Configure pkg-config to use OpenSSL 1.1 from Homebrew
+    export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig:${PKG_CONFIG_PATH}"
+
+    # Configure pyenv with Python version according to TOXENV
+    eval "$(pyenv init -)"
+    if [ "${TOXENV}" = "py35" ]
+    then
+        pyenv install 3.5.3  # Minimum version for OpenSSL 1.1.x
+        pyenv global 3.5.3
+    elif [ "${TOXENV}" = "py37" ]
+    then
+        pyenv install 3.7.0
+        pyenv global 3.7.0
+    else
+        printf '%s\n' "Unexpected value for TOXENV environment variable"
+        exit 1
+    fi
     pyenv rehash
-    python -m pip install --user virtualenv
-else
-    pip install virtualenv
+
+elif [ "${TRAVIS_OS_NAME}" = "linux" ]
+then
+
+    # Install dependencies
     sudo apt-get update
     sudo apt-get install -y pkg-config fakeroot
-    #sudo apt-get install -y liblz4-dev  # too old on trusty and xenial
-    #sudo apt-get install -y libzstd-dev  # too old on trusty and xenial
+    #sudo apt-get install -y liblz4-dev  # Too old on trusty and xenial, but might be useful in future versions
+    #sudo apt-get install -y libzstd-dev  # Too old on trusty and xenial, but might be useful in future versions
     sudo apt-get install -y libacl1-dev
-    sudo apt-get install -y libfuse-dev fuse  # optional, for FUSE support
+    sudo apt-get install -y libfuse-dev fuse  # Required for Python llfuse module
+
+else
+
+    printf '%s\n' "Unexpected value for TRAVIS_OS_NAME environment variable"
+    exit 1
+
 fi
 
+# Setup and activate virtual environment
+python -m pip install virtualenv
 python -m virtualenv ~/.venv
 source ~/.venv/bin/activate
+
+# Recent versions of OS X don't allow kernel extensions which makes the osxfuse tests fail; those versions are marked with SKIPFUSE=true in .travis.yml
+if [ "${SKIPFUSE}" = "true" ]
+then
+    truncate -s 0 requirements.d/fuse.txt
+fi
+
+# Install requirements
 pip install -r requirements.d/development.txt
 pip install codecov
 python setup.py --version