Merge pull request #3302 from lightmare/travis

move some shell code from .travis.yml to separate script
This commit is contained in:
Artem Pavlenko 2016-02-24 12:04:41 +01:00
commit 04c2532a81
3 changed files with 135 additions and 49 deletions

View file

@ -52,6 +52,7 @@ matrix:
env: JOBS=8 COVERAGE=true HEAVY_JOBS=3 env: JOBS=8 COVERAGE=true HEAVY_JOBS=3
before_install: before_install:
- source scripts/travis-common.sh
- export PYTHONUSERBASE=$(pwd)/mason_packages/.link - export PYTHONUSERBASE=$(pwd)/mason_packages/.link
- export PATH=${PYTHONUSERBASE}/bin:${PATH} - export PATH=${PYTHONUSERBASE}/bin:${PATH}
- export COVERAGE=${COVERAGE:-false} - export COVERAGE=${COVERAGE:-false}
@ -59,57 +60,34 @@ before_install:
- export BENCH=${BENCH:-false} - export BENCH=${BENCH:-false}
- if [[ ${TRAVIS_BRANCH} != 'master' ]]; then export MASON_PUBLISH=false; fi - if [[ ${TRAVIS_BRANCH} != 'master' ]]; then export MASON_PUBLISH=false; fi
- if [[ ${TRAVIS_PULL_REQUEST} != 'false' ]]; then export MASON_PUBLISH=false; fi - if [[ ${TRAVIS_PULL_REQUEST} != 'false' ]]; then export MASON_PUBLISH=false; fi
- git submodule update --init --depth=10 || - git_submodule_update --init --depth=10
git submodule foreach 'test "$sha1" = "`git rev-parse HEAD`" ||
git ls-remote origin "refs/pull/*/head" |
while read hash ref; do
if test "$hash" = "$sha1"; then
git config --add remote.origin.fetch "+$ref:$ref";
fi
done'
- git submodule update --init --depth=10
install: install:
- if [[ $(uname -s) == 'Linux' ]]; then - on 'linux' export PYTHONPATH=${PYTHONUSERBASE}/lib/python2.7/site-packages
export PYTHONPATH=${PYTHONUSERBASE}/lib/python2.7/site-packages; - on 'osx' export PYTHONPATH=${PYTHONUSERBASE}/lib/python/site-packages
else - on 'osx' brew rm postgis --force
brew rm postgis --force; - on 'osx' brew install postgis --force
brew install postgis --force; - on 'osx' pg_ctl -w start -l postgres.log --pgdata /usr/local/var/postgres
pg_ctl -w start -l postgres.log --pgdata /usr/local/var/postgres; - on 'osx' createuser -s postgres
createuser -s postgres; - psql -c 'create database template_postgis;' -U postgres
export PYTHONPATH=${PYTHONUSERBASE}/lib/python/site-packages; - psql -c 'create extension postgis;' -d template_postgis -U postgres
fi - enabled ${COVERAGE} pip install --user cpp-coveralls
- psql -c 'create database template_postgis;' -U postgres;
- psql -c 'create extension postgis;' -d template_postgis -U postgres; before_script:
- if [[ ${COVERAGE} == true ]]; then - source bootstrap.sh
if [[ ! $(which pip) ]]; then easy_install --user pip && export PATH=/Users/travis/Library/Python/2.7/bin:${PATH}; fi; - commit_message_parse
pip install --user cpp-coveralls;
fi
script: script:
- source bootstrap.sh - export SCONSFLAGS='--debug=time'
- if [[ ${COVERAGE} == true ]]; then - configure BENCHMARK=${BENCH}
./configure PGSQL2SQLITE=False SVG2PNG=False SAMPLE_INPUT_PLUGINS=False SVG_RENDERER=False BENCHMARK=${BENCH} CUSTOM_LDFLAGS='--coverage' CUSTOM_CXXFLAGS='--coverage' CUSTOM_CFLAGS='--coverage' DEBUG=True; - make
elif [[ ${MASON_PUBLISH} == true ]]; then - make test
export MASON_NAME=mapnik; - enabled ${COVERAGE} coverage
export MASON_VERSION=latest; - enabled ${BENCH} make bench
export MASON_LIB_FILE=lib/libmapnik-wkt.a;
source ./.mason/mason.sh; after_success:
./configure BENCHMARK=${BENCH} PREFIX=${MASON_PREFIX} PATH_REPLACE='' MAPNIK_BUNDLED_SHARE_DIRECTORY=True RUNTIME_LINK='static'; - if enabled ${MASON_PUBLISH}; then
else ./mason_latest.sh build &&
./configure BENCHMARK=${BENCH}; ./mason_latest.sh link &&
fi
- SCONSFLAGS='--debug=time' make
- make test || TEST_RESULT=$?
- if [[ ${COVERAGE} == true ]]; then
./mason_packages/.link/bin/cpp-coveralls --build-root . --gcov-options '\-lp' --exclude mason_packages --exclude .sconf_temp --exclude benchmark --exclude deps --exclude scons --exclude test --exclude demo --exclude docs --exclude fonts --exclude utils > /dev/null;
fi
- if [[ ${BENCH} == True ]]; then
make bench;
fi
- if [[ ${TEST_RESULT:-0} != 0 ]]; then exit $TEST_RESULT ; fi;
- if [[ ${MASON_PUBLISH} == true ]]; then
./mason_latest.sh build;
./mason_latest.sh link;
./mason_latest.sh publish; ./mason_latest.sh publish;
fi fi

