Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Travis config to test on the different django database backends. #145

Merged
merged 5 commits into from
Oct 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,23 @@ python:
- "3.4"
- "3.5"
env:
- DJANGO="Django>=1.7.0,<1.8.0"
- DJANGO="Django>=1.8.0,<1.9.0"
- DJANGO="Django>=1.9.0,<1.10.0"
- DJANGO="Django>=1.10b1,<1.11.0"
# PostgreSQL
- DJANGO="Django>=1.7.0,<1.8.0" DB=postgresql DB_NAME=travis_ci_test
- DJANGO="Django>=1.8.0,<1.9.0" DB=postgresql DB_NAME=travis_ci_test
- DJANGO="Django>=1.9.0,<1.10.0" DB=postgresql DB_NAME=travis_ci_test
- DJANGO="Django>=1.10b1,<1.11.0" DB=postgresql DB_NAME=travis_ci_test

# SQLite3
- DJANGO="Django>=1.7.0,<1.8.0" DB=sqlite3 DB_NAME=db.sqlite3
- DJANGO="Django>=1.8.0,<1.9.0" DB=sqlite3 DB_NAME=db.sqlite3
- DJANGO="Django>=1.9.0,<1.10.0" DB=sqlite3 DB_NAME=db.sqlite3
- DJANGO="Django>=1.10b1,<1.11.0" DB=sqlite3 DB_NAME=db.sqlite3

# MySQL
- DJANGO="Django>=1.7.0,<1.8.0" DB=mysql DB_NAME=mysql_db
- DJANGO="Django>=1.8.0,<1.9.0" DB=mysql DB_NAME=mysql_db
- DJANGO="Django>=1.9.0,<1.10.0" DB=mysql DB_NAME=mysql_db
- DJANGO="Django>=1.10b1,<1.11.0" DB=mysql DB_NAME=mysql_db

matrix:
allow_failures:
Expand All @@ -24,6 +37,14 @@ matrix:
install:
- pip install -q $DJANGO
- pip install -r requirements.txt

# Handle PostgreSQL
- if [[ "$DB" = "postgresql" ]]; then pip install psycopg2; fi
- if [[ "$DB" = "postgresql" ]]; then psql -c 'create database travis_ci_test;' -U postgres; fi

# Handle MySQL
- if [[ "$DB" = "mysql" ]]; then pip install mysqlclient; fi
- if [[ "$DB" = "mysql" ]]; then mysql -e 'create database mysql_db;'; fi

script:
- cd project
Expand Down
8 changes: 5 additions & 3 deletions project/project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@

WSGI_APPLICATION = 'wsgi.application'

DB_NAME = os.path.join(BASE_DIR, 'db.sqlite3')
DB = os.environ['DB']
if DB == 'postgresql':
DB = 'postgresql_psycopg2'

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': DB_NAME
'ENGINE': 'django.db.backends.' + DB,
'NAME': os.environ['DB_NAME']
}
}

Expand Down