mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Optimize travis cache usage
This commit is contained in:
+37
-17
@@ -17,32 +17,48 @@ env:
|
|||||||
- DCS="consul" TEST_SUITE="behave"
|
- DCS="consul" TEST_SUITE="behave"
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- $HOME/virtualenv/python2.7.9
|
- $HOME/mycache
|
||||||
- $HOME/virtualenv/python3.4.2
|
before_cache:
|
||||||
- $HOME/virtualenv/python3.5.2
|
- mv $HOME/virtualenv/python2.7.9 $HOME/mycache/python2.7.9
|
||||||
|
- if [[ $TEST_SUITE != "behave" ]]; then mv $HOME/virtualenv/python3.4.2 $HOME/mycache/python3.4.2; fi
|
||||||
|
- mv $HOME/virtualenv/python3.5.2 $HOME/mycache/python3.5.2
|
||||||
|
- rm -f $HOME/mycache/python3.5.2/python3.5.2
|
||||||
install:
|
install:
|
||||||
- |
|
- |
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [[ $TEST_SUITE == "behave" ]]; then
|
if [[ $TEST_SUITE == "behave" ]]; then
|
||||||
function get_consul() {
|
function get_consul() {
|
||||||
|
CC=~/mycache/consul_${CONSULVERSION}
|
||||||
|
if [[ ! -x $CC ]]; then
|
||||||
curl -L https://releases.hashicorp.com/consul/${CONSULVERSION}/consul_${CONSULVERSION}_linux_amd64.zip \
|
curl -L https://releases.hashicorp.com/consul/${CONSULVERSION}/consul_${CONSULVERSION}_linux_amd64.zip \
|
||||||
| gunzip > consul
|
| gunzip > $CC
|
||||||
[[ ${PIPESTATUS[0]} == 0 ]] || return 1
|
[[ ${PIPESTATUS[0]} == 0 ]] || return 1
|
||||||
chmod +x consul
|
chmod +x $CC
|
||||||
|
fi
|
||||||
|
ln -s $CC consul
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_etcd() {
|
function get_etcd() {
|
||||||
|
EC=~/mycache/etcd_${ETCDVERSION}
|
||||||
|
if [[ ! -x $EC ]]; then
|
||||||
curl -L https://github.com/coreos/etcd/releases/download/v${ETCDVERSION}/etcd-v${ETCDVERSION}-linux-amd64.tar.gz \
|
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
|
| tar xz -C . --strip=1 --wildcards --no-anchored etcd
|
||||||
return ${PIPESTATUS[0]}
|
[[ ${PIPESTATUS[0]} == 0 ]] || return 1
|
||||||
|
mv etcd $EC
|
||||||
|
fi
|
||||||
|
ln -s $EC etcd
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_exhibitor() {
|
function get_exhibitor() {
|
||||||
|
ZC=~/mycache/zookeeper-${ZKVERSION}
|
||||||
|
if [[ ! -d $ZC ]]; then
|
||||||
curl -L http://www.apache.org/dist/zookeeper/zookeeper-${ZKVERSION}/zookeeper-${ZKVERSION}.tar.gz | tar xz
|
curl -L http://www.apache.org/dist/zookeeper/zookeeper-${ZKVERSION}/zookeeper-${ZKVERSION}.tar.gz | tar xz
|
||||||
[[ ${PIPESTATUS[0]} == 0 ]] || return 1
|
[[ ${PIPESTATUS[0]} == 0 ]] || return 1
|
||||||
mv zookeeper-${ZKVERSION}/conf/zoo_sample.cfg zookeeper-${ZKVERSION}/conf/zoo.cfg
|
mv zookeeper-${ZKVERSION}/conf/zoo_sample.cfg zookeeper-${ZKVERSION}/conf/zoo.cfg
|
||||||
zookeeper-${ZKVERSION}/bin/zkServer.sh start
|
mv zookeeper-${ZKVERSION} $ZC
|
||||||
|
fi
|
||||||
|
$ZC/bin/zkServer.sh start
|
||||||
# following lines are 'emulating' exhibitor REST API
|
# following lines are 'emulating' exhibitor REST API
|
||||||
while true; do
|
while true; do
|
||||||
echo -e 'HTTP/1.0 200 OK\nContent-Type: application/json\n\n{"servers":["127.0.0.1"],"port":2181}' \
|
echo -e 'HTTP/1.0 200 OK\nContent-Type: application/json\n\n{"servers":["127.0.0.1"],"port":2181}' \
|
||||||
@@ -58,20 +74,29 @@ install:
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for pv in "2.7" "3.4" "3.5"; do
|
for pv in "2.7.9" "3.4.2" "3.5.2"; do
|
||||||
|
if [[ $TEST_SUITE != "behave" || $pv != "3.4.2" ]]; then
|
||||||
|
if [[ -d ~/mycache/python${pv} ]]; then
|
||||||
|
mv ~/virtualenv/python${pv} ~/virtualenv/python${pv}.bckp
|
||||||
|
mv ~/mycache/python${pv} ~/virtualenv/python${pv}
|
||||||
|
fi
|
||||||
source ~/virtualenv/python${pv}/bin/activate
|
source ~/virtualenv/python${pv}/bin/activate
|
||||||
# explicitly install all needed python modules to cache them
|
# 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
|
for p in '-r requirements.txt' 'behave codacy-coverage coverage coveralls flake8 mock pytest-cov pytest setuptools'; do
|
||||||
pip install $p
|
pip install $p --upgrade
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
script:
|
script:
|
||||||
- |
|
- |
|
||||||
for pv in "2.7" "3.4" "3.5"; do
|
for pv in "2.7" "3.4" "3.5"; do
|
||||||
source ~/virtualenv/python${pv}/bin/activate
|
source ~/virtualenv/python${pv}/bin/activate
|
||||||
|
|
||||||
if [[ $TEST_SUITE == "behave" ]]; then
|
if [[ $TEST_SUITE != "behave" ]]; then
|
||||||
if [[ $pv != "3.4" ]]; then
|
echo Running unit tests using python${pv}
|
||||||
|
$TEST_SUITE test
|
||||||
|
$TEST_SUITE flake8
|
||||||
|
elif [[ $pv != "3.4" ]]; then
|
||||||
echo Running acceptance tests using python${pv}
|
echo Running acceptance tests using python${pv}
|
||||||
if ! PATH=.:$PATH $TEST_SUITE; then
|
if ! PATH=.:$PATH $TEST_SUITE; then
|
||||||
# output all log files when tests are failing
|
# output all log files when tests are failing
|
||||||
@@ -79,11 +104,6 @@ script:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo Running unit tests using python${pv}
|
|
||||||
$TEST_SUITE test
|
|
||||||
$TEST_SUITE flake8
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ requests
|
|||||||
six >= 1.7
|
six >= 1.7
|
||||||
kazoo==2.2.1
|
kazoo==2.2.1
|
||||||
python-etcd==0.4.3
|
python-etcd==0.4.3
|
||||||
python-consul==0.6.1
|
python-consul==0.7.0
|
||||||
click>=4.1
|
click>=4.1
|
||||||
prettytable>=0.7
|
prettytable>=0.7
|
||||||
tzlocal
|
tzlocal
|
||||||
|
|||||||
Reference in New Issue
Block a user