Skip to content

Commit

Permalink
Merge pull request #26 from cuducos/ci-settings
Browse files Browse the repository at this point in the history
Enhance CI settings (avoid the need to manually add new apps)
  • Loading branch information
jllorencetti committed Jul 20, 2016
2 parents 3cbdf62 + 679c769 commit 325d24d
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 48 deletions.
21 changes: 10 additions & 11 deletions .codeclimate.yml
@@ -1,12 +1,11 @@
languages:
Ruby: true
JavaScript: true
PHP: true
Python: true
engines:
pep8:
enabled: true
ratings:
paths:
- "**.py"
exclude_paths:
- "pets/functional_tests/*"
- "pets/meupet/tests/*"
- "pets/users/tests.py"
- "pets/common/migrations/*"
- "pets/meupet/migrations/*"
- "pets/users/migrations/*"
- "**/functional_tests/*"
- "**/migrations/*"
- "**/test.py"
- "**/tests/*"
13 changes: 13 additions & 0 deletions .coveragerc
@@ -0,0 +1,13 @@
[run]

# include everything inside pets/pets/ by default
source=.

# exclude tests, migrations, settings etc.
omit=
**/test.py
*/functional_tests/*
*/migrations/*
*/tests/*
manage.py
pets/*
14 changes: 8 additions & 6 deletions .gitignore
@@ -1,10 +1,12 @@
.idea
*.log
*.pyc
*.sqlite3
.coverage
.env
.idea
__pycache__
pet_images
htmlcov
media
*.pyc
*.log
pet_images
screendumps
static_root
.env
static_root
6 changes: 2 additions & 4 deletions .travis.yml
Expand Up @@ -11,10 +11,8 @@ install:
- pip install coveralls
script:
- cd pets
- coverage run --source=common,users,meupet,functional_tests manage.py test
env:
- DJANGO_SETTINGS_MODULE=pets.settings.dev DB_NAME=test DB_USERNAME=test DB_PASSWORD=test DB_IP=127.0.0.1 DB_PORT=5432 DB_ENGINE=django.db.backends.postgresql_psycopg2 DB_CONN_MAX_AGE=0 SECRET_KEY=dummy_key ALLOWED_HOSTS=127.0.0.1, .localhost EMAIL_PORT=0 EMAIL_HOST=example.com EMAIL_HOST_PASSWORD=example EMAIL_HOST_USER=dummy@example.com OPBEAT_DISABLE_SEND=true
- coverage run --rcfile=../.coveragerc manage.py test -v 3
before_script:
- psql -U postgres -c "CREATE USER test WITH CREATEDB PASSWORD 'test';"
- psql -U postgres -c 'create database pets;'
after_success:
- coveralls
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -52,13 +52,13 @@ Then you have to set following variables:

#### Database

* **`DB_NAME`**, **`DB_USERNAME`**, **`DB_PASSWORD`**, **`DB_IP`**, **`DB_PORT`**: Credentials to access Pets's database.
* **`DB_ENGINE`**: Django databse backend to connect to Pets's database (e.g. `django.db.backends.postgresql_psycopg2`)
* **`DATABASE_URL`**: (e.g. `postgres://username:password@server:port/database_name`) [Database URL](https://github.com/kennethreitz/dj-database-url#url-schema)
* **`DB_CONN_MAX_AGE`**: (e.g. `0`) [Django's database `CONN_MAX_AGE`](https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-CONN_MAX_AGE`)

#### Mail server for sending e-mails

* **`EMAIL_PORT`**, **`EMAIL_HOST`**, **`EMAIL_HOST_PASSWORD`** and **`EMAIL_HOST_USER`**: SMTP credentials to a mail server.
* **`EMAIL_BACKEND`**: (e.g. `django.core.mail.backends.console.EmailBackend`) [Django's email backend](https://docs.djangoproject.com/en/1.8/topics/email/#topic-email-backends)

#### OAuth

Expand Down
13 changes: 5 additions & 8 deletions contrib/sample-env
@@ -1,13 +1,10 @@
SECRET_KEY=secret_dummy_key
ALLOWED_HOSTS=127.0.0.1,.localhost
DJANGO_SETTINGS_MODULE=pets.settings.dev
DB_NAME=pets
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_IP=127.0.0.1
DB_PORT=5432
DB_ENGINE=django.db.backends.postgresql_psycopg2
DATABASE_URL=sqlite:///db.sqlite3
DB_CONN_MAX_AGE=0
SECRET_KEY=dummy_key
ALLOWED_HOSTS=127.0.0.1, .localhost

EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
EMAIL_PORT=0
EMAIL_HOST=example.com
EMAIL_HOST_PASSWORD=example
Expand Down
27 changes: 12 additions & 15 deletions pets/pets/settings/prod.py
@@ -1,6 +1,7 @@
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from decouple import config, Csv
from dj_database_url import parse as db_url

BASE_DIR = os.path.dirname(os.path.dirname(__file__))

Expand All @@ -18,7 +19,7 @@
'127.0.0.1',
)

ALLOWED_HOSTS = config('ALLOWED_HOSTS', default=[], cast=Csv())
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='', cast=Csv())

# Application definition

Expand Down Expand Up @@ -112,16 +113,10 @@
# Database
# https://docs.djangoproject.com/en/dev/ref/settings/#databases

conn_max_age = config('DB_CONN_MAX_AGE', default=0, cast=int)
default_db_url = config('DATABASE_URL')
DATABASES = {
'default': {
'ENGINE': config('DB_ENGINE'),
'NAME': config('DB_NAME'),
'USER': config('DB_USERNAME'),
'PASSWORD': config('DB_PASSWORD'),
'HOST': config('DB_IP'),
'PORT': config('DB_PORT'),
'CONN_MAX_AGE': config('DB_CONN_MAX_AGE', cast=int),
}
'default': db_url(default_db_url, conn_max_age=conn_max_age)
}

# Internationalization
Expand Down Expand Up @@ -200,12 +195,14 @@
'SECRET_TOKEN': config('OPBEAT_SECRET_TOKEN', default=''),
}

default_email_backend = 'django.core.mail.backends.console.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = config('EMAIL_HOST')
EMAIL_PORT = config('EMAIL_PORT')
EMAIL_HOST_USER = config('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')
DEFAULT_FROM_EMAIL = config('EMAIL_HOST_USER')
EMAIL_BACKEND = config('EMAIL_BACKEND', default=default_email_backend)
EMAIL_HOST = config('EMAIL_HOST', default='example.com')
EMAIL_PORT = config('EMAIL_PORT', default='0')
EMAIL_HOST_USER = config('EMAIL_HOST_USER', default='dummy@example.com')
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD', default='example')
DEFAULT_FROM_EMAIL = config('EMAIL_HOST_USER', default='dummy@example.com')

CORS_ORIGIN_ALLOW_ALL = True
CORS_URLS_REGEX = r'^/api/.*$'
6 changes: 4 additions & 2 deletions pets/pets/wsgi.py
Expand Up @@ -7,9 +7,11 @@
https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/
"""

import os
from os import environ
from decouple import config

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pets.settings.dev")
settings_module = config("DJANGO_SETTINGS_MODULE", default="pets.settings.dev")
environ['DJANGO_SETTINGS_MODULE'] = settings_module

from django.core.wsgi import get_wsgi_application

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -6,6 +6,7 @@ django-compressor==2.0
django-cors-middleware==1.2.0
django-password-reset==0.9
djangorestframework==3.3.3
dj-database-url==0.4.1
easy-thumbnails==2.3
facebook-sdk==1.0.0
Pillow==3.3.0
Expand Down

0 comments on commit 325d24d

Please sign in to comment.