Skip to content

Commit

Permalink
Update travis setting (#981)
Browse files Browse the repository at this point in the history
* Update travis setting

* Update after failure script

* Fix lint

* Update comment

* Test bot

* Update ci script

* Update ci

* Test lint

* Update ci

* Check var

* Use log file

* Fix lint

* Check -f

* Lint

* Fix json

* Use vim script instead

* Fixup

* quit afte comment

* Update lint

* Fix lint

* Install gvim

* Remove file

* Install vim before test

* Fix lint

* Fix github api

* Use neovim report error

* Update travis

* Fix unkonwn command

* Use origin/dev

* Update lint

* Fix unkown command

* Fix lint

* Update config

* Fix lint

* Fix cache

* Fix cache

* Fix neovim install

* Fix neovim install

* Fix install

* Use dockerfile

* Fix lint

* Update install script

* Fix lint

* Fix type

* Fix alow faile

* Fix jobs

* Fix docker

* Fix docker

* Fix makefile

* Update commenter vim script
  • Loading branch information
wsdjeg committed Nov 22, 2017
1 parent 729d17a commit a830a3e
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 55 deletions.
35 changes: 35 additions & 0 deletions .ci/after_failure.sh
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

if [ "$TRAVIS_PULL_REQUEST" != "false" ] ; then
if [ "$LINT" = "vimlint-errors" ] ; then
if [[ -f build_log ]]; then
if [[ -d build/GitHub.vim ]]; then
rm -rf build/GitHub.vim
fi
VIMLINT_LOG=`cat build_log`
echo "$VIMLINT_LOG"
git clone https://github.com/wsdjeg/GitHub.vim.git build/GitHub.vim
docker run -it --rm \
-v $PWD/.ci:/.ci \
-v $PWD/build:/build \
spacevim/vims neovim-stable -u .ci/common/github_commenter.vim
rm build_log
fi
elif [ "$LINT" = "vint-errors" ] ; then
if [[ -f build_log ]]; then
if [[ -d build/GitHub.vim ]]; then
rm -rf build/GitHub.vim
fi
VIMLINT_LOG=`cat build_log`
echo "$VIMLINT_LOG"
git clone https://github.com/wsdjeg/GitHub.vim.git build/GitHub.vim
docker run -it --rm \
-v $PWD/.ci:/.ci \
-v $PWD/build:/build \
spacevim/vims neovim-stable -u .ci/common/github_commenter.vim
rm build_log
fi
elif [ "$LINT" = "vader" ] ; then
echo ""
fi
fi
Empty file added .ci/after_success.sh
Empty file.
48 changes: 48 additions & 0 deletions .ci/common/github_commenter.vim
@@ -0,0 +1,48 @@
exe 'set nocp'
set rtp+=build/GitHub.vim
so build/GitHub.vim/plugin/github.vim
so build/GitHub.vim/autoload/github/api/issues.vim
so build/GitHub.vim/autoload/github/api/util.vim
let s:log = filereadable('build_log') ? system('cat build_log') : ''
function! s:update_log(log, summary, new_log) abort
let log = split(a:log, "\n")
let begin = -1
let end = -1
for i in range(len(log))
if log[i] =~ a:summary
let begin = i
endif
if begin != -1 && log[i] ==# '</details>'
let end = i
endif
endfor
return a:log . "\n" . a:new_log

endfunction
if !empty(s:log)
if $LINT == 'vader'
let s:summary = $VIM . ' ' . $LINT . ' build log'
else
let s:summary = $LINT . ' build log'
endif
let s:log = '<details><summary>' . s:summary . "</summary>\n" . s:log . "\n</details>"
let s:comments = github#api#issues#List_comments('SpaceVim', 'SpaceVim',$TRAVIS_PULL_REQUEST ,'')
if empty(s:comments)
call github#api#issues#Create_comment('SpaceVim','SpaceVim', $TRAVIS_PULL_REQUEST, {'body': s:log}, 'SpaceVimBot', $BOTSECRET)
else
let s:nr = 0
for s:comment in s:comments
if s:comment.user.login ==# 'SpaceVimBot'
let s:nr = s:comment.id
break
endif
endfor
if s:nr == 0
call github#api#issues#Create_comment('SpaceVim','SpaceVim', $TRAVIS_PULL_REQUEST, {'body': s:log}, 'SpaceVimBot', $BOTSECRET)
else
call github#api#issues#Edit_comment('SpaceVim','SpaceVim', s:nr,
\ {'body': s:update_log(s:comment.body, s:summary, s:log)}, 'SpaceVimBot', $BOTSECRET)
endif
endif
endif
quit
Empty file modified .ci/install.ps1 100644 → 100755
Empty file.
20 changes: 20 additions & 0 deletions .ci/install.sh
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

