jeudi 27 août 2015

Best practices for CI

I want to set up a CI workflow for my Django application on Codeship and I'm wondering how best to go about this. So far I have the following set up:

  1. AWS EBS dev instance tied to my develop branch
  2. AWS EBS prod instance tied to my master branch

Both AWS EBS dev/prod have their own RDS database. In my Django settings file, I have:

try:
    from settings_local import *
except ImportError, e:

    DEBUG = False

    ALLOWED_HOSTS = ['localhost', '.elasticbeanstalk.com']

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
            'NAME': os.environ['RDS_DB_NAME'],
            'USER': os.environ['RDS_USERNAME'],
            'PASSWORD': os.environ['RDS_PASSWORD'],
            'HOST': os.environ['RDS_HOSTNAME'],
            'PORT': os.environ['RDS_PORT'],
        }
    }

On settings_local.py, I set DEBUG to True and set the parameters for my local databases. So when this application is pushed to either my dev or production environments, DEBUG is False, and the database parameters are set to whatever AWS has in their environment

My issue now is that with Codeship, my tests always fail before the server is set up because os.environ['RDS_DB_NAME'] doesn't exist on the codeship server.

I guess I could explicitly declare the database parameters for RDS in my settings, but the values for the prod/dev RDS database are different so I would need a way to figure out which database setting to use when deploying to dev or prod. Also I would need to give Codeship access to my RDS database.

Is there a better way to declare my database settings or start my test server with Codeship?




Aucun commentaire:

Enregistrer un commentaire