Skip to content

Commit

Permalink
feat: django 4.2 support (#59)
Browse files Browse the repository at this point in the history
* ci: Update workflows

* ci: Remove old test requirements

* ci: Add pre-commit

* ci: Generate new test requirements

* chore: Ruff fixes

* ci: Update tox

* ci: Add ruff conf

* build: Remove manifest exclude

* build: Update classifiers and bump to 3.0.1
  • Loading branch information
marksweb authored Jul 3, 2023
1 parent be56191 commit 5ccbf3e
Show file tree
Hide file tree
Showing 33 changed files with 1,548 additions and 173 deletions.
94 changes: 65 additions & 29 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,80 @@
name: CodeCov

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

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
coverage:
runs-on: ${{ matrix.os }}
tests:
name: ${{ matrix.database }} Python ${{ matrix.python-version }}
runs-on: ubuntu-22.04

strategy:
fail-fast: false
matrix:
python-version: [ 3.7, 3.8, 3.9, "3.10",] # latest release minus two
requirements-file: [
dj22_cms38.txt,
dj32_cms38.txt,
dj32_cms39.txt,
dj32_cms310.txt,
dj32_cms311.txt,
dj40_cms311.txt,
]
os: [
ubuntu-20.04,
]
exclude:
- python-version: 3.7
requirements-file: dj40_cms311.txt
python-version:
- 3.8
- 3.9
- '3.10'
- '3.11'

steps:
- uses: actions/checkout@v2
with:
fetch-depth: '2'
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@master
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Generate Report
allow-prereleases: true
cache: pip
cache-dependency-path: 'requirements/*.txt'

- name: Install dependencies
run: |
pip install -r tests/requirements/${{ matrix.requirements-file }}
coverage run setup.py test
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v1
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade 'tox>=4.0.0rc3'
- name: Run tox targets for ${{ matrix.python-version }}
run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d .)

- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: '.coverage*'

coverage:
name: Coverage
runs-on: ubuntu-22.04
needs: tests
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: python -m pip install --upgrade coverage[toml]

- name: Download data
uses: actions/download-artifact@v3
with:
name: coverage-data

- name: Combine coverage and fail if it's <100%
run: |
python -m coverage html --skip-covered --skip-empty
python -m coverage report --fail-under=100
- name: Upload HTML report
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: html-report
path: htmlcov
40 changes: 12 additions & 28 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,21 @@ concurrency:
cancel-in-progress: true

jobs:
flake8:
name: flake8
ruff:
name: ruff
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install flate8
run: pip install --upgrade flake8
- name: Run flake8
uses: liskin/gh-problem-matcher-wrap@v1
with:
linters: flake8
run: flake8

isort:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.9
- run: python -m pip install isort
- name: isort
uses: liskin/gh-problem-matcher-wrap@v1
with:
linters: isort
run: isort -c --df djangocms_file

python-version: '3.11'
allow-prereleases: true
cache: pip
- run: |
python -m pip install --upgrade pip
pip install ruff
- name: Run Ruff
run: |
ruff djangocms_file
10 changes: 6 additions & 4 deletions .github/workflows/publish-to-live-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to pypi
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/djangocms-file
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: '3.10'

Expand All @@ -34,6 +39,3 @@ jobs:
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
13 changes: 8 additions & 5 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to TestPyPI
runs-on: ubuntu-latest
environment:
name: test
url: https://test.pypi.org/p/djangocms-file
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: '3.10'

Expand All @@ -34,7 +39,5 @@ jobs:
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
repository-url: https://test.pypi.org/legacy/
skip-existing: true
45 changes: 45 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
ci:
autofix_commit_msg: |
ci: auto fixes from pre-commit hooks
for more information, see https://pre-commit.ci
autofix_prs: false
autoupdate_commit_msg: 'ci: pre-commit autoupdate'
autoupdate_schedule: monthly

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.7.0
hooks:
- id: pyupgrade
args: ["--py37-plus"]

- repo: https://github.com/adamchainz/django-upgrade
rev: '1.14.0'
hooks:
- id: django-upgrade
args: [--target-version, "3.2"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.275
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-merge-conflict
- id: debug-statements
- id: mixed-line-ending
- id: trailing-whitespace

- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
- id: codespell
8 changes: 4 additions & 4 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
Changelog
=========

unpublished
===========

* Added support for Django 3.2, Django 4.0
* Added github actions
3.0.1 (2023-07-03)
==================

* Added support for Django 4.2
* Fixed search_field to point to file_name


Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ include LICENSE
include README.rst
recursive-include djangocms_file/locale *
recursive-include djangocms_file/templates *
recursive-exclude * *.py[co]
2 changes: 1 addition & 1 deletion djangocms_file/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.0.0'
__version__ = '3.0.1'
3 changes: 1 addition & 2 deletions djangocms_file/cms_plugins.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.utils.translation import gettext_lazy as _

from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from django.utils.translation import gettext_lazy as _

from .models import File, Folder

Expand Down
5 changes: 1 addition & 4 deletions djangocms_file/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@
Enables the user to add a "File" plugin that displays a file wrapped by
an <anchor> tag.
"""
from cms.models import CMSPlugin
from django.conf import settings
from django.db import models
from django.utils.translation import gettext
from django.utils.translation import gettext_lazy as _

from cms.models import CMSPlugin

from djangocms_attributes_field.fields import AttributesField
from filer.fields.file import FilerFileField
from filer.fields.folder import FilerFolderField


LINK_TARGET = (
('_self', _('Open in same window')),
('_blank', _('Open in new window')),
Expand Down
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[tool.ruff]
exclude = [
".env",
".venv",
"**/migrations/**",
]
ignore = [
"E501", # line too long
"F403", # 'from module import *' used; unable to detect undefined names
"E701", # multiple statements on one line (colon)
"F401", # module imported but unused
]
line-length = 119
select = [
"I",
"E",
"F",
"W",
]
9 changes: 3 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@
'Operating System :: OS Independent',
'Programming Language :: Python',
'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',
'Programming Language :: Python :: 3.11',
'Framework :: Django',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.0',
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
'Framework :: Django :: 4.2',
'Framework :: Django CMS',
'Framework :: Django CMS :: 3.7',
'Framework :: Django CMS :: 3.8',
Expand Down
Loading

0 comments on commit 5ccbf3e

Please sign in to comment.