# Fail on unset variables and command errors
set -ue -o pipefail

# Prevent commands misbehaving due to locale differences
export LC_ALL=C

docker pull spacevim/vims

git fetch origin dev:dev

if [ "${LINT#vimlint}" != "$LINT" ]; then
git clone --depth=1 https://github.com/syngan/vim-vimlint /tmp/vimlint
git clone --depth=1 https://github.com/ynkdir/vim-vimlparser /tmp/vimlparser
elif [ "${LINT#vint}" != "$LINT" ]; then
pip install vim-vint
elif [ "${LINT#vader}" != "$LINT" ]; then
git clone --depth=1 https://github.com/Shougo/dein.vim.git ~/.cache/vimfiles/repos/github.com/Shougo/dein.vim
fi
55 changes: 55 additions & 0 deletions .ci/install/linux.sh
@@ -0,0 +1,55 @@
install_vim() {
local URL=https://github.com/vim/vim
local tag=$1
local ext=$([[ $tag == "HEAD" ]] && echo "" || echo "-b $tag")
local tmp="$(mktemp -d)"
local out="$HOME/cache/vim-$tag"
local ncpu=$(awk '/^processor/{n+=1}END{print n}' /proc/cpuinfo)
git clone --depth 1 --single-branch $ext $URL $tmp
cd $tmp
./configure --prefix=$out \
--enable-fail-if-missing \
--with-features=huge \
--enable-pythoninterp \
--enable-python3interp \
--enable-luainterp
make -j$ncpu
make install
ln -s $out $HOME/vim
}

install_nvim() {
local URL=https://github.com/neovim/neovim
local tag=$1
local ext=$([[ $tag == "HEAD" ]] && echo "" || echo "-b $tag")
local tmp="$(mktemp -d)"
local out="$HOME/cache/nvim-$tag"
local ncpu=$(awk '/^processor/{n+=1}END{print n}' /proc/cpuinfo)
git clone --depth 1 --single-branch $ext $URL $tmp
cd $tmp
make deps
make -j$ncpu \
CMAKE_BUILD_TYPE=Release \
CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON -DCMAKE_INSTALL_PREFIX:PATH=$out"
make install
python -m pip install --user neovim
python3 -m pip install --user neovim
ln -sf $out $HOME/vim
}

install() {
local vim=$1
local tag=$2

[[ -d $HOME/vim ]] && rm -f $HOME/vim
if [[ $tag != "HEAD" ]] && [[ -d "$HOME/cache/$vim-$tag" ]]; then
echo "Use a cached version '$HOME/cache/$vim-$tag'."
ln -sf $HOME/cache/$vim-$tag $HOME/vim
return
fi
if [[ $vim == "nvim" ]]; then
install_nvim $tag
else
install_vim $tag
fi
}
32 changes: 32 additions & 0 deletions .ci/script.sh
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -ex
if [ "$LINT" = "vimlint" ]; then
for file in $(git diff --name-only HEAD dev | grep .vim$);
do
sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser $file;
done
elif [ "$LINT" = "vimlint-errors" ]; then
if [[ -f build_log ]]; then
rm build_log
fi
for file in $(git diff --name-only HEAD dev | grep .vim$);
do
/tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser $file >> build_log;
done
if [[ -f build_log ]]; then
cat build_log
exit 2
fi
elif [ "$LINT" = "vint" ]; then
vint .
elif [ "$LINT" = "vint-errors" ]; then
vint --error .
elif [ "$LINT" = "vader" ]; then
pip install covimerage
make test_coverage
covimerage -vv xml --omit 'build/*'
pip install codecov
codecov -X search gcov pycov -f coverage.xml
fi
set +x
78 changes: 25 additions & 53 deletions .travis.yml
@@ -1,6 +1,13 @@
language: python
dist: trusty
sudo: false

services:
- docker

git:
depth: 3

