Skip to content

Commit 18e3521

Browse files
INIT
0 parents  commit 18e3521

221 files changed

Lines changed: 50007 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.py]
12+
indent_size = 4
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[*.md]
18+
trim_trailing_whitespace = false
19+
20+
[*.toml]
21+
indent_size = 4

.github/dependabot.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
labels:
8+
- "dependencies"
9+
open-pull-requests-limit: 5
10+
groups:
11+
github-actions:
12+
patterns:
13+
- "*"
14+
update-types:
15+
- "minor"
16+
- "patch"
17+
commit-message:
18+
prefix: "chore(deps)"
19+
- package-ecosystem: "uv"
20+
directory: "/"
21+
schedule:
22+
interval: "weekly"
23+
labels:
24+
- "dependencies"
25+
open-pull-requests-limit: 5
26+
groups:
27+
uv-minor-patch:
28+
patterns:
29+
- "*"
30+
update-types:
31+
- "minor"
32+
- "patch"
33+
commit-message:
34+
prefix: "chore(deps)"

.github/workflows/1_test.yml

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
name: Tests
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: ["main"]
7+
tags:
8+
- "*.*.*"
9+
paths:
10+
- "litestar_auth/**"
11+
- "tests/**"
12+
- ".pre-commit-config.yaml"
13+
- "pyproject.toml"
14+
- "uv.lock"
15+
- "justfile"
16+
- ".github/workflows/**"
17+
pull_request:
18+
paths:
19+
- "litestar_auth/**"
20+
- "tests/**"
21+
- ".pre-commit-config.yaml"
22+
- "pyproject.toml"
23+
- "uv.lock"
24+
- "justfile"
25+
- ".github/workflows/**"
26+
27+
concurrency:
28+
group: check-${{ github.ref }}
29+
cancel-in-progress: true
30+
31+
permissions:
32+
contents: read
33+
34+
# Test job: id-token write is required for OIDC JWT (GitHub Actions OIDC reference).
35+
# Codecov: use_oidc per codecov-action README; token alternative in Codecov token docs.
36+
# https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect
37+
# https://github.com/codecov/codecov-action#using-oidc
38+
# https://docs.codecov.com/docs/codecov-tokens
39+
40+
env:
41+
VENV_PRECOMMIT_CACHE_VERSION: v1
42+
43+
jobs:
44+
pre-commit:
45+
if: github.event.repository.fork == false
46+
name: Pre-commit
47+
runs-on: ubuntu-latest
48+
env:
49+
UV_PYTHON_PREFERENCE: only-managed
50+
steps:
51+
- name: Check out repository
52+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
53+
54+
- name: Set uv Python install dir
55+
run: echo "UV_PYTHON_INSTALL_DIR=${RUNNER_TEMP}/uv-python-dir" >> "$GITHUB_ENV"
56+
57+
- name: Install uv
58+
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
59+
with:
60+
python-version: "3.12"
61+
enable-cache: true
62+
cache-python: true
63+
github-token: ${{ secrets.GITHUB_TOKEN }}
64+
65+
# Cache key unique per run to avoid "another job may be creating this cache" when
66+
# multiple runs or steps evaluate hashFiles differently (e.g. after uv sync).
67+
# restore-keys restores the latest cache for this prefix; uv sync fixes deps if needed.
68+
# See: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
69+
- name: Restore .venv cache (pre-commit)
70+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
71+
with:
72+
path: .venv
73+
key: venv-precommit-${{ env.VENV_PRECOMMIT_CACHE_VERSION }}-${{ runner.os }}-3.12-${{ github.run_id }}
74+
restore-keys: |
75+
venv-precommit-${{ env.VENV_PRECOMMIT_CACHE_VERSION }}-${{ runner.os }}-3.12-
76+
77+
- name: Install the project
78+
run: uv sync --frozen --all-extras --group dev
79+
80+
- name: Save .venv cache (pre-commit)
81+
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
82+
with:
83+
path: .venv
84+
key: venv-precommit-${{ env.VENV_PRECOMMIT_CACHE_VERSION }}-${{ runner.os }}-3.12-${{ github.run_id }}
85+
86+
- name: Run pre-commit (uv-managed)
87+
run: uv run --no-sync pre-commit run --show-diff-on-failure --color=always --all-files
88+
env:
89+
SKIP: "detect-aws-credentials,no-commit-to-branch"
90+
91+
test:
92+
name: Test (${{ matrix.python-version }} on ${{ matrix.os }})
93+
needs: [pre-commit]
94+
runs-on: ${{ matrix.os }}
95+
if: github.event.repository.fork == false
96+
permissions:
97+
contents: read
98+
id-token: write
99+
strategy:
100+
fail-fast: false
101+
matrix:
102+
python-version:
103+
- "3.12"
104+
- "3.13"
105+
- "3.14"
106+
os:
107+
- ubuntu-latest
108+
- macos-latest
109+
- windows-latest
110+
steps:
111+
- name: Check out repository
112+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
113+
with:
114+
fetch-depth: 0
115+
116+
- name: Install uv
117+
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
118+
with:
119+
python-version: ${{ matrix.python-version }}
120+
enable-cache: true
121+
cache-python: true
122+
github-token: ${{ secrets.GITHUB_TOKEN }}
123+
124+
- name: Add .local/bin to Windows PATH
125+
if: runner.os == 'Windows'
126+
shell: bash
127+
run: echo "$USERPROFILE/.local/bin" >> "$GITHUB_PATH"
128+
129+
- name: Clear Python install dir (Windows)
130+
if: runner.os == 'Windows'
131+
shell: bash
132+
run: rm -rf "${UV_PYTHON_INSTALL_DIR:-}" 2>/dev/null || true
133+
134+
- name: Set up Python
135+
shell: bash
136+
run: uv python install ${{ matrix.python-version }}
137+
138+
- name: Install the project
139+
run: uv sync --frozen --all-extras --group dev
140+
141+
- name: Detect dead fixtures
142+
run: uv run pytest --dead-fixtures
143+
144+
- name: Run tests (coverage + XML for Codecov)
145+
run: >-
146+
uv run pytest
147+
--cov=litestar_auth
148+
--cov-branch
149+
--cov-report=term-missing
150+
--cov-report=xml
151+
--cov-fail-under=100
152+
-n auto
153+
154+
# Codecov flags: ^[\w.\-]{1,45}$ (alphanumeric, _, -, .); see https://docs.codecov.com/docs/flags
155+
- name: Upload coverage to Codecov
156+
uses: codecov/codecov-action@3f20e214133d0983f9a10f3d63b0faf9241a3daa # v6.0.0
157+
with:
158+
fail_ci_if_error: true
159+
files: coverage.xml
160+
flags: ${{ matrix.os }}
161+
name: py-${{ matrix.python-version }}-${{ matrix.os }}
162+
use_oidc: true

