Skip to content

Commit

Permalink
Update supported Python and Django versions (#136)
Browse files Browse the repository at this point in the history
* Update supported python and django version

No code changes required
Github actions update to let them run again
Add pre-commit CI support
  • Loading branch information
yakky committed Jul 25, 2022
1 parent 5aed37d commit f65e81c
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 51 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,34 @@ jobs:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
strategy:
matrix:
python-version: [3.8]
python-version: [3.9]
toxenv: [pep8, isort, black, pypi-description, docs, towncrier]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.toxenv }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.toxenv }}
- name: Cache tox
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: .tox
key: ${{ runner.os }}-lint-${{ matrix.toxenv }}-${{ hashFiles('setup.cfg') }}
restore-keys: |
${{ runner.os }}-lint-${{ matrix.toxenv }}-
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools tox>=1.8
python -m pip install --upgrade pip setuptools tox>3.23
- name: Test with tox
run: |
tox -e${{ matrix.toxenv }}
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Cache pip
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.toxenv }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.toxenv }}
- name: Cache tox
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: .tox
key: ${{ runner.os }}-tox-release-${{ hashFiles('setup.cfg') }}
restore-keys: |
${{ runner.os }}-tox-release-
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools tox>=1.8
python -m pip install --upgrade pip setuptools tox>3.23
- name: Build and publish
env:
TWINE_USERNAME: __token__
Expand Down
23 changes: 8 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.7, 3.6, 3.5]
django: [31,30, 22]
python-version: [3.10.0, 3.9, 3.8, 3.7]
django: [32, 31, 30, 22]
sekizai: [sekizai,nosekizai]
exclude:
- python-version: 3.5
django: 30
- python-version: 3.5
django: 31
- django: 31
sekizai: sekizai
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
Expand All @@ -32,7 +25,7 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-${{ matrix.toxenv }}
- name: Cache tox
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: .tox
key: ${{ runner.os }}-tox-${{ format('py-django{1}-{2}', matrix.python-version, matrix.django, matrix.sekizai) }}-${{ hashFiles('setup.cfg') }}
Expand All @@ -41,7 +34,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get install gettext
python -m pip install --upgrade pip tox>=3.5
python -m pip install --upgrade pip tox>=3.23
- name: Test with tox
env:
TOX_ENV: ${{ format('py-django{1}-{2}', matrix.python-version, matrix.django, matrix.sekizai) }}
Expand All @@ -52,11 +45,11 @@ jobs:
tox -e$TOX_ENV
.tox/$TOX_ENV/bin/coverage xml
.tox/$TOX_ENV/bin/coveralls
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
file: ./coverage.xml
files: ./coverage.xml
fail_ci_if_error: false
services:
redis:
Expand Down
15 changes: 9 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exclude: "(.idea|node_modules|.tox)"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -17,15 +17,15 @@ repos:
args:
- --remove
- repo: https://github.com/timothycrosley/isort
rev: "5.4.2"
rev: "5.10.1"
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 19.10b0
rev: 22.6.0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies:
Expand All @@ -40,14 +40,14 @@ repos:
- flake8-tidy-imports
- pep8-naming
- repo: https://github.com/econchick/interrogate
rev: 1.2.0
rev: 1.5.0
hooks:
- id: interrogate
args:
- "-cpyproject.toml"
- "--quiet"
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.2
rev: v2.37.2
hooks:
- id: pyupgrade
args:
Expand All @@ -60,3 +60,6 @@ repos:
language: system
pass_filenames: false
always_run: true
ci:
skip:
- towncrier
1 change: 1 addition & 0 deletions changes/135.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update tox environments and github actions
1 change: 1 addition & 0 deletions cms_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
META_USE_SCHEMAORG_PROPERTIES=True,
FILE_UPLOAD_TEMP_DIR=mkdtemp(),
TEST_RUNNER="app_helper.pytest_runner.PytestTestRunner",
SECRET_KEY="dont-use-me",
)

try:
Expand Down
10 changes: 6 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ classifiers =
Framework :: Django
Framework :: Django :: 2.2
Framework :: Django :: 3.0
Framework :: Django :: 3.1
Framework :: Django :: 3.2
Environment :: Web Environment
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10

