Move travis testing into docker for better consistency. (#950)

This now only tests python2 on Vim 7.4, 8.0 and git. No Neovim (that has been broken for a long time anyways) and no longer any python3 testing. But hey, we have green tests again!
This commit is contained in:
Holger Rapp 2018-04-01 00:56:34 +02:00 committed by GitHub
parent 3515cb6c13
commit 539c557680
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 149 additions and 127 deletions

View File

@ -1,24 +1,23 @@
language: python sudo: required
services: docker
# Cache intermediate Docker layers. For a description of how this works, see:
# https://giorgos.sealabs.net/docker-cache-on-travis-and-docker-112.html
cache:
directories:
- /home/travis/docker/
python:
- 2.7
- 3.3
- 3.4
env: env:
- VIM_VERSION="74" - VIM_VERSION="7.4" PYTHON_IMAGE=2.7-stretch TAG=vim_74_py2 DOCKER_CACHE_FILE=/home/travis/docker/vim_74_py2.tar.gz
- VIM_VERSION="git" - VIM_VERSION="8.0" PYTHON_IMAGE=2.7-stretch TAG=vim_80_py2 DOCKER_CACHE_FILE=/home/travis/docker/vim_80_py2.tar.gz
# - VIM_VERSION="NEOVIM" - VIM_VERSION="git" PYTHON_IMAGE=2.7-stretch TAG=vim_git_py2 DOCKER_CACHE_FILE=/home/travis/docker/vim_git_py2.tar.gz
install: install:
# Some of these commands fail transiently. We keep retrying them until they succeed. - docker build -t ultisnips:${TAG} --build-arg PYTHON_IMAGE=${PYTHON_IMAGE} --build-arg VIM_VERSION=${VIM_VERSION} .
- until sudo add-apt-repository ppa:kalakris/tmux -y; do sleep 10; done
- until sudo add-apt-repository ppa:neovim-ppa/unstable -y; do sleep 10; done
- until sudo apt-get update -qq; do sleep 10; done
- until sudo apt-get install -qq -y --force-yes tmux xclip gdb neovim git; do sleep 10; done
- ./travis_install.sh
script: script:
- ./travis_test.sh - docker run -it ultisnips:${TAG} scripts/run_tests.sh
- scripts/save_docker_cache.sh
notifications: notifications:
webhooks: webhooks:

27
Dockerfile Normal file
View File

@ -0,0 +1,27 @@
ARG PYTHON_IMAGE
FROM python:${PYTHON_IMAGE}
ARG VIM_VERSION
COPY scripts/install_packages.sh src/scripts/
RUN src/scripts/install_packages.sh
COPY scripts/download_vim.sh src/scripts/
RUN src/scripts/download_vim.sh
COPY scripts/build_vim.sh src/scripts/
RUN src/scripts/build_vim.sh
# We clone the plugins we currently depend on manually here. Initially we check if their master
# has changed since last time we build, this will invalidate the cache.
RUN mkdir -p /tmp/UltiSnips_test_vim_plugins
ADD https://api.github.com/repos/tpope/vim-pathogen/git/refs/heads/master \
/src/scripts/vim-pathogen_version.json
RUN git clone --recursive --depth 1 https://github.com/tpope/vim-pathogen /tmp/UltiSnips_test_vim_plugins/vim-pathogen
ADD https://api.github.com/repos/ervandew/supertab/git/refs/heads/master \
/src/scripts/supertab_version.json
RUN git clone --recursive --depth 1 https://github.com/ervandew/supertab /tmp/UltiSnips_test_vim_plugins/supertab
COPY . /src/UltiSnips
WORKDIR /src/UltiSnips

View File

@ -1,4 +1,4 @@
"""In memory representation of snippet definitions.""" """In memory representation of snippet definitions."""
from UltiSnips.snippet.definition.ultisnips import UltiSnipsSnippetDefinition from UltiSnips.snippet.definition.ulti_snips import UltiSnipsSnippetDefinition
from UltiSnips.snippet.definition.snipmate import SnipMateSnippetDefinition from UltiSnips.snippet.definition.snipmate import SnipMateSnippetDefinition

View File

@ -4,7 +4,7 @@
"""A UltiSnips snippet after parsing.""" """A UltiSnips snippet after parsing."""
from UltiSnips.snippet.definition._base import SnippetDefinition from UltiSnips.snippet.definition._base import SnippetDefinition
from UltiSnips.snippet.parsing.ultisnips import parse_and_instantiate from UltiSnips.snippet.parsing.ulti_snips import parse_and_instantiate
class UltiSnipsSnippetDefinition(SnippetDefinition): class UltiSnipsSnippetDefinition(SnippetDefinition):

View File

@ -6,5 +6,5 @@
from UltiSnips.snippet.source._base import SnippetSource from UltiSnips.snippet.source._base import SnippetSource
from UltiSnips.snippet.source.added import AddedSnippetsSource from UltiSnips.snippet.source.added import AddedSnippetsSource
from UltiSnips.snippet.source.file.snipmate import SnipMateFileSource from UltiSnips.snippet.source.file.snipmate import SnipMateFileSource
from UltiSnips.snippet.source.file.ultisnips import UltiSnipsFileSource, \ from UltiSnips.snippet.source.file.ulti_snips import UltiSnipsFileSource, \
find_all_snippet_files, find_snippet_files find_all_snippet_files, find_snippet_files

27
scripts/build_vim.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
set -o errexit
set -o verbose
cd /src/vim
if [[ $PYTHON_VERSION =~ ^2\. ]]; then
PYTHON_BUILD_CONFIG="--enable-pythoninterp"
else
PYTHON_BUILD_CONFIG="--enable-python3interp"
fi
export CFLAGS="$(python-config --cflags)"
echo $CFLAGS
./configure \
--prefix=${HOME} \
--disable-nls \
--disable-sysmouse \
--disable-gpm \
--enable-gui=no \
--enable-multibyte \
--with-features=huge \
--with-tlib=ncurses \
--without-x \
$PYTHON_BUILD_CONFIG || cat $(find . -name 'config.log')
make install

14
scripts/download_vim.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
set -o errexit
set -o verbose
mkdir -p /src && cd /src
if [[ $VIM_VERSION == "git" ]]; then
git clone https://github.com/vim/vim
else
curl http://ftp.vim.org/pub/vim/unix/vim-${VIM_VERSION}.tar.bz2 -o vim.tar.bz2
tar xjf vim.tar.bz2
mv -v vim?? vim
fi

11
scripts/install_packages.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
set -o errexit
set -o verbose
apt-get update
apt-get install -y \
g++ \
tmux \
git
apt-get clean

11
scripts/load_docker_cache.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
set -o errexit
set -o verbose
set -o pipefail
# See
# https://giorgos.sealabs.net/docker-cache-on-travis-and-docker-112.html
if [ -f ${DOCKER_CACHE_FILE} ]; then
gunzip -c ${DOCKER_CACHE_FILE} | docker load;
fi

23
scripts/run_tests.sh Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e
PYTHON_CMD="$(which python)"
INTERFACE="--interface tmux"
VIM="$HOME/bin/vim"
PYTHON_VERSION=$($PYTHON_CMD -c 'import sys;print(sys.version.split()[0])')
echo "Using python from: $PYTHON_CMD Version: $PYTHON_VERSION"
echo "Using vim from:"
$VIM --version | head -n 3
set -x
tmux new -d -s vim
$PYTHON_CMD ./test_all.py \
-v \
--plugins \
--session vim \
--vim $VIM \
$INTERFACE \
--expected-python-version $PYTHON_VERSION

14
scripts/save_docker_cache.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
set -o errexit
set -o verbose
set -o pipefail
# Cache intermediate Docker layers. For a description of how this works, see:
# https://giorgos.sealabs.net/docker-cache-on-travis-and-docker-112.html
if [[ ${TRAVIS_BRANCH} == "master" ]] && [[ ${TRAVIS_PULL_REQUEST} == "false" ]]; then
mkdir -p $(dirname ${DOCKER_CACHE_FILE})
IMAGE_NAMES=$(docker history -q ultisnips:${TAG} | grep -v '<missing>')
docker save ${IMAGE_NAMES} | gzip > ${DOCKER_CACHE_FILE}.new
mv ${DOCKER_CACHE_FILE}.new ${DOCKER_CACHE_FILE}
fi

View File

@ -93,6 +93,10 @@ class VimInterface(TempFileManager):
self._vim_executable = vim_executable self._vim_executable = vim_executable
self._version = None self._version = None
@property
def vim_executable(self):
return self._vim_executable
def has_version(self, major, minor, patchlevel): def has_version(self, major, minor, patchlevel):
if self._version is None: if self._version is None:
output = subprocess.check_output([ output = subprocess.check_output([

View File

@ -83,9 +83,8 @@ class VimTestCase(unittest.TestCase, TempFileManager):
os.symlink(source, os.path.join(absdir, os.path.basename(source))) os.symlink(source, os.path.join(absdir, os.path.basename(source)))
def setUp(self): def setUp(self):
# TODO(sirver): this uses 'vim', but must use --vim from the commandline.
if not VimTestCase.version: if not VimTestCase.version:
VimTestCase.version, _ = subprocess.Popen(['vim', '--version'], VimTestCase.version, _ = subprocess.Popen([self.vim.vim_executable, '--version'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
if PYTHON3: if PYTHON3:
VimTestCase.version = VimTestCase.version.decode('utf-8') VimTestCase.version = VimTestCase.version.decode('utf-8')

View File

@ -1,68 +0,0 @@
#!/usr/bin/env bash
# Installs a known version of vim in the travis test runner.
set -ex
PYTHON="python${TRAVIS_PYTHON_VERSION}"
build_vanilla_vim () {
mkdir ~/vim_build
pushd ~/vim_build
if [[ $VIM_VERSION == "74" ]]; then
until curl ftp://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz2 -o vim.tar.bz2; do sleep 10; done
tar xjf vim.tar.bz2
cd vim${VIM_VERSION}
elif [[ $VIM_VERSION == "git" ]]; then
git clone https://github.com/vim/vim
cd vim
fi
local PYTHON_CONFIG_DIR=$(dirname $(find $($PYTHON-config --prefix)/lib -iname 'config.c') | grep $TRAVIS_PYTHON_VERSION)
local PYTHON_BUILD_CONFIG=""
if [[ $TRAVIS_PYTHON_VERSION =~ ^2\. ]]; then
PYTHON_BUILD_CONFIG="--enable-pythoninterp --with-python-config-dir=${PYTHON_CONFIG_DIR}"
else
PYTHON_BUILD_CONFIG="--enable-python3interp --with-python3-config-dir=${PYTHON_CONFIG_DIR}"
fi
export LDFLAGS="$($PYTHON-config --ldflags) -L$($PYTHON-config --prefix)/lib"
export CFLAGS="$($PYTHON-config --cflags)"
# This is needed so that vim finds the shared libraries it was build against
# - they are not on the regular path.
export LD_LIBRARY_PATH="$($PYTHON-config --prefix)/lib"
echo $LDFLAGS
echo $CFLAGS
./configure \
--prefix=${HOME} \
--disable-nls \
--disable-sysmouse \
--disable-gpm \
--enable-gui=no \
--enable-multibyte \
--with-features=huge \
--with-tlib=ncurses \
--without-x \
${PYTHON_BUILD_CONFIG} || cat $(find . -name 'config.log')
make install
popd
rm -rf vim_build
}
if [[ $VIM_VERSION = "74" || $VIM_VERSION = "git" ]]; then
build_vanilla_vim
elif [[ $VIM_VERSION == "NEOVIM" ]]; then
PIP=$(which pip)
$PIP install neovim
else
echo "Unknown VIM_VERSION: $VIM_VERSION"
exit 1
fi
# Clone the dependent plugins we want to use.
PYTHON_CMD="$(which $PYTHON)"
$PYTHON_CMD ./test_all.py --clone-plugins

View File

@ -1,39 +0,0 @@
#!/usr/bin/env bash
set -ex
PYTHON="python${TRAVIS_PYTHON_VERSION}"
PYTHON_CMD="$(which ${PYTHON})"
if [[ $VIM_VERSION = "74" || $VIM_VERSION = "git" ]]; then
INTERFACE="--interface tmux"
VIM="${HOME}/bin/vim"
# This is needed so that vim finds the shared libraries it was build against -
# they are not on the regular path.
export LD_LIBRARY_PATH="$($PYTHON-config --prefix)/lib"
elif [[ $VIM_VERSION == "NEOVIM" ]]; then
VIM="$(which nvim)"
if [[ $TRAVIS_PYTHON_VERSION =~ ^2\. ]]; then
INTERFACE="--interface tmux_nvim --python-host-prog=$PYTHON_CMD"
else
INTERFACE="--interface tmux_nvim --python3-host-prog=$PYTHON_CMD"
fi
else
echo "Unknown VIM_VERSION: $VIM_VERSION"
exit 1
fi
PYTHON_VERSION=$($PYTHON_CMD -c 'import sys;print(sys.version.split()[0])')
echo "Using python from: $PYTHON_CMD Version: $PYTHON_VERSION"
echo "Using vim from: $VIM. Version: $($VIMn)"
tmux new -d -s vim
$PYTHON_CMD ./test_all.py \
-v \
--plugins \
--session vim \
--vim $VIM \
$INTERFACE \
--expected-python-version $PYTHON_VERSION