notifications:
slack:
on_success: never
Expand All @@ -9,62 +16,27 @@ notifications:
on_success: never # default: change
on_failure: never # default: always
cache:
pip: true
- directories:
- $HOME/cache/

env:
global:
- DEPS=$HOME/deps
- PATH=$DEPS/bin:$PATH
matrix:
- LINT=vimlint-errors
- LINT=vimlint
- LINT=vint-errors
- LINT=vint
- LINT=vader
- PATH=$HOME/vim/bin:$PATH

matrix:
jobs:
include:
- env: LINT=vimlint-errors VIM=nvim VIM_VERSION=v0.2.0
- env: LINT=vimlint VIM=nvim VIM_VERSION=v0.2.0
- env: LINT=vint-errors VIM=nvim VIM_VERSION=v0.2.0
- env: LINT=vint VIM=nvim VIM_VERSION=v0.2.0
- env: LINT=vader VIM=vim VIM_VERSION=v8.0.0027
- env: LINT=vader VIM=nvim VIM_VERSION=v0.2.0
allow_failures:
- env: LINT=vimlint
- env: LINT=vint
- env: LINT=vimlint VIM=nvim VIM_VERSION=v0.2.0
- env: LINT=vint VIM=nvim VIM_VERSION=v0.2.0


install:
- |
set -e
if [ "${LINT#vimlint}" != "$LINT" ]; then
git clone --depth=1 https://github.com/syngan/vim-vimlint /tmp/vimlint
git clone --depth=1 https://github.com/ynkdir/vim-vimlparser /tmp/vimlparser
elif [ "${LINT#vint}" != "$LINT" ]; then
virtualenv /tmp/vint && source /tmp/vint/bin/activate && pip install vim-vint
elif [ "${LINT#vader}" != "$LINT" ]; then
git clone --depth=1 https://github.com/Shougo/dein.vim.git ~/.cache/vimfiles/repos/github.com/Shougo/dein.vim
C_OPTS="--prefix=$DEPS --with-features=huge --disable-gui --enable-pythoninterp"
(git clone --depth 1 https://github.com/vim/vim /tmp/vim &&
cd /tmp/vim &&
./configure $C_OPTS &&
make install)
fi
script:
- |
set -ex
if [ "$LINT" = "vimlint" ]; then
for file in $(git diff --name-only HEAD dev | grep .vim$);
do
sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser $file;
done
elif [ "$LINT" = "vimlint-errors" ]; then
for file in $(git diff --name-only HEAD dev | grep .vim$);
do
sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser $file;
done
elif [ "$LINT" = "vint" ]; then
vint .
elif [ "$LINT" = "vint-errors" ]; then
vint --error .
elif [ "$LINT" = "vader" ]; then
pip install covimerage
make test_coverage
covimerage -vv xml --omit 'build/*'
pip install codecov
codecov -X search gcov pycov -f coverage.xml
fi
set +x
install: .ci/install.sh
script: .ci/script.sh
after_success: .ci/after_success.sh
after_failure: .ci/after_failure.sh
12 changes: 10 additions & 2 deletions Makefile
@@ -1,10 +1,18 @@
DOCKER = docker run -it --rm -v $(PWD):/testplugin -v $(PWD)/test:/test -v $(PWD)/build:/build "spacevim/vims"

ifeq ($(VIM),nvim)
DEFAULT_VIM:=$(DOCKER) neovim-stable
else
DEFAULT_VIM:=$(DOCKER) vim8
endif

test: build/vader | build
vim -Nu test/vimrc -c 'Vader! test/**'
$(DEFAULT_VIM) -Nu test/vimrc -c 'Vader! test/**'

COVIMERAGE=$(shell command -v ccovimerage 2>/dev/null || echo build/covimerage/bin/covimerage)

test_coverage: $(COVIMERAGE) build/vader | build
$(COVIMERAGE) run vim -Nu test/vimrc -c 'Vader! test/**'
$(COVIMERAGE) run $(DEFAULT_VIM) -Nu test/vimrc -c 'Vader! test/**'

build/covimerage:
virtualenv $@
Expand Down
8 changes: 8 additions & 0 deletions config/functions.vim
Expand Up @@ -204,3 +204,11 @@ fu! UpdateStarredRepos()
endfor
return 1
endf


function! TestBot(argv) abort
endfunction

function! TestBot(argv) abort

endfunction

0 comments on commit a830a3e

Please sign in to comment.