Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 29 additions & 25 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,37 @@ jobs:
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install Tox
run: pip install tox tox-gh-actions
- name: Run Tox
run: tox
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v5


lint:
name: Lint
runs-on: ubuntu-latest
strategy:
matrix:
tox_env: [flake8, docs]
tox_env: [ruff, docs]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v6
with:
python-version: "3.10"
python-version: "3.12"
- name: Install Tox
run: pip install tox
- name: Run tox
Expand All @@ -65,23 +63,29 @@ jobs:
if: ${{ github.ref=='refs/heads/main' && github.event_name!='pull_request' }}

steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Check release
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Check if new release
id: check_release
shell: python
run: |
python -m pip install --upgrade pip
python -m pip install wheel twine poetry githubrelease httpx==0.16.1 autopub
echo "##[set-output name=release;]$(autopub check)"
- name: Publish
if: ${{ steps.check_release.outputs.release=='' }}
import tomllib, urllib.request, json, os
with open("pyproject.toml", "rb") as f:
current = tomllib.load(f)["project"]["version"]
try:
data = json.load(urllib.request.urlopen("https://pypi.org/pypi/django-elevate/json"))
published = data["info"]["version"]
except Exception:
published = ""
new_release = current != published
with open(os.environ["GITHUB_OUTPUT"], "a") as out:
out.write(f"new_release={'true' if new_release else 'false'}\n")
out.write(f"version={current}\n")
- name: Build and publish
if: steps.check_release.outputs.new_release == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_PASSWORD }}
run: |
git remote set-url origin https://$GITHUB_TOKEN@github.com/${{ github.repository }}
autopub deploy
uv build
uv publish
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.11.6"
hooks:
# Run the linter.
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
# Run the formatter.
- id: ruff-format
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

39 changes: 17 additions & 22 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,38 @@
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.contenttypes',

'elevate',
"django.contrib.auth",
"django.contrib.sessions",
"django.contrib.contenttypes",
"elevate",
]

MIDDLEWARE_CLASSES = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
MIDDLEWARE = [
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
]


def pytest_report_header(config):
return 'made with love: <3'
return "made with love: <3"


def pytest_configure(config):
from django.conf import settings

settings.configure(
AUTHENTICATION_BACKENDS=[
'tests.base.FooPasswordBackend',
'tests.base.StubPasswordBackend',
"tests.base.FooPasswordBackend",
"tests.base.StubPasswordBackend",
],
DEBUG=True,
DATABASE_ENGINE='sqlite3',
DATABASES={
'default': {
'NAME': ':memory:',
'ENGINE': 'django.db.backends.sqlite3',
'TEST_NAME': ':memory:',
"default": {
"NAME": ":memory:",
"ENGINE": "django.db.backends.sqlite3",
},
},
DATABASE_NAME=':memory:',
TEST_DATABASE_NAME=':memory:',
INSTALLED_APPS=INSTALLED_APPS,
MIDDLEWARE_CLASSES=MIDDLEWARE_CLASSES,
PASSWORD_HASHERS=['django.contrib.auth.hashers.MD5PasswordHasher'],
ROOT_URLCONF='tests.urls',
SECRET_KEY='test',
MIDDLEWARE=MIDDLEWARE,
PASSWORD_HASHERS=["django.contrib.auth.hashers.MD5PasswordHasher"],
ROOT_URLCONF="tests.urls",
SECRET_KEY="test",
)
10 changes: 0 additions & 10 deletions dev-requirements.txt

This file was deleted.

Loading