Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Django CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
"Linting":
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9.x"
- name: Install Dependencies
run: |
python3 -m pip install --upgrade pip
pip install flake8 coverage
- name: Run flake8
run: flake8 .

"Build-and-Test":
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: lazysignup
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres_password
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mariadb:
image: mariadb:latest
env:
MYSQL_USER: travis
MYSQL_PASSWORD: mypassword
MYSQL_DATABASE: lazysignup
MYSQL_ROOT_PASSWORD: myrootpassword
ports:
- 3306:3306
# Set health checks to wait until postgres has started
options: >-
--health-cmd mysqladmin ping
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
max-parallel: 4
matrix:
python-version:
# - "3.6.x"
# - "3.7.x"
# - "3.8.x"
# - "3.9.x"
- "3.10.x"
django-version:
# - "2.2"
# - "3.2"
- "4.0"
db:
- "postgres"
# - "mysql"
settings:
- "lazysignup.tests.settings"
- "custom_user_tests.settings"
exclude:
- django-version: "2.2"
python-version: "3.10.x"

- django-version: "4.0"
python-version: "3.6.x"
- django-version: "4.0"
python-version: "3.7.x"

steps:
- uses: actions/checkout@v2
- name: Install database clients
run: |
apt update
apt install --yes mariadb-server postgresql-client
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python3 -m pip install --upgrade pip
pip install django==${{ matrix.django-version }}
pip install -e .[all]
- name: Initialize database
env:
DB: ${{ matrix.db }}
PGUSER: postgres
PGPASSWORD: postgres_password
PGDATABASE: lazysignup
PGPORT: 5432
MYSQL_PORT: 3306
run: |
[ "$DB" == 'postgres' ] && psql -U postgres -c 'CREATE DATABASE lazysignup;'
[ "$DB" == 'mysql' ] && mysql -e 'CREATE DATABASE lazysignup;'
- name: Run Tests
env:
DB: ${{ matrix.db }}
SETTINGS: ${{ matrix.settings }}
run: |
coverage run manage.py test --settings=$SETTINGS
coverage report --fail-under=98
45 changes: 32 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
sudo: false
addons:
postgresql: "13"
language: python
python:
- "3.5"
- "3.6"
addons:
postgresql: "9.4"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
env:
matrix:
- DJANGO_VERSION="==2.0" DB="postgres"
- DJANGO_VERSION="==2.0" DB="mysql"
- DJANGO_VERSION="==2.1" DB="postgres"
- DJANGO_VERSION="==2.1" DB="mysql"
- DJANGO_VERSION="2.2" DB="postgres"
- DJANGO_VERSION="2.2" DB="mysql"
- DJANGO_VERSION="3.2" DB="postgres"
- DJANGO_VERSION="3.2" DB="mysql"
- DJANGO_VERSION="4.0" DB="postgres"
- DJANGO_VERSION="4.0" DB="mysql"
jobs:
exclude:
- python: "3.10"
env: DJANGO_VERSION="2.2" DB="postgres"
- python: "3.10"
env: DJANGO_VERSION="2.2" DB="mysql"
- python: "3.6"
env: DJANGO_VERSION="4.0" DB="postgres"
- python: "3.6"
env: DJANGO_VERSION="4.0" DB="mysql"
- python: "3.7"
env: DJANGO_VERSION="4.0" DB="postgres"
- python: "3.7"
env: DJANGO_VERSION="4.0" DB="mysql"

# command to install dependencies
install:
- pip install Django$DJANGO_VERSION flake8 coverage
- pip install Django==$DJANGO_VERSION flake8 coverage
- pip install -e .[all]
# command to run tests
before_script:
- psql -c 'CREATE DATABASE lazysignup;' -U postgres
- mysql -e 'CREATE DATABASE lazysignup;'
- "[ \"$DB\" == 'postgres' ] && psql -c 'CREATE DATABASE lazysignup;' -U postgres"
- "[ \"$DB\" == 'mysql' ] && mysql -e 'CREATE DATABASE lazysignup;'"
script:
- flake8 .
- coverage run manage.py test --settings=lazysignup.tests.settings
- coverage report --fail-under=98
- psql -c 'DROP DATABASE IF EXISTS test_lazysignup;' -U postgres
- mysql -e 'DROP DATABASE IF EXISTS test_lazysignup;'
- "[ \"$DB\" == 'postgres' ] && psql -c 'DROP DATABASE IF EXISTS test_lazysignup;' -U postgres"
- "[ \"$DB\" == 'mysql' ] && mysql -e 'DROP DATABASE IF EXISTS test_lazysignup;'"
- coverage erase
- coverage run manage.py test --settings=custom_user_tests.settings
- coverage report --fail-under=98
Expand Down
2 changes: 1 addition & 1 deletion custom_user_tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
'PASSWORD': 'lazysignup',
}
else:
raise RuntimeError('Unsupported test DB {0}'.format(test_db))
raise RuntimeError(f'Unsupported test DB {test_db}')

DATABASES = {
'default': db_config
Expand Down
2 changes: 0 additions & 2 deletions lazysignup/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# flake8: noqa
from .version import __version__

default_app_config = 'lazysignup.apps.LazySignupConfig'
3 changes: 2 additions & 1 deletion lazysignup/signals.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import django.dispatch

converted = django.dispatch.Signal(providing_args=['user'])
# Providing args: user
converted = django.dispatch.Signal()
2 changes: 1 addition & 1 deletion lazysignup/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
try:
db_config = DB_CONFIGS[test_db]
except KeyError:
raise RuntimeError('Unsupported test DB {0}'.format(test_db))
raise RuntimeError(f'Unsupported test DB {test_db}')

DATABASES = {
'default': db_config
Expand Down
2 changes: 1 addition & 1 deletion lazysignup/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from lazysignup.signals import converted
from lazysignup.utils import is_lazy_user

if settings.AUTH_USER_MODEL is 'auth.User':
if settings.AUTH_USER_MODEL == 'auth.User':
from lazysignup.tests.forms import GoodUserCreationForm
else:
from custom_user_tests.forms import GoodUserCreationForm
Expand Down
2 changes: 1 addition & 1 deletion lazysignup/tests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.conf import settings

if settings.AUTH_USER_MODEL is 'auth.User': # pragma: no cover
if settings.AUTH_USER_MODEL == 'auth.User': # pragma: no cover
from lazysignup.tests.forms import GoodUserCreationForm
else: # pragma: no cover
from custom_user_tests.forms import GoodUserCreationForm
Expand Down