Skip to content

Commit f171685

Browse files
authored
Merge pull request #6 from Gandi/features/uv
Features/uv
2 parents e75689f + debbfea commit f171685

30 files changed

+3367
-1513
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Build envsub tarballs for supported python.
2+
3+
name: "Build artifact"
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
release-version:
9+
required: true
10+
type: string
11+
dry-run:
12+
required: true
13+
type: boolean
14+
python-version:
15+
required: true
16+
type: string
17+
pull_request:
18+
paths:
19+
# When we change pyproject.toml, we want to ensure that the maturin builds still work.
20+
- pyproject.toml
21+
# And when we change this workflow itself...
22+
- .github/workflows/build-artifacts.yml
23+
24+
concurrency:
25+
group: sdist-${{ github.workflow }}-${{ github.ref }}
26+
cancel-in-progress: true
27+
28+
jobs:
29+
sdist:
30+
name: Build artifact for ${{ inputs.release-version }} ${{ inputs.dry-run && '(dry-run)' || '' }}
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: actions/setup-python@v5
35+
with:
36+
python-version: ${{ inputs.python-version }}
37+
38+
- name: Install uv
39+
uses: astral-sh/setup-uv@v3
40+
41+
- name: Install the project
42+
run: uv sync
43+
44+
- name: Build tarball
45+
run: uv build
46+
47+
- name: "Upload sdist"
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: pypi_files
51+
path: dist/*

.github/workflows/main.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/publish-doc.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Doc
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
release-version:
7+
required: true
8+
type: string
9+
dry-run:
10+
required: true
11+
type: boolean
12+
13+
workflow_dispatch:
14+
15+
jobs:
16+
pages:
17+
runs-on: ubuntu-latest
18+
environment:
19+
name: github-pages
20+
url: ${{ steps.deployment.outputs.page_url }}
21+
permissions:
22+
pages: write # Grants write access for GitHub Pages
23+
id-token: write # Enables id-token for OIDC tokens
24+
steps:
25+
- id: deployment
26+
uses: sphinx-notes/pages@v3
27+
with:
28+
documentation_path: docs/source
29+
publish: ${{ !inputs.dry-run }}
30+
python_version: 3.12

.github/workflows/publish-pypi.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Publish a release to PyPI.
2+
#
3+
name: "Publish to PyPI"
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
release-version:
9+
required: true
10+
type: string
11+
dry-run:
12+
required: true
13+
type: boolean
14+
15+
jobs:
16+
pypi-publish:
17+
name: Upload to PyPI ${{ inputs.release-version }} ${{ inputs.dry-run && '(dry-run)' || '' }}
18+
runs-on: ubuntu-latest
19+
if: ${{ !inputs.dry-run }}
20+
permissions:
21+
contents: read
22+
id-token: write
23+
steps:
24+
- uses: actions/download-artifact@v4
25+
with:
26+
pattern: pypi_files
27+
path: dist
28+
merge-multiple: true
29+
30+
- uses: pdm-project/setup-pdm@v4
31+
with:
32+
python-version: 3.12
33+
34+
- name: Publish package distributions to PyPI
35+
run: pdm publish --no-build
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: tests artifacts
2+
3+
# Controls when the workflow will run
4+
on:
5+
# Allows you to run this workflow manually from the Actions tab
6+
workflow_call:
7+
inputs:
8+
release-version:
9+
required: true
10+
type: string
11+
description: "release number"
12+
dry-run:
13+
required: true
14+
type: boolean
15+
description: "blank run means that the release will not be pushed"
16+
17+
jobs:
18+
test-sdist:
19+
name: test tarball archive of ${{ inputs.release-version }} ${{ inputs.dry-run && '(dry-run)' || '' }}
20+
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
24+
steps:
25+
- uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- uses: actions/download-artifact@v4
30+
with:
31+
pattern: pypi_files
32+
path: dist
33+
merge-multiple: true
34+
35+
- name: "Install"
36+
run: |
37+
pip install dist/wagtail-oauth2-*.whl --force-reinstall
38+
39+
- name: "Test sdist"
40+
run: |
41+
python -c "from wagtail_oauth2 import __version__; print(__version__, end='')"

.github/workflows/tests.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Django CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: chartboost/ruff-action@v1
20+
21+
- uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v3
27+
28+
- name: Install the project
29+
run: uv sync --group dev
30+
31+
- name: Run tests
32+
run: |
33+
uv run pytest tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml --cov=wagtail_oauth2 --cov-report=xml --cov-report=html
34+
35+
- name: Upload pytest test results
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: pytest-results-${{ matrix.python-version }}
39+
path: junit/test-results-${{ matrix.python-version }}.xml
40+
41+
# FIXME = I don't see wagtail-oauth2 on codecov ( the token is now mandatory )
42+
# - name: Upload test results to Codecov
43+
# if: ${{ !cancelled() }} && matrix.python-version == '3.12' && github.event_name != 'workflow_dispatch'
44+
# uses: codecov/test-results-action@v1
45+
# with:
46+
# token: ${{ secrets.CODECOV_TOKEN }}
47+
# files: junit/test-results-${{ matrix.python-version }}.xml
48+
49+
# - name: Codecov
50+
# if: matrix.python-version == '3.12' && github.event_name != 'workflow_dispatch'
51+
# uses: codecov/codecov-action@v4
52+
# with:
53+
# token: ${{ secrets.CODECOV_TOKEN }}
54+
# files: coverage.xml

Justfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package := 'wagtail_oauth2'
2+
default_test_suite := 'tests'
3+
4+
install:
5+
uv sync --group dev --frozen
6+
7+
update:
8+
uv sync --group dev
9+
10+
upgrade:
11+
uv sync --group dev --upgrade
12+
13+
doc:
14+
uv sync --group dev --group doc
15+
cd docs && uv run make html
16+
xdg-open docs/build/html/index.html
17+
18+
cleandoc:
19+
cd docs && uv run make clean
20+
21+
lint:
22+
uv run ruff check .
23+
24+
test: lint unittest
25+
26+
unittest test_suite=default_test_suite:
27+
uv run pytest -sxv {{test_suite}}
28+
29+
lf:
30+
uv run pytest -sxvvv --lf
31+
32+
cov test_suite=default_test_suite:
33+
rm -f .coverage
34+
rm -rf htmlcov
35+
uv run pytest --cov-report=html --cov={{package}} {{test_suite}}
36+
xdg-open htmlcov/index.html
37+
38+
fmt:
39+
uv run ruff check --fix .
40+
uv run ruff format src
41+
42+
release major_minor_patch: test && changelog
43+
uvx --with=pdm,pdm-bump --python-preference system pdm bump {{major_minor_patch}}
44+
uv sync --group dev --frozen
45+
46+
changelog:
47+
uv run python scripts/write_changelog.py
48+
cat CHANGELOG.rst >> CHANGELOG.rst.new
49+
rm CHANGELOG.rst
50+
mv CHANGELOG.rst.new CHANGELOG.rst
51+
$EDITOR CHANGELOG.rst
52+
53+
publish:
54+
git commit -am "Release $(uv run scripts/get_version.py)"
55+
git tag "v$(uv run scripts/get_version.py)"
56+
git push
57+
git push origin "v$(uv run scripts/get_version.py)"

README.rst

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@ Wagtail OAuth2
66
:target: https://wagtail-oauth2.readthedocs.io/en/latest/?badge=latest
77
:alt: Documentation Status
88

9-
.. image:: https://github.com/Gandi/wagtail-oauth2/actions/workflows/main.yml/badge.svg
10-
:target: https://github.com/Gandi/wagtail-oauth2/actions/workflows/main.yml
9+
.. image:: https://github.com/Gandi/wagtail-oauth2/actions/workflows/tests.yml/badge.svg
10+
:target: https://github.com/Gandi/wagtail-oauth2/actions/workflows/tests.yml
1111
:alt: Build Status
1212

1313

14-
.. image:: https://codecov.io/gh/Gandi/wagtail-oauth2/branch/main/graph/badge.svg?token=VN14GVV3Y0
15-
:target: https://codecov.io/gh/Gandi/wagtail-oauth2
16-
:alt: Coverage
17-
18-
1914
Plugin to replace Wagtail default login by an OAuth2.0 Authorization Server.
2015

2116
What is wagtail-oauth2
@@ -34,4 +29,4 @@ Read More
3429
You can read the `full documentation of this library here`_.
3530

3631

37-
.. _`full documentation of this library here`: https://wagtail-oauth2.readthedocs.io/en/latest/
32+
.. _`full documentation of this library here`: https://wagtail-oauth2.readthedocs.io/en/latest/

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#
1313
import os
1414
import sys
15+
1516
import tomlkit
1617

1718
sys.path.insert(0, os.path.abspath("../../src"))

docs/source/users/oauth2_settings.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The settings `OAUTH2_LOAD_USERINFO` is a function that takes an `access_token` i
4747
and builds a python dict or raises a `PermissionDenied` error.
4848

4949
Basically, this method is about fetching some information on the user loaded using
50-
OAuth2.0 API and deciding to grant the user to log in, and to get the role of
50+
OAuth2.0 API and deciding to grant the user to log in, and to get the role of
5151
that user.
5252

5353
The userinfo dict contains the following keys:
@@ -87,11 +87,11 @@ Exemple of settings
8787

8888
def load_userinfo(access_token):
8989
try:
90-
# Real code consume an api with a header
90+
# Real code consume an api with a header
9191
# f"Authorization: Bearer {access_token}"
9292
return USERS[access_token]
93-
except KeyError:
94-
raise PermissionDenied
93+
except KeyError as exc:
94+
raise PermissionDenied from exc
9595

9696

9797
OAUTH2_LOAD_USERINFO = load_userinfo

0 commit comments

Comments
 (0)