forked from fedspendingtransparency/usaspending-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
88 lines (78 loc) · 4.25 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
language: python
cache: pip
python:
- '3.7'
services:
- postgresql
# NOTE: This is added, but re-installed at a different version below
- elasticsearch
addons:
postgresql: '10'
apt:
packages:
- postgresql-10
- postgresql-client-10
env:
global:
- USASPENDING_DB_HOST=localhost
- USASPENDING_DB_PORT=5432
- USASPENDING_DB_USER=usaspending
- USASPENDING_DB_PASSWORD=usaspender
- USASPENDING_DB_NAME=data_store_api
- DATABASE_URL=postgres://${USASPENDING_DB_USER}:${USASPENDING_DB_PASSWORD}@${USASPENDING_DB_HOST}:${USASPENDING_DB_PORT}/${USASPENDING_DB_NAME}
- DOWNLOAD_DATABASE_URL=postgres://${USASPENDING_DB_USER}:${USASPENDING_DB_PASSWORD}@${USASPENDING_DB_HOST}:${USASPENDING_DB_PORT}/${USASPENDING_DB_NAME}
- DJANGO_SETTINGS_MODULE='usaspending_api.settings'
- ES_HOSTNAME='http://localhost:9200'
- BROKER_DB_HOST=localhost
- BROKER_DB_PORT=5432
- BROKER_DB_USER=admin
- BROKER_DB_PASSWORD=root
- BROKER_DB_NAME=data_broker
- DATA_BROKER_DATABASE_URL=postgres://${BROKER_DB_USER}:${BROKER_DB_PASSWORD}@${BROKER_DB_HOST}:${BROKER_DB_PORT}/${BROKER_DB_NAME}
- BROKER_REPO_URL=https://github.com/fedspendingtransparency/data-act-broker-backend.git
- BROKER_REPO_BRANCH=$(if [ "${TRAVIS_EVENT_TYPE}" = "pull_request" ] && [ ! -z "`git ls-remote --heads ${BROKER_REPO_URL} ${TRAVIS_BRANCH}`" ]; then echo "${TRAVIS_BRANCH}"; else echo "development"; fi;)
- BROKER_REPO_FOLDER=${TRAVIS_BUILD_DIR}/../data-act-broker-backend
- BROKER_DOCKER_IMAGE=dataact-broker-backend
- GRANTS_API_KEY=${GRANTS_API_KEY}
before_install:
# Re-install elasticsearch at the right version
- sudo systemctl stop elasticsearch
- sudo dpkg --remove elasticsearch
- sudo dpkg --purge elasticsearch
- sudo rm -rf /var/lib/elasticsearch
- travis_retry curl -s -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.1-amd64.deb
- sudo dpkg --install elasticsearch-7.1.1-amd64.deb
- sudo sed -i.old 's/-Xms1g/-Xms512m/' /etc/elasticsearch/jvm.options
- echo -e '-XX:+DisableExplicitGC\n-Djdk.io.permissionsUseCanonicalPath=true\n-Dlog4j.skipJansi=true\n-server\n' | sudo tee -a /etc/elasticsearch/jvm.options
- sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install mapper-murmur3
- sudo chown -R elasticsearch:elasticsearch /etc/default/elasticsearch
- sudo systemctl start elasticsearch
- sudo journalctl -u elasticsearch -b
# Add dredd for API contract testing
- travis_retry npm install --global dredd@13.1.2
install:
- travis_retry pip install -r requirements/requirements.txt
- travis_retry pip install coveralls
# Checkout dependent broker code used to spin up a broker integration test db. Put it in its own folder alongside this repo's code
- echo "Using ${BROKER_REPO_BRANCH} branch from ${BROKER_REPO_URL}"
- travis_retry git clone --branch ${BROKER_REPO_BRANCH} --single-branch --depth 1 ${BROKER_REPO_URL} ${BROKER_REPO_FOLDER}
before_script:
# Get dependencies to report code coverage to code climate
- travis_retry curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
# Our Postgres DB provided by Travis needs to have the (super) users specified by our env var DB URLs used
- psql -c "CREATE USER ${USASPENDING_DB_USER} PASSWORD '${USASPENDING_DB_PASSWORD}' SUPERUSER"
- psql -c "CREATE USER ${BROKER_DB_USER} PASSWORD '${BROKER_DB_PASSWORD}' SUPERUSER"
- docker build -t ${BROKER_DOCKER_IMAGE} ${BROKER_REPO_FOLDER} # Build image from which to call Broker scripts
- until curl --silent -XGET --fail http://localhost:9200; do printf '.'; sleep 1; done
script:
- cd ${TRAVIS_BUILD_DIR} # run build script out of repo dir
- flake8
- black --check --diff .
- python manage.py check_for_endpoint_documentation
- dredd > dredd-results.txt && echo '! grep -E "^[warn:|error:]" dredd-results.txt' | bash
- pytest --durations 50 --ignore-glob='**/tests/integration/*' --cov=usaspending_api --cov-report= --reuse-db -rsx
- pytest --durations 50 --override-ini=python_files='**/tests/integration/*' --cov=usaspending_api --cov-append --cov-report term --cov-report xml:coverage.xml --reuse-db -rsx
after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT