Skip to content

Commit

Permalink
Merge pull request #134 from JayH5/new-versions-travis
Browse files Browse the repository at this point in the history
Update Django/Python versions & clean up sample site Docker things
  • Loading branch information
mwarkentin authored Feb 25, 2019
2 parents 25902a9 + adad187 commit b9ff64a
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 48 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
.tox
*.egg_info
**/__pycache__
**/*.pyc
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
sudo: false
dist: xenial
language: python

python:
- "3.7"
- "3.6"
- "3.5"
- "2.7"

env:
matrix:
- DJANGO_VERSION=2.1
- DJANGO_VERSION=2.0
- DJANGO_VERSION=1.11
- DJANGO_VERSION=1.10
- DJANGO_VERSION=1.9
- DJANGO_VERSION=1.8

matrix:
exclude:
- python: "2.7"
env: DJANGO_VERSION=2.0
- python: "2.7"
env: DJANGO_VERSION=2.1

install:
- pip install tox coveralls
Expand All @@ -35,6 +36,7 @@ notifications:
jobs:
include:
- stage: pypi release
if: tag IS present
python: "3.6"
script: echo "Deploying to pypi ..."
deploy:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python
FROM python:slim
COPY . /app
WORKDIR /app/sample_project
RUN pip install -r requirements.txt
RUN pip install --no-cache -r requirements.txt
RUN python manage.py migrate
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
18 changes: 15 additions & 3 deletions sample_project/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sample_project.settings")

from django.core.management import execute_from_command_line

try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)
2 changes: 1 addition & 1 deletion sample_project/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
django<1.9
django<2.0,>=1.11

# django-watchman
-e /app
56 changes: 27 additions & 29 deletions sample_project/sample_project/settings.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
"""
Django settings for sample_project project.
Generated by 'django-admin startproject' using Django 1.8.6.
Generated by 'django-admin startproject' using Django 1.11.17.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
https://docs.djangoproject.com/en/1.11/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'h%n@34@2nst!bm-ilj$3tfyq4-*iq@q@0_jjquu4$0g61ep-vy'
Expand All @@ -34,26 +34,25 @@

# Application definition

INSTALLED_APPS = (
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'watchman',
)
]

MIDDLEWARE_CLASSES = (
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
]

ROOT_URLCONF = 'sample_project.urls'

Expand All @@ -77,7 +76,7 @@


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {
'default': {
Expand All @@ -91,28 +90,27 @@
}


# Logging
# https://docs.djangoproject.com/en/1.8/topics/logging/
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
'loggers': {
'watchman': {
'handlers': ['console'],
'level': 'DEBUG',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
}
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
# https://docs.djangoproject.com/en/1.11/topics/i18n/

LANGUAGE_CODE = 'en-us'

Expand All @@ -126,6 +124,6 @@


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
# https://docs.djangoproject.com/en/1.11/howto/static-files/

STATIC_URL = '/static/'
17 changes: 16 additions & 1 deletion sample_project/sample_project/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
"""sample_project URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import include, url
from django.contrib import admin
import watchman.views


urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', admin.site.urls),
url(r'^watchman/', include('watchman.urls')),
url(r'^watchman/bare/', watchman.views.bare_status, name='bare_status'),
]
2 changes: 1 addition & 1 deletion sample_project/sample_project/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""

import os
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
)
8 changes: 3 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
[tox]
envlist =
covclean,
py27-dj{18,19,110,111},
py{35,36}-dj{18,19,110,111,20},
py27-dj111,
py{35,36,37}-dj{111,20,21},
coverage

[testenv]
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/watchman
commands = coverage run --parallel --source watchman runtests.py {posargs}
deps =
dj18: Django>=1.8,<1.9
dj19: Django>=1.9,<1.10
dj110: Django>=1.10,<1.11
dj111: Django>=1.11,<2.0
dj20: Django>=2.0,<2.1
dj21: Django>=2.1,<2.2
-r{toxinidir}/requirements-test.txt

[testenv:covclean]
Expand Down

0 comments on commit b9ff64a

Please sign in to comment.