I am trying to setup continuous integration for my django project. Since I am using postgresql als my database, I want to setup the same in travis. This is my travis.yml file:
language: python
services:
- postgresql
python:
- 3.4
env:
- DJANGO=1.8 DB=postgres
before_install:
- export DJANGO_SETTINGS_MODULE=ledenbestand.settings.local
install:
- pip install -r travis/requirements.txt
before_script:
- psql -c 'create database ledenbestand;' -U postgres
script:
- python manage.py test
notifications:
email:
recipients:
- [email protected]
on_success: never
on_failure: always
The problem is that this will fail because my local.py settings also gives a password when connecting to the database, the postgres user on travis doesn't have a password:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'ledenbestand',
'USER': 'postgres',
**'PASSWORD': 'password',**
'HOST': 'localhost',
'PORT': '5432',
}
}
The travis documentation says the following:
Should your local test setup use different credentials or settings to access the local test database, we recommend putting these settings in a database.yml.travis in your repository and copying that over as part of your build:
before_script:
- cp config/database.yml.travis config/database.yml
I however have no clue how this could work, how can this line of code overwrite my local.py settings?