View file

@ -112,7 +112,6 @@ CPP_TESTS = True
PGSQL2SQLITE = True PGSQL2SQLITE = True
XMLPARSER = 'ptree' XMLPARSER = 'ptree'
SVG2PNG = True SVG2PNG = True
SAMPLE_INPUT_PLUGINS = True
" "
} }

109
scripts/travis-common.sh Normal file
View file

@ -0,0 +1,109 @@
#! /bin/bash
# enabled VALUE
# - if VALUE is empty or falsy, returns 1 (false)
# - otherwise returns 0 (true)
# enabled VALUE COMMAND ...
# - if VALUE is empty or falsy, returns 0 (true)
# - otherwise runs COMMAND and returns its result
enabled () {
local value="$1"; shift
case $value in
''|'0'|[Ff]alse|[Nn]o) test $# -ne 0;;
*) test $# -eq 0 || "$@";;
esac
}
# on NAME
# - if NAME == $TRAVIS_OS_NAME, returns 0 (true)
# - otherwise returns 1 (false)
# on NAME COMMAND ...
# - if NAME == $TRAVIS_OS_NAME, runs COMMAND and returns its result
# - otherwise returns 0 (true)
on () {
local name="$1"; shift
case $name in
$TRAVIS_OS_NAME) test $# -eq 0 || "$@";;
*) test $# -ne 0;;
esac
}
git_submodule_update () {
git submodule update "$@" && return
# failed, search pull requests for matching commits
git submodule foreach \
'
test "$sha1" = "`git rev-parse HEAD`" ||
git ls-remote origin "refs/pull/*/head" |
while read hash ref; do
if test "$hash" = "$sha1"; then
git config --add remote.origin.fetch "+$ref:$ref";
fi
done
'
# try again with added fetch refs
git submodule update "$@"
}
# install and call pip
pip () {
if ! which pip >/dev/null; then
easy_install --user pip && \
export PATH="$HOME/Library/Python/2.7/bin:$PATH"
fi
command pip "$@"
}
# commit_message_contains TEXT
# - returns 0 (true) if TEXT is found in commit message
# - case-insensitive, plain-text search, not regex
commit_message_contains () {
git log -1 --pretty='%B' "$TRAVIS_COMMIT" | grep -qiFe "$*"
}
commit_message_parse () {
if commit_message_contains '[skip tests]'; then
config_override "CPP_TESTS = False"
fi
if commit_message_contains '[skip utils]'; then
config_override "MAPNIK_INDEX = False"
config_override "MAPNIK_RENDER = False"
config_override "PGSQL2SQLITE = False"
config_override "SHAPEINDEX = False"
config_override "SVG2PNG = False"
fi
}
config_override () {
echo "Appending to config.py:" "$@"
echo "$@" >> ./config.py
}
configure () {
if enabled ${COVERAGE}; then
./configure "$@" PGSQL2SQLITE=False SVG2PNG=False SVG_RENDERER=False \
CUSTOM_LDFLAGS='--coverage' CUSTOM_CXXFLAGS='--coverage' \
CUSTOM_CFLAGS='--coverage' DEBUG=True
elif enabled ${MASON_PUBLISH}; then
export MASON_NAME=mapnik
export MASON_VERSION=latest
export MASON_LIB_FILE=lib/libmapnik-wkt.a
source ./.mason/mason.sh
./configure "$@" PREFIX=${MASON_PREFIX} \
PATH_REPLACE='' MAPNIK_BUNDLED_SHARE_DIRECTORY=True \
RUNTIME_LINK='static'
else
./configure "$@"
fi
# print final config values, sorted and indented
sort -sk1,1 ./config.py | sed -e 's/^/ /'
}
coverage () {
./mason_packages/.link/bin/cpp-coveralls \
--build-root . --gcov-options '\-lp' --exclude mason_packages \
--exclude .sconf_temp --exclude benchmark --exclude deps \
--exclude scons --exclude test --exclude demo --exclude docs \
--exclude fonts --exclude utils \
> /dev/null
}