sudo: false language: python python: - "3.5" addons: apt: packages: - postgresql-contrib-9.5 postgresql: "9.5" env: global: - ETCDVERSION=2.3.2 ZKVERSION=3.4.6 CONSULVERSION=0.6.4 matrix: - TEST_SUITE="python setup.py" - DCS="etcd" TEST_SUITE="behave" - DCS="exhibitor" TEST_SUITE="behave" - DCS="consul" TEST_SUITE="behave" cache: directories: - $HOME/virtualenv/python2.7.9 - $HOME/virtualenv/python3.4.2 - $HOME/virtualenv/python3.5.2 install: - | set -e if [[ $TEST_SUITE == "behave" ]]; then if [[ $DCS == "consul" ]]; then curl -L https://releases.hashicorp.com/consul/${CONSULVERSION}/consul_${CONSULVERSION}_linux_amd64.zip \ | gunzip > consul chmod +x consul fi if [[ $DCS == "etcd" ]]; then curl -L https://github.com/coreos/etcd/releases/download/v${ETCDVERSION}/etcd-v${ETCDVERSION}-linux-amd64.tar.gz \ | tar xz -C . --strip=1 --wildcards --no-anchored etcd fi if [[ $DCS == "exhibitor" ]]; then curl -L http://www.apache.org/dist/zookeeper/zookeeper-${ZKVERSION}/zookeeper-${ZKVERSION}.tar.gz | tar xz mv zookeeper-${ZKVERSION}/conf/zoo_sample.cfg zookeeper-${ZKVERSION}/conf/zoo.cfg zookeeper-${ZKVERSION}/bin/zkServer.sh start # following lines are 'emulating' exhibitor REST API while true; do echo -e 'HTTP/1.0 200 OK\nContent-Type: application/json\n\n{"servers":["127.0.0.1"],"port":2181}' \ | nc -l 8181 &> /dev/null done& fi fi for pv in "2.7" "3.4" "3.5"; do source ~/virtualenv/python${pv}/bin/activate # explicitly install all needed python modules to cache them for p in '-r requirements.txt' 'behave codacy-coverage coverage coveralls flake8==2.6.0 mock>=2.0.0 pytest-cov pytest'; do pip install $p done done script: - | for pv in "2.7" "3.4" "3.5"; do source ~/virtualenv/python${pv}/bin/activate if [[ $TEST_SUITE == "behave" ]]; then if [[ $pv != "3.4" ]]; then echo Running acceptance tests using python${pv} if ! PATH=.:$PATH $TEST_SUITE; then # output all log files when tests are failing grep . features/output/*/*postgres?.* exit 1 fi fi else echo Running unit tests using python${pv} $TEST_SUITE test $TEST_SUITE flake8 fi done set +e after_success: - coveralls - if [[ $TEST_SUITE != "behave" ]]; then python-codacy-coverage -r coverage.xml; fi