forked from nyaruka/rapidpro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.travis.yml
More file actions
131 lines (102 loc) · 5.17 KB
/
Copy path.travis.yml
File metadata and controls
131 lines (102 loc) · 5.17 KB
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
# use container-based Ubuntu Trusty
dist: trusty
sudo: true
language: python
python:
- "3.6.6"
services:
- redis-server
env:
- PGDB=10
- PGDB=9.6
cache:
directories:
- "$HOME/.cache/pip"
before_install:
- sudo -E service postgresql stop 9.2
- sudo -E service postgresql stop 9.3
- sudo -E service postgresql stop 9.4
- sudo -E service postgresql stop 9.5
- sudo -E service postgresql stop 9.6
- sudo -E apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install postgresql-$PGDB postgresql-client-$PGDB postgresql-$PGDB-postgis-2.4 postgresql-$PGDB-postgis-2.4-scripts
- sudo -E sed -i -e '/local.*peer/s/postgres/all/' -e 's/peer\|md5/trust/g' /etc/postgresql/*/main/pg_hba.conf
- sudo -E sed -i 's/port = 5433/port = 5432/' /etc/postgresql/*/main/postgresql.conf
- sudo -E service postgresql restart $PGDB
install:
# install Elasticsearch
- ES_VERSION=6.3.1
- wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
- tar -xzf elasticsearch-${ES_VERSION}.tar.gz
- ./elasticsearch-${ES_VERSION}/bin/elasticsearch &
# install mailroom
- MAILROOM_VERSION=1.0.1
- wget https://github.com/nyaruka/mailroom/releases/download/v${MAILROOM_VERSION}/mailroom_${MAILROOM_VERSION}_linux_amd64.tar.gz
- tar -xvf mailroom_${MAILROOM_VERSION}_linux_amd64.tar.gz mailroom
# install rp-indexer
- RPINDEXER_VERSION=1.0.25
- wget https://github.com/nyaruka/rp-indexer/releases/download/v${RPINDEXER_VERSION}/rp-indexer_${RPINDEXER_VERSION}_linux_amd64.tar.gz
- tar -xvf rp-indexer_${RPINDEXER_VERSION}_linux_amd64.tar.gz
# install all Python dependencies
- travis_retry pip install --upgrade pip
- pip --version
- travis_retry pip install -r pip-freeze.txt --upgrade
- pip install coveralls
- pip install flake8
# switch to Node 10 and install our node dependencies
- nvm install 10
- nvm use 10
- npm install
before_script:
# setup test database
- psql -U postgres -c "CREATE USER temba WITH PASSWORD 'temba';"
- psql -U postgres -c "ALTER ROLE temba WITH SUPERUSER;"
- psql -d 'template1' -U postgres -c "CREATE EXTENSION postgis;"
- psql -d 'template1' -U postgres -c "CREATE EXTENSION postgis_topology;"
- psql -d 'template1' -U postgres -c "CREATE EXTENSION hstore;"
- psql -U temba postgres -c "CREATE DATABASE temba;"
# use dev settings file
- ln -s $TRAVIS_BUILD_DIR/temba/settings.py.dev $TRAVIS_BUILD_DIR/temba/settings.py
# wait until Elasticsearch is responsive
- wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200
script:
# any non-zero error code should be treated as an immediate failure
- set -e
# test that everything is well formatted
- black --line-length=119 --target-version=py36 temba --check --quiet || (echo 'The source code could use a bit more black.' && exit 1)
# test PEP8 compliance on both Python 2 and 3
- flake8
# compile messages
- cd temba && python ../manage.py compilemessages && cd ..
# fail if there are changes
- git diff --numstat
- git diff --numstat | awk '$3 ~ /locale.*mo$/ { print "compilemessages needs to be rerun, see .travis.yml for command"; exit 1 }'
# generate our locale messages
- python manage.py makemessages -a -e haml,html,txt,py --ignore="env/*" --no-location --no-wrap | awk '/warning/ { print "makemessages contains warnings"; exit 1 }'
- python manage.py makemessages -d djangojs -a --ignore="env/*" --ignore="static/bower/*" --ignore="node_modules/*" --no-location --no-wrap
- python manage.py makemessages -d djangojs -a --ignore="env/*" --ignore="static/bower/*" --ignore="node_modules/*" --no-location --no-wrap | awk '/warning/ { print "makemessages for djangojs contains warnings"; exit 1 }'
# fail if there are changes
- git diff --numstat
- git diff --numstat | awk '$1 > 1 && $3 ~ /locale/ { print "makemessages needs to be rerun, see .travis.yml for command"; exit 1 }'
# check for model changes not reflected in a migration
- python manage.py makemigrations --settings=temba.settings_travis --dry-run | grep 'No changes detected' || (echo 'There are changes which require migrations.' && exit 1)
# run our Javascript tests
- node_modules/karma/bin/karma start karma.conf.coffee --single-run --browsers PhantomJS
# check we can collect and compress all static files
- python manage.py collectstatic --noinput --verbosity=0
- (! python manage.py compress --extension=".haml" --settings=temba.settings_compress | grep 'Error') || exit 1
# install database schema
- python manage.py migrate --settings=temba.settings_travis
# fire up mailroom
- ./mailroom -db=postgres://temba:temba@localhost:5432/temba -redis=redis://localhost:6379/10 -log-level=info &
- jobs
# run our Python unit tests on same database
- coverage run manage.py test --settings=temba.settings_travis --keepdb --noinput --verbosity=2
- set +e
after_success:
- pip install codecov
- codecov
- coverage report -i
- coverage report -i --rcfile .coveragerc_todo
notifications:
slack:
secure: "b2/RUpO6gWEDgOI/sEWsjt2cVnwp3hOWUSMnHpVuY0pZBzzrICZ5MeqEulwCoKy+8ohaCmYUL42RzJwq1v2FITo5YDeiLrqmrkYR0Zieel/Vey+o6sBdR6y2yPvWjBmydHNvfUyMshT5iqEn4bS6bjhm57F0rLJX7mTqp19A+68="