mirror of
https://github.com/c0de-archive/django-gallery.git
synced 2025-08-07 23:48:47 +00:00
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user