Repository navigation
Expand file tree
/
Copy path.travis.yml
More file actions
72 lines (62 loc) · 3.26 KB
/
Copy path.travis.yml
File metadata and controls
72 lines (62 loc) · 3.26 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
language: python
cache: pip
python:
- '3.7'
services:
- postgresql
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}
- 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
before_install:
- npm install dredd@5.4.1 --global
install:
- travis_retry pip install -r requirements/requirements.txt
- 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}"
- 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
- 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
# Run elasticsearch
- curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.1.1.deb && sudo dpkg -i --force-confnew elasticsearch-6.1.1.deb && sudo service elasticsearch restart
# 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
- sleep 10 # wait for Elasticsearch to be up
script:
- cd ${TRAVIS_BUILD_DIR} # run build script out of repo dir
- flake8
- black --check --diff .
- python manage.py check_for_endpoint_documentation
- pytest --durations 50 --ignore-glob='**/tests/integration/*' --cov=usaspending_api --cov-report= --reuse-db -rsx
- pytest --durations 50 --override-ini=python_files='**/tests/integration/test_*.py **/tests/integration/*_test.py' --cov=usaspending_api --cov-append --cov-report term --cov-report xml:coverage.xml --reuse-db -rsx
# - dredd (Disable dredd until test data is loaded into DB for API responses)
after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT