forked from CenterForOpenScience/osf.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
145 lines (123 loc) · 4.93 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Config file for automatic testing at travis-ci.org
language: python
python:
- "2.7"
sudo: false
# TODO: uncomment when https://github.com/travis-ci/travis-ci/issues/8836 is resolved
# addons:
# chrome: stable
cache:
yarn: true
pip: true
directories:
- $HOME/.cache
- node_modules
- website/static/vendor/bower_components
env:
global:
- WHEELHOUSE="$HOME/.cache/wheelhouse"
- LIBXML2_DEB="libxml2-dbg_2.9.1+dfsg1-3ubuntu4.9_amd64.deb"
- POSTGRES_DEB="postgresql-9.6_9.6.3-1.pgdg12.4+1_amd64.deb"
- ELASTICSEARCH_ARCHIVE="elasticsearch-2.4.5.tar.gz"
- LIBJEMALLOC_DEB="libjemalloc1_3.5.1-2_amd64.deb"
- LIBPCRE_DEB="libpcre3_8.31-2ubuntu2.3_amd64.deb"
# - VARNISH_DEB="varnish_4.1.0-1~trusty_amd64.deb"
- OSF_DB_PORT="54321"
# Workaround for travis bug: see https://github.com/travis-ci/travis-ci/issues/7940#issuecomment-311411559
- BOTO_CONFIG=/dev/null
matrix:
- TEST_BUILD="addons"
- TEST_BUILD="website"
- TEST_BUILD="api1_and_js"
- TEST_BUILD="api2"
- TEST_BUILD="api3_and_osf"
before_install:
# cache directories
- |
mkdir -p $HOME/.cache/downloads
mkdir -p $HOME/.cache/pip
mkdir -p $HOME/.cache/wheelhouse
rm -rf node_modules ## TODO remove this later
# postgres
- |
cd $HOME/.cache/downloads
if [ ! -f "$LIBXML2_DEB" ]; then
curl -SLO http://security.ubuntu.com/ubuntu/pool/main/libx/libxml2/$LIBXML2_DEB
fi
if [ ! -f "$POSTGRES_DEB" ]; then
curl -SLO http://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-9.6/$POSTGRES_DEB
fi
dpkg -x $LIBXML2_DEB /tmp/libxml2
dpkg -x $POSTGRES_DEB /tmp/postgres
- |
export LD_LIBRARY_PATH=/tmp/libxml2/usr/lib/x86_64-linux-gnu
/tmp/postgres/usr/lib/postgresql/9.6/bin/initdb /tmp/postgres/data --nosync -U postgres
sed -i -e 's/#fsync.*/fsync = off/' /tmp/postgres/data/postgresql.conf
sed -i -e 's/#synchronous_commit.*/synchronous_commit = off/' /tmp/postgres/data/postgresql.conf
sed -i -e 's/#full_page_writes.*/full_page_writes = off/' /tmp/postgres/data/postgresql.conf
/tmp/postgres/usr/lib/postgresql/9.6/bin/postgres -k /tmp -D /tmp/postgres/data -p 54321 > /dev/null & export POSTGRES_PID=$!
# elasticsearch
- |
cd $HOME/.cache/downloads
if [ ! -f "$ELASTICSEARCH_ARCHIVE" ]; then
curl -SLO https://download.elasticsearch.org/elasticsearch/elasticsearch/$ELASTICSEARCH_ARCHIVE
fi
if [ ! -f "$ELASTICSEARCH_ARCHIVE.sha1.txt" ]; then
curl -SLO https://download.elasticsearch.org/elasticsearch/elasticsearch/$ELASTICSEARCH_ARCHIVE.sha1.txt
fi
sha1sum --check $ELASTICSEARCH_ARCHIVE.sha1.txt
mkdir -p /tmp/elasticsearch
tar xzf $ELASTICSEARCH_ARCHIVE -C /tmp/elasticsearch --strip-components=1
- /tmp/elasticsearch/bin/elasticsearch > /dev/null & export ELASTICSEARCH_PID=$!
# Wait for elasticsearch to come online
- |-
while true; do
sleep 5
curl -sf http://localhost:9200/_cluster/health?wait_for_status=yellow
if [ $? -eq 0 ]; then
break
fi
done
install:
- cd $TRAVIS_BUILD_DIR
- cp website/settings/local-travis.py website/settings/local.py
- cp api/base/settings/local-travis.py api/base/settings/local.py
- '[ -d $HOME/preprints ] || ( mkdir -p $HOME/preprints && touch $HOME/preprints/index.html )'
- travis_retry pip install --upgrade pip
- travis_retry pip install invoke==0.13.0
- travis_retry pip install flake8==2.4.0 --force-reinstall --upgrade
- travis_retry invoke wheelhouse --dev --addons
- |
if [ "$TEST_BUILD" = "api1_and_js" ]; then
nvm install 8.6.0
nvm use 8.6.0
curl -o- -L https://yarnpkg.com/install.sh | bash
export PATH=$HOME/.yarn/bin:$PATH
travis_retry invoke assets --dev
fi
- travis_retry invoke travis_addon_settings
- travis_retry invoke requirements --dev --addons
# Hack to fix package conflict between uritemplate and uritemplate.py (dependency of github3.py)
- pip uninstall uritemplate.py --yes
- pip install uritemplate.py==0.3.0
# Run Python tests (core and addon) and JS tests
script:
- export COVERAGE=`if [ "$TRAVIS_BRANCH" == "master-w-coverage" ]; then echo "--coverage"; else echo ""; fi`
- invoke test_travis_$TEST_BUILD -n 4 $COVERAGE
after_success:
- if [[ "$TRAVIS_BRANCH" == "master-w-coverage" ]]; then coveralls; fi
before_cache:
- rm -Rf $HOME/.cache/pip/http
- rm -f $HOME/.cache/pip/log/debug.log
# exclude python requirements from github repo's
- rm -f $HOME/.cache/wheelhouse/modular_odm-*.whl
- rm -f $HOME/.cache/wheelhouse/mfr-*.whl
- rm -f $HOME/.cache/wheelhouse/responses-*.whl
- rm -f $HOME/.cache/wheelhouse/mendeley-*.whl
- rm -f $HOME/.cache/wheelhouse/feedparser-*.whl
# kill any running processes
- kill -9 $POSTGRES_PID
- kill -9 $ELASTICSEARCH_PID
branches:
except:
- /^[0-9]/