ndarville / pony-forum

A modern alternative to ancient forum CMSes like vBulletin and PHPBB in Python on Django. (Alpha stage.) (NB: dotCloud have since removed their free Sandbox tier.)
http://pony-forum.com
26 stars 7 forks source link

Set up Travis CI for Python/Django and GitHub #51

Closed ndarville closed 12 years ago

ndarville commented 12 years ago

travis.yml in root

language: python

python:
  - 2.6
  - 2.7

services: postgresql

install:
  - pip install -r requirements.txt --use-mirrors
# - pip install psycopg2 --use-mirrors
  - pip install pep8 --use-mirrors

before_script:
  - psql -c "CREATE DATABASE ponydb;" -U postgres
  - pep8 --exclude=migrations --ignore=E501,E225 forum, _postinstall

script:
  - python manage.py syncdb --noinput
  - python _postinstall/mkadmin.py
  - python _postinstall/definesite.py
  - python _postinstall/mkcategorythreadpost.py
  - python _postinstall/mkplaceholders.py

# Test scripts: deprecation warnings, user testing, security
# after_script:
# - django-admin.py checksecure
# - python -Wall manage.py runserver
# If Travis CI is running a build
try:
    os.environ['TRAVIS']
    TRAVIS_DB = {
        'default': {
            'ENGINE':   'django.db.backends.postgresql_psycopg2',
            'NAME':     'ponydb',
            'USER':     'postgres',
            'PASSWORD': '',
            'HOST':     'localhost',  # Remember this part!
            'PORT':     '',
        }
   }
   DATABASES = TRAVIS_DB
except KeyError:
    pass
ndarville commented 12 years ago

Settle for a dialled-down version, until I figure out the Django back-end configuration

language: python

python:
  - 2.6
  - 2.7

install:
  - pip install -r requirements.txt --use-mirrors
  - pip install pep8 --use-mirrors

before_script:
  - pep8 --exclude=migrations --ignore=E501,E225 forum, _postinstall

pep8 --select=X000 dir

        'default': {
            'ENGINE':  'django.db.backends.postgresql_psycopg2',
            'NAME':    'template1',
            'USER':     env['DOTCLOUD_DB_SQL_LOGIN'],
            'PASSWORD': env['DOTCLOUD_DB_SQL_PASSWORD'],
            'HOST':     env['DOTCLOUD_DB_SQL_HOST'],
            'PORT':     int(env['DOTCLOUD_DB_SQL_PORT']),
        },
        'travis': {
            'ENGINE':   'django.db.backends.postgresql_psycopg2',
            'NAME':     'ponydb',
            'USER':     'postgres',
            'PASSWORD': '',
            'HOST':     'localhost',
            'PORT':     '',
        }

manage.py syncdb --database=travis

import os

if 'TRAVIS' in os.environ:
    DATABASE = ...

Python config: http://about.travis-ci.org/docs/user/languages/python/. Database config: http://about.travis-ci.org/docs/user/database-setup/. More config: http://about.travis-ci.org/blog/august-2012-upcoming-ci-environment-updates/. Env vars: http://about.travis-ci.org/docs/user/ci-environment/.

ndarville commented 12 years ago

Problems importing wsgi.py:

Traceback (most recent call last):
  File "_postinstall/mkadmin.py", line 2, in <module>
    from wsgi import *
ImportError: No module named wsgi

http://travis-ci.org/#!/ndarville/dotcloud-django/jobs/2261149 (dotcloud-django -> ponyforum)

ndarville commented 12 years ago

For some reason, you have to define both the DJANGO_SETTINGS_MODULE and PYTHONPATH in order for the local set-up to work. The PYTHONPATH is designated as your Django project dir, while the settings module is yourproject.settings---sometimes yourproject.settings.work_environment.

ndarville commented 12 years ago

Merged in Pull Request #56: https://github.com/ndarville/dotcloud-django/pull/56.