Skip to content

Commit 843fe39

Browse files
authored
πŸ‘·β€β™€οΈ Run CI tests in GitHub actions & Pre-Commit
- πŸ’₯ Python & Django version adjustments: - Drop support of Python 3.4, 3.5 - Drop support of Django 1.8, 1.9, 1.10, 1.11, 2.0, 2.1 - Add support for Python 3.6 - 3.9 - Add support for Django 2.2 - 3.2 - ❗️ Update tox.ini to reflect new supported envs - ❗️ Update test suite for Django 3.0 - πŸ—‘ Remove TravisCI & AppVeyor - ✨ Configure Pre-Commit - Use Flake8 to lint Python but not generated Python files like Django migrations - Use Black to autoformat Python - Use ISort to sort Python imports - Use Prettier to autoformat other formats like Markdown but ensure it skips Django Templates and confusable homoglyphs material - ✨ Add Github action to check package (i.e.: manifest, setup.py, etc) - ✨ Add Github action to test package (run Python tests) - ✨ Add Github action to test example projects - πŸ”¨ Update ISort config for ISort v5 - πŸ”¨ Add secret key to runtest script - βž– Remove setuptools, wheels, flake8 from requirements.txt - πŸ”§ setup.cfg: description-file β†’ description_file - πŸ”¨ Remove Python 2 compatibility material - patch_logger replaced with assertLogs https://docs.djangoproject.com/en/stable/releases/3.0/ https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertLogs - πŸ› Fix admin.W411: add request ctx to templates - πŸ› Fix models.W042: define default_auto_field - πŸŽ€ Improve docstrings based on Flake8 warnings - πŸŽ€ Fix N811: capitalize version constant - 🚧 Partial removal of Python 3.4 linting ignores PR #122
1 parent ae91086 commit 843fe39

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2147
-1661
lines changed

Diff for: β€Ž.bumpversion.cfg

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ current_version = 1.0.0
33
commit = True
44
tag = False
55
parse = (?P<major>\d+)\.(?P<minor>\d+)((\.(?P<patch>\d+))|((?P<level>(a|b|rc|final))(?P<prerelease>\d+)))
6-
serialize =
6+
serialize =
77
{major}.{minor}{level}{prerelease}
88
{major}.{minor}.{patch}
99

1010
[bumpversion:part:level]
1111
first_value = final
12-
values =
12+
values =
1313
final
1414
a
1515
b
@@ -23,4 +23,3 @@ first_value = 1
2323
[bumpversion:file:docs/conf.py]
2424

2525
[bumpversion:file:setup.py]
26-

Diff for: β€Ž.editorconfig

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; https://editorconfig.org/
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
indent_size = 4
9+
indent_style = tab
10+
insert_final_newline = true
11+
max_line_length = 80
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
indent_style = space
16+
; Robert-Bringhurst in The Elements of Typographic Style:
17+
; Anything from 45 to 75 characters is widely regarded as a satisfactory
18+
; length of line for a single-column page […] The 66-character line […]
19+
; is widely regarded as ideal (25).
20+
;
21+
; PEP 8 limits long blocks of text to 72 characters.
22+
; https://www.python.org/dev/peps/pep-0008/#maximum-line-length
23+
max_line_length = 72
24+
25+
[*.py]
26+
indent_style = space
27+
max_line_length = 79
28+
29+
[*.{yaml,yml}]
30+
indent_style = space

