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 and fsbraun committed May 19, 2024
1 parent 58fba22 commit 0f65aa8
Show file tree
Hide file tree
Showing 203 changed files with 1,482 additions and 339 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.10'
- 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.10'
- 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
84 changes: 63 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,37 +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.8, 3.9, '3.10' ]
requirements-file: [
dj32_cms40.txt,
dj42_cms40.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
22 changes: 19 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
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
Expand All @@ -16,18 +25,25 @@ repos:
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

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

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.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

# upgrade the isort version to fix compatiable issue withe peotry: https://stackoverflow.com/questions/75269700/pre-commit-fails-to-install-isort-5-11-4-with-error-runtimeerror-the-poetry-co
- repo: https://github.com/pycqa/isort
Expand Down
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
1 change: 0 additions & 1 deletion djangocms_snippet/__init__.py

This file was deleted.

This file was deleted.

Loading

0 comments on commit 0f65aa8

Please sign in to comment.