Skip to content

updated readthedocs to python 3.12, added uv github actions #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2025
Merged
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
2 changes: 1 addition & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"https"
],
"__template_repo": "https://github.com/btr1975/cookiecutter-python-fastapi-openapi",
"__template_version": "2.0.1",
"__template_version": "2.0.2",
"_new_lines": "\n",
"_copy_without_render": [
"{{cookiecutter.__app_name}}/templates",
Expand Down
8 changes: 8 additions & 0 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
REMOVE_PATHS_UV = [
'{% if cookiecutter.package_manager == "uv" %}requirements.txt{% endif %}',
'{% if cookiecutter.package_manager == "uv" %}requirements-dev.txt{% endif %}',
'{% if cookiecutter.package_manager == "uv" %}.github/workflows/publish-to-pypi.yml{% endif %}',
'{% if cookiecutter.package_manager == "uv" %}.github/workflows/test-coverage-lint.yml{% endif %}',
]

REMOVE_PATHS_PIP = [
'{% if cookiecutter.package_manager == "pip" %}.github/workflows/publish-to-pypi-uv.yml{% endif %}',
'{% if cookiecutter.package_manager == "pip" %}.github/workflows/test-coverage-lint-uv.yml{% endif %}',
]


Expand All @@ -47,3 +54,4 @@ def remove_paths(paths_to_remove: List[str]) -> None:
remove_paths(REMOVE_PATHS_PODMAN)
remove_paths(REMOVE_PATHS_DOCKER)
remove_paths(REMOVE_PATHS_UV)
remove_paths(REMOVE_PATHS_PIP)
32 changes: 32 additions & 0 deletions tests/test_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def test_bake_project_api_only_podman(cookies, bake_project_api_only_podman):
assert not result.project_path.joinpath("api_only", "static").is_dir()
assert not result.project_path.joinpath("api_only", "templates").is_dir()
assert not result.project_path.joinpath("api_only", "routers", "hello_world.py").is_file()
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()


def test_bake_project_uv_api_only_podman(cookies, bake_project_uv_api_only_podman):
Expand All @@ -34,6 +38,10 @@ def test_bake_project_uv_api_only_podman(cookies, bake_project_uv_api_only_podma
assert not result.project_path.joinpath("api_only", "static").is_dir()
assert not result.project_path.joinpath("api_only", "templates").is_dir()
assert not result.project_path.joinpath("api_only", "routers", "hello_world.py").is_file()
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()


def test_bake_project_api_only_docker(cookies, bake_project_api_only_docker):
Expand All @@ -53,6 +61,10 @@ def test_bake_project_api_only_docker(cookies, bake_project_api_only_docker):
assert not result.project_path.joinpath("api_only", "static").is_dir()
assert not result.project_path.joinpath("api_only", "templates").is_dir()
assert not result.project_path.joinpath("api_only", "routers", "hello_world.py").is_file()
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()


def test_bake_project_uv_api_only_docker(cookies, bake_project_uv_api_only_docker):
Expand All @@ -72,6 +84,10 @@ def test_bake_project_uv_api_only_docker(cookies, bake_project_uv_api_only_docke
assert not result.project_path.joinpath("api_only", "static").is_dir()
assert not result.project_path.joinpath("api_only", "templates").is_dir()
assert not result.project_path.joinpath("api_only", "routers", "hello_world.py").is_file()
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()


def test_bake_project_api_with_webpages_podman(cookies, bake_project_api_with_webpages_podman):
Expand All @@ -91,6 +107,10 @@ def test_bake_project_api_with_webpages_podman(cookies, bake_project_api_with_we
assert result.project_path.joinpath("api_with_webpages", "static").is_dir()
assert result.project_path.joinpath("api_with_webpages", "templates").is_dir()
assert result.project_path.joinpath("api_with_webpages", "routers", "hello_world.py").is_file()
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()


def test_bake_project_uv_api_with_webpages_podman(cookies, bake_project_uv_api_with_webpages_podman):
Expand All @@ -110,6 +130,10 @@ def test_bake_project_uv_api_with_webpages_podman(cookies, bake_project_uv_api_w
assert result.project_path.joinpath("api_with_webpages", "static").is_dir()
assert result.project_path.joinpath("api_with_webpages", "templates").is_dir()
assert result.project_path.joinpath("api_with_webpages", "routers", "hello_world.py").is_file()
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()


def test_bake_project_api_with_webpages_docker(cookies, bake_project_api_with_webpages_docker):
Expand All @@ -129,6 +153,10 @@ def test_bake_project_api_with_webpages_docker(cookies, bake_project_api_with_we
assert result.project_path.joinpath("api_with_webpages", "static").is_dir()
assert result.project_path.joinpath("api_with_webpages", "templates").is_dir()
assert result.project_path.joinpath("api_with_webpages", "routers", "hello_world.py").is_file()
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()


def test_bake_project_uv_api_with_webpages_docker(cookies, bake_project_uv_api_with_webpages_docker):
Expand All @@ -148,3 +176,7 @@ def test_bake_project_uv_api_with_webpages_docker(cookies, bake_project_uv_api_w
assert result.project_path.joinpath("api_with_webpages", "static").is_dir()
assert result.project_path.joinpath("api_with_webpages", "templates").is_dir()
assert result.project_path.joinpath("api_with_webpages", "routers", "hello_world.py").is_file()
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will upload a Python Package using UV 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

name: Upload Python Package to PyPi

on:
release:
types:
- published

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install UV
run: |
pip install uv
- name: Build and publish
env:
UV_PUBLISH_USERNAME: ${{ secrets.PYPI_USERNAME }}
UV_PUBLISH_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
make build
uv publish
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"

- name: Upgrade pip setuptools wheel
run: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Unit-Testing, Coverage, Linting

on:
push:
branches:
- main
- develop
- feature/*
- bug/*
pull_request:
branches:
- main
- develop
- feature/*
- bug/*

jobs:
linting:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
os:
- ubuntu-latest

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 UV
run: |
pip install uv
- name: Run Linting
run: |
make pylint

testing-coverage:
needs: linting
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
os:
- ubuntu-latest
- windows-latest
- macos-latest

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 UV
run: |
pip install uv
- name: Run Unit-Testing and Coverage
run: |
make coverage

build:
needs: testing-coverage
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
os:
- ubuntu-latest
- windows-latest
- macos-latest

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 UV
run: |
pip install uv
- name: Run Build
run: |
make build
2 changes: 1 addition & 1 deletion {{cookiecutter.git_repo_name}}/.readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 2
build:
os: "ubuntu-22.04"
tools:
python: "3.8"
python: "3.12"

sphinx:
configuration: docs/conf.py
Expand Down