Skip to content

Commit dcfe0be

Browse files
committed
updated readthedocs to python 3.12, added uv github actions
1 parent 5c267d1 commit dcfe0be

File tree

7 files changed

+181
-3
lines changed

7 files changed

+181
-3
lines changed

cookiecutter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"https"
4848
],
4949
"__template_repo": "https://github.com/btr1975/cookiecutter-python-fastapi-openapi",
50-
"__template_version": "2.0.1",
50+
"__template_version": "2.0.2",
5151
"_new_lines": "\n",
5252
"_copy_without_render": [
5353
"{{cookiecutter.__app_name}}/templates",

hooks/post_gen_project.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
REMOVE_PATHS_UV = [
2424
'{% if cookiecutter.package_manager == "uv" %}requirements.txt{% endif %}',
2525
'{% if cookiecutter.package_manager == "uv" %}requirements-dev.txt{% endif %}',
26+
'{% if cookiecutter.package_manager == "uv" %}.github/workflows/publish-to-pypi.yml{% endif %}',
27+
'{% if cookiecutter.package_manager == "uv" %}.github/workflows/test-coverage-lint.yml{% endif %}',
28+
]
29+
30+
REMOVE_PATHS_PIP = [
31+
'{% if cookiecutter.package_manager == "pip" %}.github/workflows/publish-to-pypi-uv.yml{% endif %}',
32+
'{% if cookiecutter.package_manager == "pip" %}.github/workflows/test-coverage-lint-uv.yml{% endif %}',
2633
]
2734

2835

@@ -47,3 +54,4 @@ def remove_paths(paths_to_remove: List[str]) -> None:
4754
remove_paths(REMOVE_PATHS_PODMAN)
4855
remove_paths(REMOVE_PATHS_DOCKER)
4956
remove_paths(REMOVE_PATHS_UV)
57+
remove_paths(REMOVE_PATHS_PIP)

tests/test_cookies.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ def test_bake_project_api_only_podman(cookies, bake_project_api_only_podman):
1515
assert not result.project_path.joinpath("api_only", "static").is_dir()
1616
assert not result.project_path.joinpath("api_only", "templates").is_dir()
1717
assert not result.project_path.joinpath("api_only", "routers", "hello_world.py").is_file()
18+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
19+
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
20+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
21+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
1822

1923

2024
def test_bake_project_uv_api_only_podman(cookies, bake_project_uv_api_only_podman):
@@ -34,6 +38,10 @@ def test_bake_project_uv_api_only_podman(cookies, bake_project_uv_api_only_podma
3438
assert not result.project_path.joinpath("api_only", "static").is_dir()
3539
assert not result.project_path.joinpath("api_only", "templates").is_dir()
3640
assert not result.project_path.joinpath("api_only", "routers", "hello_world.py").is_file()
41+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
42+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
43+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
44+
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
3745

3846

3947
def test_bake_project_api_only_docker(cookies, bake_project_api_only_docker):
@@ -53,6 +61,10 @@ def test_bake_project_api_only_docker(cookies, bake_project_api_only_docker):
5361
assert not result.project_path.joinpath("api_only", "static").is_dir()
5462
assert not result.project_path.joinpath("api_only", "templates").is_dir()
5563
assert not result.project_path.joinpath("api_only", "routers", "hello_world.py").is_file()
64+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
65+
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
66+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
67+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
5668

5769

5870
def test_bake_project_uv_api_only_docker(cookies, bake_project_uv_api_only_docker):
@@ -72,6 +84,10 @@ def test_bake_project_uv_api_only_docker(cookies, bake_project_uv_api_only_docke
7284
assert not result.project_path.joinpath("api_only", "static").is_dir()
7385
assert not result.project_path.joinpath("api_only", "templates").is_dir()
7486
assert not result.project_path.joinpath("api_only", "routers", "hello_world.py").is_file()
87+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
88+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
89+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
90+
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
7591

7692

7793
def test_bake_project_api_with_webpages_podman(cookies, bake_project_api_with_webpages_podman):
@@ -91,6 +107,10 @@ def test_bake_project_api_with_webpages_podman(cookies, bake_project_api_with_we
91107
assert result.project_path.joinpath("api_with_webpages", "static").is_dir()
92108
assert result.project_path.joinpath("api_with_webpages", "templates").is_dir()
93109
assert result.project_path.joinpath("api_with_webpages", "routers", "hello_world.py").is_file()
110+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
111+
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
112+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
113+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
94114

95115

96116
def test_bake_project_uv_api_with_webpages_podman(cookies, bake_project_uv_api_with_webpages_podman):
@@ -110,6 +130,10 @@ def test_bake_project_uv_api_with_webpages_podman(cookies, bake_project_uv_api_w
110130
assert result.project_path.joinpath("api_with_webpages", "static").is_dir()
111131
assert result.project_path.joinpath("api_with_webpages", "templates").is_dir()
112132
assert result.project_path.joinpath("api_with_webpages", "routers", "hello_world.py").is_file()
133+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
134+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
135+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
136+
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
113137

114138

115139
def test_bake_project_api_with_webpages_docker(cookies, bake_project_api_with_webpages_docker):
@@ -129,6 +153,10 @@ def test_bake_project_api_with_webpages_docker(cookies, bake_project_api_with_we
129153
assert result.project_path.joinpath("api_with_webpages", "static").is_dir()
130154
assert result.project_path.joinpath("api_with_webpages", "templates").is_dir()
131155
assert result.project_path.joinpath("api_with_webpages", "routers", "hello_world.py").is_file()
156+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
157+
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
158+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
159+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
132160

133161

134162
def test_bake_project_uv_api_with_webpages_docker(cookies, bake_project_uv_api_with_webpages_docker):
@@ -148,3 +176,7 @@ def test_bake_project_uv_api_with_webpages_docker(cookies, bake_project_uv_api_w
148176
assert result.project_path.joinpath("api_with_webpages", "static").is_dir()
149177
assert result.project_path.joinpath("api_with_webpages", "templates").is_dir()
150178
assert result.project_path.joinpath("api_with_webpages", "routers", "hello_world.py").is_file()
179+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
180+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
181+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
182+
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This workflow will upload a Python Package using UV when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Upload Python Package to PyPi
5+
6+
on:
7+
release:
8+
types:
9+
- published
10+
11+
jobs:
12+
deploy:
13+
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.12"
22+
23+
- name: Install UV
24+
run: |
25+
pip install uv
26+
- name: Build and publish
27+
env:
28+
UV_PUBLISH_USERNAME: ${{ secrets.PYPI_USERNAME }}
29+
UV_PUBLISH_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
30+
run: |
31+
make build
32+
uv publish

{{cookiecutter.git_repo_name}}/.github/workflows/publish-to-pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Set up Python
1919
uses: actions/setup-python@v5
2020
with:
21-
python-version: "3.10"
21+
python-version: "3.12"
2222

2323
- name: Upgrade pip setuptools wheel
2424
run: |
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Unit-Testing, Coverage, Linting
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
- develop
11+
- feature/*
12+
- bug/*
13+
pull_request:
14+
branches:
15+
- main
16+
- develop
17+
- feature/*
18+
- bug/*
19+
20+
jobs:
21+
linting:
22+
runs-on: ${{ matrix.os }}
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
python-version:
27+
- "3.9"
28+
- "3.10"
29+
- "3.11"
30+
- "3.12"
31+
- "3.13"
32+
os:
33+
- ubuntu-latest
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
- name: Set up Python ${{ matrix.python-version }}
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
- name: Install UV
42+
run: |
43+
pip install uv
44+
- name: Run Linting
45+
run: |
46+
make pylint
47+
48+
testing-coverage:
49+
needs: linting
50+
runs-on: ${{ matrix.os }}
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
python-version:
55+
- "3.9"
56+
- "3.10"
57+
- "3.11"
58+
- "3.12"
59+
- "3.13"
60+
os:
61+
- ubuntu-latest
62+
- windows-latest
63+
- macos-latest
64+
65+
steps:
66+
- uses: actions/checkout@v4
67+
- name: Set up Python ${{ matrix.python-version }}
68+
uses: actions/setup-python@v5
69+
with:
70+
python-version: ${{ matrix.python-version }}
71+
- name: Install UV
72+
run: |
73+
pip install uv
74+
- name: Run Unit-Testing and Coverage
75+
run: |
76+
make coverage
77+
78+
build:
79+
needs: testing-coverage
80+
runs-on: ${{ matrix.os }}
81+
strategy:
82+
fail-fast: false
83+
matrix:
84+
python-version:
85+
- "3.9"
86+
- "3.10"
87+
- "3.11"
88+
- "3.12"
89+
- "3.13"
90+
os:
91+
- ubuntu-latest
92+
- windows-latest
93+
- macos-latest
94+
95+
steps:
96+
- uses: actions/checkout@v4
97+
- name: Set up Python ${{ matrix.python-version }}
98+
uses: actions/setup-python@v5
99+
with:
100+
python-version: ${{ matrix.python-version }}
101+
- name: Install UV
102+
run: |
103+
pip install uv
104+
- name: Run Build
105+
run: |
106+
make build

{{cookiecutter.git_repo_name}}/.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version: 2
44
build:
55
os: "ubuntu-22.04"
66
tools:
7-
python: "3.8"
7+
python: "3.12"
88

99
sphinx:
1010
configuration: docs/conf.py

0 commit comments

Comments
 (0)