Skip to content

Commit

Permalink
Ruff formatter, GitHub Action
Browse files Browse the repository at this point in the history
poetry
pyproject.toml single config
added Django 5.1
pypi trusted publish
  • Loading branch information
llybin committed Sep 11, 2024
1 parent 032ebd9 commit 18d7612
Show file tree
Hide file tree
Showing 25 changed files with 904 additions and 309 deletions.
24 changes: 22 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,36 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
charset = utf-8

# Docstrings and comments use max_line_length = 119
[*.py]
max_line_length = 119

# Use 2 spaces for frontend files
[{*.html,*.js,*.css}]
indent_size = 2

[{*.yml,*.yaml}]
indent_size = 2

# The JSON files contain newlines inconsistently
[*.json]
indent_size = 2
insert_final_newline = false

# Minified JavaScript files shouldn't be changed
[**.min.js]
insert_final_newline = false

# Batch files use tabs for indentation
[{*.bat,*.sh,Dockerfile}]
indent_style = tab

[*.md]
trim_trailing_whitespace = false
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github: [llybin]
github: [ llybin ]
48 changes: 20 additions & 28 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]
types: [ published ]

permissions:
contents: read

jobs:
deploy:

pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest

permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true
11 changes: 11 additions & 0 deletions .github/workflows/ruff.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Ruff
on: [ push, pull_request ]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
- uses: chartboost/ruff-action@v1
with:
args: 'format --check'
98 changes: 56 additions & 42 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,63 @@ jobs:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
django-version: [ "3.2", "4.0", "4.1", "4.2", "5.0"]
django-version: [ "3.2", "4.0", "4.1", "4.2", "5.0", "5.1" ]
drf-version: [ "3.11", "3.12", "3.13", "3.14", "3.15" ]
exclude:
# https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django
- django-version: "4.2"
python-version: "3.8"
- django-version: "4.2"
python-version: "3.9"
- django-version: "5.0"
python-version: "3.8"
- django-version: "5.0"
python-version: "3.9"
# https://www.django-rest-framework.org/community/release-notes/
- django-version: "4.2"
drf-version: "3.11"
- django-version: "4.2"
drf-version: "3.12"
- django-version: "4.2"
drf-version: "3.13"
- django-version: "5.0"
drf-version: "3.11"
- django-version: "5.0"
drf-version: "3.12"
- django-version: "5.0"
drf-version: "3.13"
# https://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-django
- django-version: "4.2"
python-version: "3.8"
- django-version: "4.2"
python-version: "3.9"
- django-version: "5.0"
python-version: "3.8"
- django-version: "5.0"
python-version: "3.9"
- django-version: "5.1"
python-version: "3.8"
- django-version: "5.1"
python-version: "3.9"
# https://www.django-rest-framework.org/community/release-notes/
- django-version: "4.2"
drf-version: "3.11"
- django-version: "4.2"
drf-version: "3.12"
- django-version: "4.2"
drf-version: "3.13"
- django-version: "5.0"
drf-version: "3.11"
- django-version: "5.0"
drf-version: "3.12"
- django-version: "5.0"
drf-version: "3.13"
- django-version: "5.1"
drf-version: "3.11"
- django-version: "5.1"
drf-version: "3.12"
- django-version: "5.1"
drf-version: "3.13"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
python -m pip install setuptools==71.0.0
python -m pip install "Django~=${{ matrix.django-version }}.0"
python -m pip install "djangorestframework~=${{ matrix.drf-version }}.0"
- name: Test with pytest
run: python setup.py test
- name: Send coverage to Codacy
env:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --upgrade pip
pip install poetry
poetry install --no-interaction
poetry run pip install "Django~=${{ matrix.django-version }}.0"
poetry run pip install "djangorestframework~=${{ matrix.drf-version }}.0"
- name: Test with pytest
run: poetry run pytest
- name: Send coverage to Codacy
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: |
pip install codacy-coverage==1.3.11
[ -z "$CODACY_PROJECT_TOKEN" ] && echo "CODACY_PROJECT_TOKEN is empty!" || python-codacy-coverage -r ./coverage.xml
run: |
pip install codacy-coverage==1.3.11
[ -z "$CODACY_PROJECT_TOKEN" ] && echo "CODACY_PROJECT_TOKEN is empty!" || python-codacy-coverage -r ./coverage.xml
109 changes: 92 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,94 @@
*.pyc
*.db
*~
.*

/site/
/htmlcov/
/coverage/
/build/
/dist/
/*.egg-info/
/env/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
coverage.*

!.coveragerc
!.editorconfig
!.gitignore
!.github
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# mkdocs documentation
/site

# mypy
.mypy_cache/
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

Loading

0 comments on commit 18d7612

Please sign in to comment.