diff --git a/.travis.yml b/.travis.yml index 71cefbd618b..54b308f2efb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,49 +1,32 @@ -language: generic - -matrix: - include: - - os: linux - sudo: required - env: PYTHON_VERSION=python2 - - os: linux - sudo: required - env: PYTHON_VERSION=python3 - - os: osx - osx_image: xcode9.3beta - env: PYTHON_VERSION=python2 - - os: linux - sudo: required - env: PYTHON_VERSION=python2 ONNX_ML=1 - - os: linux - sudo: required - env: PYTHON_VERSION=python3 ONNX_ML=1 - - os: osx - osx_image: xcode9.3beta - env: PYTHON_VERSION=python2 ONNX_ML=1 - -env: - global: - - PB_VERSION=2.6.1 - -before_install: - - ./.travis/before_install.sh +os: linux +dist: trusty +sudo: required +language: python +python: + - "2.7" + - "3.6" + +addons: + apt: + packages: + - dos2unix install: - ./.travis/install.sh script: - - ./.travis/script.sh - -after_success: - - ./.travis/after_success.sh - -after_failure: - - ./.travis/after_failure.sh + - ./.travis/build.sh cache: - - timeout: 300 - directories: - - $BUILD_CCACHE_DIR - - $BUILD_NINJA_DIR + - $HOME/.build_cache - $HOME/.ccache - - $HOME/.cache/pb + +env: + global: + - PB_VERSION=2.6.1 + matrix: + - USE_NINJA=false + - USE_NINJA=true + - ONNX_ML=1 USE_NINJA=false + - ONNX_ML=1 USE_NINJA=true diff --git a/.travis/after_failure.sh b/.travis/after_failure.sh deleted file mode 100755 index 3a22393faf1..00000000000 --- a/.travis/after_failure.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -script_path=$(python -c "import os; import sys; print(os.path.realpath(sys.argv[1]))" "${BASH_SOURCE[0]}") -source "${script_path%/*}/setup.sh" diff --git a/.travis/after_success.sh b/.travis/after_success.sh deleted file mode 100755 index 3a22393faf1..00000000000 --- a/.travis/after_success.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -script_path=$(python -c "import os; import sys; print(os.path.realpath(sys.argv[1]))" "${BASH_SOURCE[0]}") -source "${script_path%/*}/setup.sh" diff --git a/.travis/before_install.sh b/.travis/before_install.sh deleted file mode 100755 index 1fe5bc74ce4..00000000000 --- a/.travis/before_install.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -# Don't source setup.sh here, because the virtualenv might not be set up yet - -export NUMCORES=`grep -c ^processor /proc/cpuinfo` -if [ ! -n "$NUMCORES" ]; then - export NUMCORES=`sysctl -n hw.ncpu` -fi -echo Using $NUMCORES cores - -# Install dependencies -if [ "$TRAVIS_OS_NAME" == "linux" ]; then - sudo apt-get update - APT_INSTALL_CMD='sudo apt-get install -y --no-install-recommends' - $APT_INSTALL_CMD dos2unix - - # Install protobuf - pb_dir="~/.cache/pb" - mkdir -p "$pb_dir" - wget -qO- "https://github.com/google/protobuf/releases/download/v${PB_VERSION}/protobuf-${PB_VERSION}.tar.gz" | tar -xz -C "$pb_dir" --strip-components 1 - ccache -z - cd "$pb_dir" && ./configure && make -j${NUMCORES} && make check && sudo make install && sudo ldconfig - ccache -s - - # Setup Python. - export PYTHON_DIR="/usr/bin" -elif [ "$TRAVIS_OS_NAME" == "osx" ]; then - brew install ccache protobuf - - # Setup Python. - export PYTHON_DIR="/usr/local/bin" - brew install ${PYTHON_VERSION} -else - echo Unknown OS: $TRAVIS_OS_NAME - exit 1 -fi - -# TODO consider using "python3.6 -m venv" -# which is recommended by python3.6 and may make some difference -pip install virtualenv -virtualenv -p "${PYTHON_DIR}/${PYTHON_VERSION}" "${HOME}/virtualenv" -source "${HOME}/virtualenv/bin/activate" -python --version - -pip install pytest-cov nbval - -if [[ $USE_NINJA == true ]]; then - pip install ninja -fi - -# Update all existing python packages -pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U diff --git a/.travis/script.sh b/.travis/build.sh similarity index 77% rename from .travis/script.sh rename to .travis/build.sh index cd638eb1f9c..7d1a5b01617 100755 --- a/.travis/script.sh +++ b/.travis/build.sh @@ -1,10 +1,16 @@ #!/bin/bash -script_path=$(python -c "import os; import sys; print(os.path.realpath(sys.argv[1]))" "${BASH_SOURCE[0]}") -source "${script_path%/*}/setup.sh" +scripts_dir=$(dirname $(readlink -e "${BASH_SOURCE[0]}")) +source "$scripts_dir/common"; onnx_dir="$PWD" +# install onnx +cd $onnx_dir +ccache -z +ONNX_NAMESPACE=ONNX_NAMESPACE_FOO_BAR_FOR_CI pip install -v . +ccache -s + # onnx tests cd $onnx_dir pip install pytest-cov nbval diff --git a/.travis/common b/.travis/common new file mode 100644 index 00000000000..55e94b61e1b --- /dev/null +++ b/.travis/common @@ -0,0 +1,14 @@ +set -ex + +die() { + echo >&2 "$@" + exit 1 +} + +workdir="$HOME/work" +mkdir -p "$workdir" +build_cache_dir="$HOME/.build_cache/pb-$PB_VERSION" +mkdir -p "$build_cache_dir" + +# setup ccache +export PATH="/usr/lib/ccache:$PATH" diff --git a/.travis/install.sh b/.travis/install.sh index 2d2d2574689..7d3bb400f72 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -1,6 +1,17 @@ #!/bin/bash -script_path=$(python -c "import os; import sys; print(os.path.realpath(sys.argv[1]))" "${BASH_SOURCE[0]}") -source "${script_path%/*}/setup.sh" +scripts_dir=$(dirname $(readlink -e "${BASH_SOURCE[0]}")) +source "$scripts_dir/common" -time ONNX_NAMESPACE=ONNX_NAMESPACE_FOO_BAR_FOR_CI pip install -v . +# install protobuf +pb_dir="$build_cache_dir/pb" +mkdir -p $pb_dir +wget -qO- "https://github.com/google/protobuf/releases/download/v$PB_VERSION/protobuf-$PB_VERSION.tar.gz" | tar -xvz -C "$pb_dir" --strip-components 1 +ccache -z +cd "$pb_dir" && ./configure && make && make check && sudo make install && sudo ldconfig +ccache -s + + +if [[ $USE_NINJA == true ]]; then + pip install ninja +fi diff --git a/.travis/setup.sh b/.travis/setup.sh deleted file mode 100644 index e756303fe2b..00000000000 --- a/.travis/setup.sh +++ /dev/null @@ -1,17 +0,0 @@ -set -ex - -export top_dir=$(dirname ${0%/*}) - -source "${HOME}/virtualenv/bin/activate" -python --version - -# setup ccache -if [ "$TRAVIS_OS_NAME" == "linux" ]; then - export PATH="/usr/lib/ccache:$PATH" -elif [ "$TRAVIS_OS_NAME" == "osx" ]; then - export PATH="/usr/local/opt/ccache/libexec:$PATH" -else - echo Unknown OS: $TRAVIS_OS_NAME - exit 1 -fi -ccache --max-size 1G