Diff for: β€Ž.flake8

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[flake8]
2+
# https://flake8.readthedocs.org/en/latest/
3+
select = B, B9, C, D, E, F, N, W
4+
ignore = B950, D104, D105, D106, D202, D400, E203, E266, E501, N803, N806, N815, W503
5+
exclude=
6+
src/*/migrations/*,
7+
example_*_project/*/migrations/*,
8+
max-complexity = 10
9+
max-line-length = 79

Diff for: β€Ž.github/ISSUE_TEMPLATE.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,27 @@ To Use this Template:
2323

2424
## Specifications
2525

26-
- Platform/System:
27-
- Python Version:
28-
- Django Version:
29-
- Improved User Version:
26+
- Platform/System:
27+
- Python Version:
28+
- Django Version:
29+
- Improved User Version:
3030

3131
## Expected Behavior
32+
3233
<!--- Tell us what should happen -->
3334

3435
## Actual Behavior
36+
3537
<!--- Tell us what happens instead of the expected behavior
3638
Attach screenshots if applicable. -->
3739

3840
## Context
41+
3942
<!--- How has this issue affected you? What are you trying to accomplish?
4043
Providing context helps us come up with a solution that is most useful in the real world -->
4144

4245
## Steps to Reproduce the Problem
46+
4347
<!--- Provide a link to a live example, or an unambiguous set of steps to
4448
reproduce this bug. Include code to reproduce, if relevant -->
4549

Diff for: β€Ž.github/workflows/check-project.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Check Package
2+
3+
on:
4+
push:
5+
branches: [development]
6+
pull_request:
7+
branches: [development]
8+
9+
env:
10+
PYTHONDONTWRITEBYTECODE: 1
11+
PYTHONWARNINGS: once
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: "3.9"
24+
25+
- name: Upgrade pip
26+
run: python3 -m pip install -U distlib pip setuptools wheel
27+
28+
- name: Get pip cache dir
29+
id: pip-cache
30+
run: echo "::set-output name=dir::$(pip cache dir)"
31+
32+
- name: Cache dependencies
33+
uses: actions/cache@v2
34+
with:
35+
path: ${{ steps.pip-cache.outputs.dir }}
36+
key:
37+
${{ runner.os }}-pip-${{ hashFiles('./requirements.txt')
38+
}}
39+
restore-keys: |
40+
${{ runner.os }}-pip-
41+
42+
- name: Install dependencies
43+
run: |
44+
python3 -m pip install -r ./requirements.txt
45+
46+
- name: Check Package
47+
run: |
48+
python3 setup.py check --strict --metadata --restructuredtext
49+
50+
- name: Check Manifest
51+
run: check-manifest

Diff for: β€Ž.github/workflows/run-project-tests.yml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Example Project Tests
2+
3+
on:
4+
push:
5+
branches: [development]
6+
pull_request:
7+
branches: [development]
8+
9+
env:
10+
PYTHONDONTWRITEBYTECODE: 1
11+
PYTHONWARNINGS: once
12+
13+
jobs:
14+
build:
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, windows-latest]
19+
# Django LTS versions & latest version only
20+
django-version: ["2.2", "3.2"]
21+
project: ["extension", "integration", "replacement"]
22+
exclude:
23+
# Django Registration 2 does not support Django 3.2
24+
- django-version: "3.2"
25+
project: "integration"
26+
27+
steps:
28+
- uses: actions/checkout@v2
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v2
32+
with:
33+
python-version: "3.9"
34+
35+
- name: Upgrade pip
36+
run: python3 -m pip install -U distlib pip setuptools wheel
37+
38+
- name: Get pip cache dir
39+
id: pip-cache
40+
run: echo "::set-output name=dir::$(pip cache dir)"
41+
42+
- name: Cache dependencies
43+
uses: actions/cache@v2
44+
with:
45+
path: ${{ steps.pip-cache.outputs.dir }}
46+
key:
47+
${{ runner.os }}-pip-${{ matrix.django-version }}-${{
48+
hashFiles('**/requirements.txt') }}
49+
restore-keys: |
50+
${{ runner.os }}-pip-
51+
52+
- name: Install dependencies
53+
run: |
54+
python3 -m pip install -r ./requirements.txt
55+
python3 setup.py develop
56+
python3 -m pip install -r ./example_${{ matrix.project }}_project/requirements.txt
57+
58+
- name: Install Django
59+
run: python3 -m pip install "Django~=${{ matrix.django-version }}"
60+
61+
- name: Python and Django versions
62+
run: |
63+
python3 --version
64+
echo "Django ${{ matrix.django-version }}: $(django-admin --version)"
65+
66+
- name: Run tests
67+
working-directory: ./example_${{ matrix.project }}_project
68+
run: python3 manage.py test

