Skip to content

Commit

Permalink
Merge pull request #3 from wooyek/develop
Browse files Browse the repository at this point in the history
Wsparcie dla Heroku, TOX i Travis
  • Loading branch information
xinulsw committed Jan 11, 2017
2 parents 6e2862e + 0362b25 commit f0841aa
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ __pycache__/

# Distribution / packaging
.Python
bin/
# bin/
build/
develop-eggs/
dist/
Expand Down Expand Up @@ -100,3 +100,4 @@ $RECYCLE.BIN/
*.msp

.pve/
malybar/static/
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
language: python

python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"

sudo: false

cache:
- apt
- pip

install:
- pip install -r requirements.txt -r requirements-dev.txt

script: coverage run malybar/manage.py test

after_success:
- coveralls
- bash <(curl -s https://codecov.io/bash)

branches:
only:
- develop
- master
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn --chdir=/app/malybar malybar.wsgi:application --log-file -
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Mały Bar

Przykładowa aplikacja sieciowa w Django

http://django-maly-bar.readthedocs.io/


# Aplikacja wykorzystuje

- Django 1.10.4
- django-registration

Expand All @@ -12,9 +17,9 @@ i zainstalować w nim wymagane biblioteki

~$ git clone https://github.com/xinulsw/malybar.git
~$ cd malybar
~$ virtualenv .pve
~$ source .pve/bin/activate
~$ pip install -r requirements.txt
malybar$ virtualenv .pve
malybar$ source .pve/bin/activate
malybar$ pip install -r requirements.txt

Serwer uruchamiamy po aktywowaniu środowiska wirtualnego
(poleceniem: `source .pve/bin/activate`), w katalogu `malybar`:
Expand All @@ -32,5 +37,28 @@ W bazie są już konta użytkowników (login - hasło):
Sprawdzenia poprawnego działania aplikacji dokonujemy uruchamiając testy:

~/malybar/malybar$ python manage.py test

Dodatkowo testy można wykonać na wielu wersja Python przy pomocy narzędzia [TOX](https://tox.readthedocs.io/en/latest/),
konfiguracja tego narzędzia w pliku [tox.ini](tox.ini) wykonuje także testy pokrycia kodu testami.

~/malybar$ tox

Ponadto to repozytorium w GitHub jest spięte z testami wykonywanymi w chmurze.

![](https://img.shields.io/travis/wooyek/malybar.svg)
![](https://img.shields.io/coveralls/wooyek/malybar.svg)

Każda kopia repozytorium na GitHubie może uruchomić testy na własnym bezpłatnym koncie by objąć testami własne modyfikacje.

Dokumentacja: http://django-maly-bar.readthedocs.io/

# Heroku: Bezpłatny hosting aplikacji w Chmurze

Każdy może utworzyć jedną bezpłatną aplikację na Heroku, po ściągnięciu Heroku CLI:

Dokumentacja: http://django-maly-bar.readthedocs.io/
malybar$ heroku login
malybar$ heroku create
malybar$ git push heroku master
malybar$ heroku open

Po więcej informacji zapraszamy [do dokumentacji](https://devcenter.heroku.com/articles/getting-started-with-python#introduction)
6 changes: 6 additions & 0 deletions bin/post_compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# File path should be ./bin/post_compile
# https://gist.github.com/kylefox/7044491259b6b2586ca1

echo "=> Performing database migrations..."
python malybar/manage.py migrate
19 changes: 15 additions & 4 deletions malybar/malybar/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,19 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = [
'127.0.0.1',
'localhost',
'vagrant',
'.example.com',
'.herokuapp.com',
]

if 'ALLOWED_HOSTS' in os.environ:
for host in os.environ['ALLOWED_HOSTS'].split(" "):
host = host.strip()
if host:
ALLOWED_HOSTS.append(host)

# Application definition

Expand Down Expand Up @@ -83,11 +94,10 @@
DATABASES = {
"default": dj_database_url.config()
}
# Make sure we use GIS enabled engine
DATABASES['default']['ENGINE'] = 'django.contrib.gis.db.backends.postgis'
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql'
DATABASES['default']['TEST'] = {'NAME': os.environ.get("DATABASE_TEST_NAME", None)}
DATABASES['default']['OPTIONS'] = {
'options': '-c search_path=gis,public,pg_catalog'
'options': '-c search_path=public,pg_catalog'
}
else:
# Use local sqlite3 database
Expand Down Expand Up @@ -136,6 +146,7 @@
# https://docs.djangoproject.com/en/1.9/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

# django-registration
# REGISTRATION_OPEN = True # czy użytkownik może utworzyć konto
Expand Down
22 changes: 22 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Potrzebne testom CI na Travis
coverage
coveralls

# Przydaje się do testowania na różnych wersjach Pythona
tox

# Narzędzia ułatwiające pisanie testów jednostkowych
mock
faker
factory-boy

# Narzędzie do wersjonowania wydań
bumpversion

# Analiza jakości kodów źródłowych
pylint

# Inne
invoke
pathlib

16 changes: 12 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
Sphinx==1.4.5
Django==1.10.4
django-registration
dj-database-url
Django==1.10.4
django-registration

# Potrzebne do budowania dokumentacji
Sphinx==1.4.5

# Wymagane przez Heroku
# Potrzebne dla obsługi PostgreSQL, plików statycznych oraz serwera HTTP
psycopg2
dj-database-url
whitenoise
gunicorn
31 changes: 31 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
envlist = py27,py35
skipsdist = True

[testenv]
passenv =
DJANGO_SETTINGS_MODULE
DATABASE_URL

setenv =
TOX_ENVBINDIR={envbindir}
LIBRARY_PATH=/usr/local/lib
CPATH=/usr/local/include
CPLUS_INCLUDE_PATH=/usr/include/gdal
C_INCLUDE_PATH=/usr/include/gdal
PYTHONIOENCODING=utf-8

commands =
coverage erase
coverage run --source={toxinidir}/malybar malybar/manage.py test
coverage report
coverage xml

deps =
-rrequirements.txt
-rrequirements-dev.txt

0 comments on commit f0841aa

Please sign in to comment.