Add configuration to connect to a postgres database (#2)

CircleCI's free service only allows running 1 container at a time.
This causes problems if I want to use a database.
A workaround that I found seems to work by running the database server directly within the test container. This does increase test time however
This commit is contained in:
David Todd
2018-03-08 21:25:54 -06:00
committed by GitHub
parent 168266cd4a
commit 51a117ca5f
7 changed files with 117 additions and 6 deletions

View File

@@ -9,17 +9,27 @@ jobs:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
- image: circleci/python:2.7
environment:
POSTGRES_PASSWORD: totallyHacked1337
POSTGRES_USER: imagehost
POSTGRES_DB: imagehost_db
POSTGRES_HOST: localhost
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
- image: circleci/postgres:9.4
#- image: circleci/postgres:9.4
working_directory: ~/repo
steps:
- checkout
# Set up Test DB
- run: sudo apt install postgresql-client-9.4 postgresql-9.4
- run: sudo /etc/init.d/postgresql start
- run: sudo ${HOME}/repo/newdb.sh
# Download and cache dependencies
- restore_cache:
keys:
@@ -39,6 +49,14 @@ jobs:
- ./venv
key: v1-dependencies-{{ checksum "requirements.txt" }}
# Migrate our database (if needed)
- run:
name: run migration
command: |
. venv/bin/activate
python manage.py migrate
# run tests!
# this example uses Django's built-in test-runner
# other common Python testing frameworks include pytest and nose