Diff for: β€Ž.github/workflows/run-tests.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Package Tests
2+
3+
on:
4+
push:
5+
branches: [development]
6+
pull_request:
7+
branches: [development]
8+
9+
env:
10+
PYTHONDONTWRITEBYTECODE: 1
11+
PYTHONWARNINGS: once
12+
13+
jobs:
14+
build:
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, windows-latest]
19+
python-version: ["3.6", "3.7", "3.8", "3.9"]
20+
django-version: ["2.2", "3.0", "3.1", "3.2"]
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v2
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
30+
- name: Upgrade pip
31+
run: python3 -m pip install -U distlib pip setuptools wheel
32+
33+
- name: Get pip cache dir
34+
id: pip-cache
35+
run: echo "::set-output name=dir::$(pip cache dir)"
36+
37+
- name: Cache dependencies
38+
uses: actions/cache@v2
39+
with:
40+
path: ${{ steps.pip-cache.outputs.dir }}
41+
key:
42+
${{ runner.os }}-pip-${{ matrix.django-version }}-${{
43+
hashFiles('./requirements.txt') }}
44+
restore-keys: |
45+
${{ runner.os }}-pip-
46+
47+
- name: Install dependencies
48+
run: |
49+
python3 -m pip install -r ./requirements.txt
50+
python3 setup.py develop
51+
52+
- name: Install Django
53+
run: python3 -m pip install "Django~=${{ matrix.django-version }}"
54+
55+
- name: Python and Django versions
56+
run: |
57+
echo "Python ${{ matrix.python-version }} & Django ${{ matrix.django-version }}"
58+
python3 --version
59+
echo "Django: $(django-admin --version)"
60+
61+
- name: Run tests
62+
run: python3 ./runtests.py

Diff for: β€Ž.isort.cfg

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
[settings]
22
balanced_wrapping=true
33
combine_as_imports=true
4-
force_add=true
5-
include_trailing_comma=true
4+
known_first_party=improved_user
65
known_third_party=
76
django
87
registration
9-
known_first_party=improved_user
10-
indent=' '
118
line_length=79
12-
multi_line_output=5
13-
not_skip=__init__.py
9+
profile=black
1410
skip=migrations

Diff for: β€Ž.pre-commit-config.yaml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
default_language_version:
4+
python: "python3.9"
5+
repos:
6+
# - repo: meta
7+
# hooks:
8+
# - id: check-hooks-apply
9+
# - id: check-useless-excludes
10+
- repo: https://github.com/pre-commit/pre-commit-hooks
11+
rev: v4.0.1
12+
hooks:
13+
- id: check-added-large-files
14+
args: [--maxkb=500]
15+
- id: check-case-conflict
16+
- id: check-json
17+
- id: check-merge-conflict
18+
- id: check-symlinks
19+
- id: check-yaml
20+
- id: debug-statements
21+
- id: detect-private-key
22+
- id: end-of-file-fixer
23+
- id: fix-byte-order-marker
24+
- id: mixed-line-ending
25+
args: [--fix=lf]
26+
- id: requirements-txt-fixer
27+
- id: trailing-whitespace
28+
- repo: https://github.com/pre-commit/mirrors-prettier
29+
rev: v2.4.1
30+
hooks:
31+
- id: prettier
32+
- repo: https://github.com/pycqa/isort
33+
rev: 5.9.3
34+
hooks:
35+
- id: isort
36+
- repo: https://github.com/ambv/black
37+
rev: 21.9b0
38+
hooks:
39+
- id: black
40+
- repo: https://gitlab.com/PyCQA/flake8
41+
rev: 3.9.2
42+
hooks:
43+
- id: flake8
44+
args: ["--config=.flake8"]
45+
additional_dependencies:
46+
[
47+
flake8-blind-except,
48+
flake8-bugbear,
49+
flake8-builtins,
50+
flake8-docstrings,
51+
flake8-logging-format,
52+
flake8-rst-docstrings,
53+
pep8-naming,
54+
]

Diff for: β€Ž.prettierignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Ignore all Django Template files:
2+
*.html
3+
4+
# Security & Validation files need not be formatted
5+
# See Django Registration documentation for more details
6+
example_integration_project/categories.json
7+
example_integration_project/confusables.json

Diff for: β€Ž.prettierrc.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bracketSameLine = false
2+
bracketSpacing = true
3+
proseWrap = "always"
4+
semi = false
5+
singleQuote = false
6+
trailingComma = "all"

0 commit comments

Comments
Β (0)