.github/workflows/2_bump.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Bump version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
increment:
7+
description: "Version increment type"
8+
required: false
9+
default: ""
10+
type: choice
11+
options:
12+
- ""
13+
- "PATCH"
14+
- "MINOR"
15+
- "MAJOR"
16+
17+
permissions:
18+
contents: write
19+
20+
concurrency:
21+
group: release-operations
22+
cancel-in-progress: false
23+
24+
jobs:
25+
bump:
26+
name: Bump version and release
27+
if: "github.event.head_commit == null || !startsWith(github.event.head_commit.message, 'bump:')"
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 5
30+
steps:
31+
- name: Check out repository
32+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
33+
with:
34+
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
35+
fetch-depth: 0
36+
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
39+
with:
40+
enable-cache: true
41+
cache-python: true
42+
github-token: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Set up Python
45+
run: uv python install 3.12
46+
47+
- name: Install dev dependencies
48+
run: uv sync --frozen --group dev
49+
50+
- name: Get next version
51+
id: get_version
52+
run: |
53+
if [ -n "${{ inputs.increment }}" ]; then
54+
NEXT=$(uv run cz bump --get-next --yes --increment "${{ inputs.increment }}")
55+
else
56+
NEXT=$(uv run cz bump --get-next --yes)
57+
fi
58+
echo "version=$NEXT" >> "$GITHUB_OUTPUT"
59+
60+
- name: Replace Unreleased header in CHANGELOG
61+
id: unreleased
62+
run: |
63+
if grep -q '^## Unreleased' CHANGELOG.md; then
64+
DATE=$(date -u +%Y-%m-%d)
65+
sed -i.bak "s/^## Unreleased.*/## ${{ steps.get_version.outputs.version }} ($DATE)/" CHANGELOG.md
66+
rm -f CHANGELOG.md.bak
67+
echo "replaced=true" >> "$GITHUB_OUTPUT"
68+
else
69+
echo "replaced=false" >> "$GITHUB_OUTPUT"
70+
fi
71+
72+
# Run cz bump on the runner (not commitizen-action Docker) so Commitizen pre_bump_hooks can run `uv lock`.
73+
- name: Bump version and changelog
74+
id: bump
75+
env:
76+
PAT: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
77+
run: |
78+
set -euo pipefail
79+
git config user.name "github-actions[bot]"
80+
git config user.email "github-actions[bot]@users.noreply.github.com"
81+
82+
previous_version=$(uv run cz version --project)
83+
echo "previous_version=${previous_version}" >> "$GITHUB_OUTPUT"
84+
85+
cz_args=(uv run cz --no-raise 21 bump --yes)
86+
if [ -n "${{ inputs.increment }}" ]; then
87+
cz_args+=(--increment "${{ inputs.increment }}")
88+
fi
89+
if [ "${{ steps.unreleased.outputs.replaced }}" = "true" ]; then
90+
cz_args+=(--files-only)
91+
else
92+
cz_args+=(--changelog)
93+
fi
94+
"${cz_args[@]}"
95+
96+
version=$(uv run cz version --project)
97+
echo "version=${version}" >> "$GITHUB_OUTPUT"
98+
99+
if [ "${{ steps.unreleased.outputs.replaced }}" != "true" ] && [ "${version}" != "${previous_version}" ]; then
100+
remote="https://x-access-token:${PAT}@github.com/${GITHUB_REPOSITORY}.git"
101+
branch="${GITHUB_REF_NAME}"
102+
git pull "$remote" "$branch" --rebase
103+
git push "$remote" "HEAD:${branch}" --tags
104+
fi
105+
106+
- name: Commit, tag and push (single commit when using custom changelog)
107+
if: steps.unreleased.outputs.replaced == 'true'
108+
run: |
109+
git config user.name "github-actions[bot]"
110+
git config user.email "github-actions[bot]@users.noreply.github.com"
111+
git add CHANGELOG.md pyproject.toml litestar_auth/__init__.py uv.lock
112+
git commit -m "bump: version ${{ steps.bump.outputs.previous_version }} → ${{ steps.bump.outputs.version }}"
113+
git tag "${{ steps.bump.outputs.version }}"
114+
git push origin HEAD --tags
115+
116+
- name: Prepare release notes
117+
id: release_notes
118+
run: |
119+
awk '/^## [0-9]+\.[0-9]+\.[0-9]+ / {if(d) exit; d=1; next} d && /^## / {exit} d {print}' CHANGELOG.md > release_body.md
120+
echo "path=release_body.md" >> "$GITHUB_OUTPUT"
121+
122+
- name: Create GitHub release
123+
uses: softprops/action-gh-release@71d29a04ae7c63895f38299d7a5e05d238f7f445 # v2.5.1
124+
with:
125+
tag_name: ${{ steps.bump.outputs.version }}
126+
body_path: release_body.md
127+
env:
128+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)