Skip to content

Commit f8a03af

Browse files
authored
Feature/testing and docs (#3)
* updated readthedoc python version, added actions for uv, updated publish version to 3.12 * Template version to 2.0.2
1 parent 6d6f8e6 commit f8a03af

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-library",
50-
"__template_version": "2.0.1",
50+
"__template_version": "2.0.2",
5151
"_new_lines": "\n",
5252
"_copy_without_render": [
5353
".github"

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
@@ -13,6 +13,10 @@ def test_bake_project_no_cli_podman(cookies, bake_project_no_cli_podman_data):
1313
assert not result.project_path.joinpath("python_no_cli", "example.py").is_file()
1414
assert result.project_path.joinpath("containers", "Containerfile").is_file()
1515
assert not result.project_path.joinpath("containers", "Dockerfile").is_file()
16+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
17+
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
18+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
19+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
1620

1721

1822
def test_bake_project_uv_no_cli_podman(cookies, bake_project_uv_no_cli_podman_data):
@@ -30,6 +34,10 @@ def test_bake_project_uv_no_cli_podman(cookies, bake_project_uv_no_cli_podman_da
3034
assert not result.project_path.joinpath("python_no_cli", "example.py").is_file()
3135
assert result.project_path.joinpath("containers", "Containerfile").is_file()
3236
assert not result.project_path.joinpath("containers", "Dockerfile").is_file()
37+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
38+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
39+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
40+
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
3341

3442

3543
def test_bake_project_no_cli_docker(cookies, bake_project_no_cli_docker_data):
@@ -47,6 +55,10 @@ def test_bake_project_no_cli_docker(cookies, bake_project_no_cli_docker_data):
4755
assert not result.project_path.joinpath("python_no_cli", "example.py").is_file()
4856
assert not result.project_path.joinpath("containers", "Containerfile").is_file()
4957
assert result.project_path.joinpath("containers", "Dockerfile").is_file()
58+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
59+
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
60+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
61+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
5062

5163

5264
def test_bake_project_uv_no_cli_docker(cookies, bake_project_uv_no_cli_docker_data):
@@ -64,6 +76,10 @@ def test_bake_project_uv_no_cli_docker(cookies, bake_project_uv_no_cli_docker_da
6476
assert not result.project_path.joinpath("python_no_cli", "example.py").is_file()
6577
assert not result.project_path.joinpath("containers", "Containerfile").is_file()
6678
assert result.project_path.joinpath("containers", "Dockerfile").is_file()
79+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
80+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
81+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
82+
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
6783

6884

6985
def test_bake_project_cli_podman(cookies, bake_project_cli_podman_data):
@@ -81,6 +97,10 @@ def test_bake_project_cli_podman(cookies, bake_project_cli_podman_data):
8197
assert result.project_path.joinpath("python_with_cli", "example.py").is_file()
8298
assert result.project_path.joinpath("containers", "Containerfile").is_file()
8399
assert not result.project_path.joinpath("containers", "Dockerfile").is_file()
100+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
101+
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
102+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
103+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
84104

85105

86106
def test_bake_project_uv_cli_podman(cookies, bake_project_uv_cli_podman_data):
@@ -98,6 +118,10 @@ def test_bake_project_uv_cli_podman(cookies, bake_project_uv_cli_podman_data):
98118
assert result.project_path.joinpath("python_with_cli", "example.py").is_file()
99119
assert result.project_path.joinpath("containers", "Containerfile").is_file()
100120
assert not result.project_path.joinpath("containers", "Dockerfile").is_file()
121+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
122+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
123+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
124+
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
101125

102126

103127
def test_bake_project_cli_docker(cookies, bake_project_cli_docker_data):
@@ -115,6 +139,10 @@ def test_bake_project_cli_docker(cookies, bake_project_cli_docker_data):
115139
assert result.project_path.joinpath("python_with_cli", "example.py").is_file()
116140
assert not result.project_path.joinpath("containers", "Containerfile").is_file()
117141
assert result.project_path.joinpath("containers", "Dockerfile").is_file()
142+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
143+
assert result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
144+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
145+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint-uv.yml").is_file()
118146

119147

120148
def test_bake_project_uv_cli_docker(cookies, bake_project_uv_cli_docker_data):
@@ -132,3 +160,7 @@ def test_bake_project_uv_cli_docker(cookies, bake_project_uv_cli_docker_data):
132160
assert result.project_path.joinpath("python_with_cli", "example.py").is_file()
133161
assert not result.project_path.joinpath("containers", "Containerfile").is_file()
134162
assert result.project_path.joinpath("containers", "Dockerfile").is_file()
163+
assert not result.project_path.joinpath(".github", "workflows", "publish-to-pypi.yml").is_file()
164+
assert not result.project_path.joinpath(".github", "workflows", "test-coverage-lint.yml").is_file()
165+
assert result.project_path.joinpath(".github", "workflows", "publish-to-pypi-uv.yml").is_file()
166+
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 Twine 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.9"
7+
python: "3.12"
88

99
sphinx:
1010
configuration: docs/conf.py

0 commit comments

Comments
 (0)