Skip to content

Commit

Permalink
feat: litestar-htmx plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
cofin committed Oct 17, 2024
0 parents commit 003b1cd
Show file tree
Hide file tree
Showing 43 changed files with 4,561 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Code owner settings for `litestar-org`
# @maintainers should be assigned to all reviews.
# Most specific assignment takes precedence though, so if you add a more specific thing than the `*` glob, you must also add @maintainers
# For more info about code owners see https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-file-example

# Global Assignment
* @litestar-org/maintainers @litestar-org/members
27 changes: 27 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Continuous Deployment

on:
push:
tags:
- "v*.*.*"

jobs:
generate-changelog:
name: Generate changelog
runs-on: ubuntu-22.04
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Generate a changelog
uses: orhun/git-cliff-action@main
id: git-cliff
with:
config: pyproject.toml
args: -vv --latest --strip header
env:
OUTPUT: docs/CHANGELOG.rst
146 changes: 146 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Tests And Linting

on:
pull_request:
push:
branches:
- main

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python
run: uv python install 3.8

- name: Create virtual environment
run: uv sync --all-extras --dev

- name: Install Pre-Commit hooks
run: uv run pre-commit install

- name: Load cached Pre-Commit Dependencies
id: cached-pre-commit-dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit/
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}

- name: Execute Pre-Commit
run: uv run pre-commit run --show-diff-on-failure --color=always --all-files

mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python
run: uv python install 3.8

- name: Install dependencies
run: uv sync --all-extras --dev

- name: Run mypy
run: uv run mypy

pyright:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python
run: uv python install 3.8

- name: Install dependencies
run: uv sync --all-extras --dev

- name: Run pyright
run: uv run pyright

slotscheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python
run: uv python install 3.8

- name: Install dependencies
run: uv sync --all-extras --dev

- name: Run slotscheck
run: uv run slotscheck litestar_htmx

test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --all-extras --dev

- name: Test
run: uv run pytest -m ""

# build-docs:
# needs:
# - validate
# if: github.event_name == 'pull_request'
# runs-on: ubuntu-latest
# steps:
# - name: Check out repository
# uses: actions/checkout@v4

# - name: Install uv
# uses: astral-sh/setup-uv@v3

# - name: Set up Python
# run: uv python install 3.12

# - name: Install dependencies
# run: uv sync --all-extras --dev

# - name: Build docs
# run: uv run make docs

# - name: Save PR number
# run: |
# echo "${{ github.event.number }}" > .pr_number

# - name: Upload artifact
# uses: actions/upload-artifact@v4
# with:
# name: docs-preview
# path: |
# docs/_build/html
# .pr_number
# include-hidden-files: true
78 changes: 78 additions & 0 deletions .github/workflows/docs-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Deploy Documentation Preview

on:
workflow_run:
workflows: [Tests And Linting]
types: [completed]

jobs:
deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }}
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Download artifact
uses: dawidd6/action-download-artifact@v6
with:
workflow_conclusion: success
run_id: ${{ github.event.workflow_run.id }}
path: docs-preview
name: docs-preview

- name: Validate and set PR number
run: |
PR_NUMBER=$(cat docs-preview/.pr_number)
if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]]; then
echo "Invalid PR number: $PR_NUMBER"
exit 1
fi
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
- name: Deploy docs preview
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs-preview/docs/_build/html
token: ${{ secrets.DOCS_PREVIEW_DEPLOY_KEY }}
repository-name: litestar-org/litestar-htmx-docs-preview
clean: false
target-folder: ${{ env.PR_NUMBER }}
branch: gh-pages

- uses: actions/github-script@v7
env:
PR_NUMBER: ${{ env.PR_NUMBER }}
with:
script: |
const issue_number = process.env.PR_NUMBER
const body = "Documentation preview will be available shortly at https://litestar-org.github.io/litestar-htmx-docs-preview/" + issue_number
const opts = github.rest.issues.listComments.endpoint.merge({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
});
const comments = await github.paginate(opts)
for (const comment of comments) {
if (comment.user.id === 41898282 && comment.body === body) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id
})
}
}
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: body,
})
41 changes: 41 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Documentation Building

on:
release:
types: [published]
push:
branches:
- main

jobs:
docs:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python
run: uv python install 3.12

- name: Install dependencies
run: uv sync --all-extras --dev

- name: Fetch gh pages
run: git fetch origin gh-pages --depth=1

- name: Build release docs
run: uv run python tools/build_docs.py docs-build
if: github.event_name == 'release'

- name: Build dev docs
run: uv run python tools/build_docs.py docs-build
if: github.event_name == 'push'

- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs-build
20 changes: 20 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Lint PR Title"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Latest Release

on:
release:
types: [published]
workflow_dispatch:

jobs:
publish-release:
runs-on: ubuntu-latest
permissions:
id-token: write
environment: release
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python
run: uv python install 3.12

- name: Install dependencies
run: uv sync --all-extras

- name: Build package
run: uv build

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# folders
.auto_pytabs_cache/
.hypothesis/
.mypy_cache/
.pytest_cache/
.venv/
*.egg-info/
build/
dist/
results/
site/
target/
.idea/
.vscode/
.cursor/

# files
**/*.so
**/*.sqlite
**/*.sqlite*
*.iml
.coverage
.dmypy.json
.python-version
.ruff_cache
/docs/_build/
coverage.*
setup.py
Loading

0 comments on commit 003b1cd

Please sign in to comment.