Skip to content

Commit

Permalink
chore: Package overhaul (#140)
Browse files Browse the repository at this point in the history
* ci: Update pre-commit

* ci: Run ruff formatter

* build: Move package in to src dir

* test: Update requirements building

* chore: Keeping git happy after moving to src

* ci: Add dependabot config

* ci: Update tests to run tox

* build: Project config

* test: Update tox setup

* build: Update setup to build_meta

* ci: Update pypi workflows

* ci: Update linter to ruff

* chore: Fix RUF012

* ci: Update linter trigger

* chore: Drop python 3.8

* chore: Drop python 3.8

* chore: Adjust coverage config
  • Loading branch information
marksweb authored Oct 26, 2023
1 parent 17c72b9 commit cf6e93a
Show file tree
Hide file tree
Showing 197 changed files with 1,664 additions and 454 deletions.
18 changes: 0 additions & 18 deletions .coveragerc

This file was deleted.

5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ quote_type = single
[*.rst]
max_line_length = 80

[*.yml]
[*.toml]
indent_size = 2

[*.{yml,yaml}]
indent_size = 2
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
50 changes: 21 additions & 29 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
name: Lint

on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

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

isort:
jobs:
ruff:
name: ruff
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- run: python -m pip install isort
- name: isort
uses: liskin/gh-problem-matcher-wrap@v1
uses: actions/setup-python@v4
with:
linters: isort
run: isort -c -rc -df djangocms_snippet
python-version: "3.11"
cache: 'pip'
- run: |
python -m pip install --upgrade pip
pip install ruff
- name: Run Ruff
working-directory: ./src
run: ruff djangocms_snippet
18 changes: 10 additions & 8 deletions .github/workflows/publish-to-live-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ 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-snippet
permissions:
id-token: write
steps:
- uses: actions/checkout@master
- name: Set up Python 3.9
uses: actions/setup-python@v1
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: '3.11'

- name: Install pypa/build
run: >-
Expand All @@ -31,9 +36,6 @@ jobs:
--outdir dist/
.
- name: PyPI - Publish distribution 📦
- 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 }}
21 changes: 12 additions & 9 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@ name: Publish Python 🐍 distributions 📦 to TestPyPI
on:
push:
branches:
- master
- main

jobs:
build-n-publish:
name: TestPyPI - Build and publish Python 🐍 distributions 📦
name: Build and publish Python 🐍 distributions 📦 to TestPyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://test.pypi.org/p/djangocms-snippet
permissions:
id-token: write
steps:
- uses: actions/checkout@master
- name: Set up Python 3.9
uses: actions/setup-python@v1
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: '3.11'

- name: Install pypa/build
run: >-
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/
repository-url: https://test.pypi.org/legacy/
skip_existing: true
87 changes: 63 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,79 @@
name: CodeCov

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

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

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

strategy:
fail-fast: false
matrix:
python-version: [ 3.7, 3.8, 3.9, ] # latest release minus two
requirements-file: [
dj22_cms37.txt,
dj22_cms38.txt,
dj30_cms37.txt,
dj30_cms38.txt,
dj31_cms38.txt,
]
os: [
ubuntu-20.04,
]
python-version:
- 3.9
- '3.10'
- '3.11'

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

uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: pip
cache-dependency-path: 'tests/requirements/*.txt'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements/${{ matrix.requirements-file }}
python setup.py install
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: unit-tests
steps:
- uses: actions/checkout@v4

- 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: Run coverage
run: coverage run setup.py test
- name: Combine coverage
run: |
python -m coverage combine
python -m coverage html --skip-covered --skip-empty
python -m coverage report
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v1
- name: Upload HTML report
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: html-report
path: htmlcov
56 changes: 36 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,50 @@
ci:
autofix_commit_msg: |
ci: auto fixes from pre-commit hooks
for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_commit_msg: 'ci: pre-commit autoupdate'
autoupdate_schedule: monthly

repos:
# Need to drop python 3.5 and 3.6 before we include python upgrade
# - repo: https://github.com/asottile/pyupgrade
# rev: v2.31.0
# hooks:
# - id: pyupgrade
# args: ["--py37-plus"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
hooks:
- id: pyupgrade
args: ["--py38-plus"]

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

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.270"
hooks:
- id: flake8
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/asottile/yesqa
rev: v1.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.2
hooks:
- id: yesqa
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-json
- id: check-merge-conflict
- id: mixed-line-ending
- id: check-symlinks
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.3.0
# hooks:
# - id: mypy
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changelog
=========

Unreleased
==========

* Drop support for Django < 3.2
* Drop support for Python < 3.9

3.1.1
=====

Expand Down
7 changes: 4 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
prune tests
include CHANGELOG.rst
include LICENSE
include pyproject.toml
include README.rst
recursive-include djangocms_snippet/locale *
recursive-include djangocms_snippet/templates *
recursive-exclude * *.py[co]
include src/*/py.typed
3 changes: 0 additions & 3 deletions djangocms_snippet/__init__.py

This file was deleted.

Loading

0 comments on commit cf6e93a

Please sign in to comment.