Skip to content

Commit

Permalink
Feat/better compatibility and update ci cd (#57)
Browse files Browse the repository at this point in the history
* chore: remove DJANGO_2_2 reference since it is EOL now

* feat: update github actions

These github actions has some outdated actions. This updates them to the
latest available . Also, Python3.12 is the standard now

* fix: cleanup lint issue and also upgrade pyproject

* fix: tests and issues with CI builds

* fix: remove the option context arg as Django 2.2 is EOL

---------

Co-authored-by: Vinit Kumar <[email protected]>
  • Loading branch information
vinitkumar authored Nov 22, 2024
1 parent ebae665 commit 47864a0
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 97 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
python-version: "3.12"
cache: "pip"
- run: |
python -m pip install --upgrade pip
pip install ruff
Expand Down
44 changes: 22 additions & 22 deletions .github/workflows/publish-to-live-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ jobs:
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
48 changes: 24 additions & 24 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@ jobs:
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://test.pypi.org/legacy/
skip_existing: true
52 changes: 24 additions & 28 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,33 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12"] # latest release minus two
requirements-file: [
dj42_cms311.txt,
dj42_cms41.txt,
dj50_cms41.txt,
dj51_cms41.txt
]
os: [
ubuntu-20.04,
]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
requirements-file:
[dj42_cms311.txt, dj42_cms41.txt, dj50_cms41.txt, dj51_cms41.txt]
os: [ubuntu-20.04]
exclude:
- python-version: "3.9"
requirements-file: dj50_cms41.txt
- python-version: "3.9"
requirements-file: dj51_cms41.txt
- python-version: "3.9"
requirements-file: dj50_cms41.txt
- python-version: "3.9"
requirements-file: dj51_cms41.txt

steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}

uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements/${{ matrix.requirements-file }}
python setup.py install
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements/${{ matrix.requirements-file }}
python setup.py install
- name: Run coverage
run: coverage run tests/settings.py
- name: Run coverage
run: coverage run tests/settings.py

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v1
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
14 changes: 1 addition & 13 deletions djangocms_attributes_field/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,7 @@ def formfield(self, **kwargs):
defaults["excluded_keys"] = self.excluded_keys
return super().formfield(**defaults)

# This was added to keep backwards compatibility with Django 2.2 while also
# avoiding a RemovedInDjango30Warning caused by the deprecation of
# context argument
if DJANGO_2_2:
def from_db_value(self, value,
expression=None, connection=None, context=None):
self._from_db_value(value)
else:
def from_db_value(self, value,
expression=None, connection=None):
self._from_db_value(value)

def _from_db_value(self, value):
def from_db_value(self, value, expression=None, connection=None):
"""
This is a temporary workaround for #7 taken from
https://bitbucket.org/schinckel/django-jsonfield/pull-requests/32/make-from_db_value-compatible-with/diff
Expand Down
5 changes: 2 additions & 3 deletions djangocms_attributes_field/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from platform import python_version
from django import get_version

from distutils.version import LooseVersion
from platform import python_version

from django import get_version

DJANGO_VERSION = get_version()
PYTHON_VERSION = python_version()
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ ignore="H023,T003,H006,H031,D018,H021,H025"
profile="django"

[tool.ruff]
exclude = [
lint.exclude = [
".env",
".venv",
"**/migrations/**",
]
ignore = [
lint.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 = [
lint.select = [
"I",
"E",
"F",
Expand Down

0 comments on commit 47864a0

Please sign in to comment.