[options]
include_package_data = True
Expand All @@ -57,7 +59,7 @@ install_requires =
setup_requires =
setuptools
packages = meta
python_requires = >=3.5
python_requires = >=3.7
test_suite = cms_helper.run
zip_safe = False

Expand All @@ -67,7 +69,7 @@ meta = *.html *.png *.gif *js *jpg *jpeg *svg *py *mo *po

[options.extras_require]
docs =
django<3.1
django<4.0

[upload]
repository = https://upload.pypi.org/legacy/
Expand Down
22 changes: 11 additions & 11 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@task
def clean(c):
""" Remove artifacts and binary files. """
"""Remove artifacts and binary files."""
c.run("python setup.py clean --all")
patterns = ["build", "dist"]
patterns.extend(glob("*.egg*"))
Expand All @@ -25,19 +25,19 @@ def clean(c):

@task
def lint(c):
""" Run linting tox environments. """
"""Run linting tox environments."""
c.run("tox -epep8,isort,black,pypi-description")


@task # NOQA
def format(c): # NOQA
""" Run code formatting tasks. """
"""Run code formatting tasks."""
c.run("tox -eblacken,isort_format")


@task
def towncrier_check(c): # NOQA
""" Check towncrier files. """
"""Check towncrier files."""
output = io.StringIO()
c.run("git branch --contains HEAD", out_stream=output)
skipped_branch_prefix = ["pull/", "develop", "master", "HEAD"]
Expand Down Expand Up @@ -90,47 +90,47 @@ def towncrier_check(c): # NOQA

@task
def test(c):
""" Run test in local environment. """
"""Run test in local environment."""
c.run("python setup.py test")


@task
def test_all(c):
""" Run all tox environments. """
"""Run all tox environments."""
c.run("tox")


@task
def coverage(c):
""" Run test with coverage in local environment. """
"""Run test with coverage in local environment."""
c.run("coverage erase")
c.run("run setup.py test")
c.run("report -m")


@task
def tag_release(c, level):
""" Tag release version. """
"""Tag release version."""
c.run("bumpversion --list %s --no-tag" % level)


@task
def tag_dev(c, level="patch"):
""" Tag development version. """
"""Tag development version."""
c.run("bumpversion --list %s --message='Bump develop version [ci skip]' --no-tag" % level)


@task(pre=[clean])
def docbuild(c):
""" Build documentation. """
"""Build documentation."""
os.chdir("docs")
build_dir = os.environ.get("BUILD_DIR", "_build/html")
c.run("python -msphinx -W -b html -d _build/doctrees . %s" % build_dir)


@task(docbuild)
def docserve(c):
""" Serve docs at http://localhost:$DOCS_PORT/ (default port is 8000). """
"""Serve docs at http://localhost:$DOCS_PORT/ (default port is 8000)."""
from livereload import Server

server = Server()
Expand Down
9 changes: 5 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ envlist =
pep8
pypi-description
towncrier
py{38,37,36}-django{31,30}-{sekizai,nosekizai}
py{38,37,36,35}-django{22}-{sekizai,nosekizai}
py{310,39,38,37}-django{32,31,30,22}-{sekizai,nosekizai}
minversion = 3.23

[testenv]
commands = {env:COMMAND:python} cms_helper.py meta test {posargs}
deps =
django22: django~=2.2.0
django30: django~=3.0.0
django31: django~=3.1.0
django32: django~=3.2.0
sekizai: django-sekizai
-r{toxinidir}/requirements-test.txt
passenv =
Expand Down Expand Up @@ -45,7 +46,7 @@ skip_install = true
[testenv:isort]
commands =
{envpython} -m isort -c --df meta meta_mixin tests
deps = isort>5.3,<5.4
deps = isort>5.10,<5.11
skip_install = true

[testenv:isort_format]
Expand All @@ -70,7 +71,7 @@ skip_install = true
commands =
{envpython} -m invoke docbuild
deps =
django<3.1
django<4.0
invoke
sphinx
sphinx-rtd-theme
Expand Down

0 comments on commit f65e81c

Please sign in to comment.