test-python-package-release 0.5.0__tar.gz → 0.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- test_python_package_release-0.6.0/.github/.release-please-manifest.json +3 -0
- test_python_package_release-0.6.0/.github/workflows/docs.yml +47 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/.gitignore +3 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/CHANGELOG.md +17 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/Dockerfile +1 -1
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/PKG-INFO +118 -19
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/README.md +113 -18
- test_python_package_release-0.6.0/docs/contributing.md +55 -0
- test_python_package_release-0.6.0/docs/docker.md +21 -0
- test_python_package_release-0.6.0/docs/getting-started.md +34 -0
- test_python_package_release-0.6.0/docs/index.md +24 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/pyproject.toml +20 -4
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/src/test_python_package_release/__init__.py +2 -2
- test_python_package_release-0.6.0/src/test_python_package_release/calculator.py +178 -0
- test_python_package_release-0.6.0/src/test_python_package_release/strings.py +95 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/uv.lock +447 -1
- test_python_package_release-0.6.0/zensical.toml +52 -0
- test_python_package_release-0.5.0/.github/.release-please-manifest.json +0 -3
- test_python_package_release-0.5.0/src/test_python_package_release/calculator.py +0 -38
- test_python_package_release-0.5.0/src/test_python_package_release/strings.py +0 -26
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/.dockerignore +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/.github/dependabot.yml +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/.github/release-please-config.json +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/.github/workflows/ci.yml +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/.github/workflows/claude-review.yml +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/.github/workflows/docker-publish.yml +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/.github/workflows/publish.yml +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/.github/workflows/release-please.yml +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/.pre-commit-config.yaml +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/.python-version +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/LICENSE +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/commitlint.config.cjs +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/docs/superpowers/plans/2026-05-30-python-package-release-template.md +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/docs/superpowers/specs/2026-05-30-python-package-release-template-design.md +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/tests/__init__.py +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/tests/test_calculator.py +0 -0
- {test_python_package_release-0.5.0 → test_python_package_release-0.6.0}/tests/test_strings.py +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: Docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [main]
|
|
6
|
+
release:
|
|
7
|
+
types: [published]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: docs-${{ github.ref }}
|
|
15
|
+
cancel-in-progress: true
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
docs:
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
- uses: astral-sh/setup-uv@v4
|
|
23
|
+
with:
|
|
24
|
+
enable-cache: true
|
|
25
|
+
- name: Build documentation (strict)
|
|
26
|
+
run: uv run --group docs zensical build --clean
|
|
27
|
+
- name: Upload Pages artifact
|
|
28
|
+
if: github.event_name != 'pull_request'
|
|
29
|
+
uses: actions/upload-pages-artifact@v5
|
|
30
|
+
with:
|
|
31
|
+
path: site
|
|
32
|
+
|
|
33
|
+
deploy-docs:
|
|
34
|
+
if: github.event_name != 'pull_request'
|
|
35
|
+
needs: docs
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
permissions:
|
|
38
|
+
pages: write
|
|
39
|
+
id-token: write
|
|
40
|
+
environment:
|
|
41
|
+
name: github-pages
|
|
42
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/configure-pages@v6
|
|
45
|
+
- name: Deploy to GitHub Pages
|
|
46
|
+
id: deployment
|
|
47
|
+
uses: actions/deploy-pages@v5
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.0](https://github.com/wozniakos10/test_python_package_release/compare/test-python-package-release-v0.5.0...test-python-package-release-v0.6.0) (2026-12-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **docs:** publish API docs site to GitHub Pages ([5562c0a](https://github.com/wozniakos10/test_python_package_release/commit/5562c0a618a1da2a90087cfd7f84c5cfc3287e6a))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **docker:** correct repository URL in image label ([4ae50c2](https://github.com/wozniakos10/test_python_package_release/commit/4ae50c2ebc22b6aa303063ca6e35be04ac4a88da))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Documentation
|
|
17
|
+
|
|
18
|
+
* add Google-style docstrings with doctests ([40970b9](https://github.com/wozniakos10/test_python_package_release/commit/40970b9b6bf515c720df30ba5f4573e6d4345f9b))
|
|
19
|
+
|
|
3
20
|
## [0.5.0](https://github.com/wozniakos10/test_python_package_release/compare/test-python-package-release-v0.4.0...test-python-package-release-v0.5.0) (2026-12-05)
|
|
4
21
|
|
|
5
22
|
|
|
@@ -7,7 +7,7 @@ RUN uv build --wheel --out-dir /dist
|
|
|
7
7
|
|
|
8
8
|
FROM python:3.13-slim
|
|
9
9
|
|
|
10
|
-
LABEL org.opencontainers.image.source="https://github.com/wozniakos10/
|
|
10
|
+
LABEL org.opencontainers.image.source="https://github.com/wozniakos10/test_python_package_release"
|
|
11
11
|
|
|
12
12
|
COPY --from=builder /dist/*.whl /tmp/
|
|
13
13
|
RUN pip install --no-cache-dir /tmp/*.whl && rm /tmp/*.whl
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: test-python-package-release
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Template library demonstrating Python package release CI/CD
|
|
5
|
+
Project-URL: Homepage, https://github.com/wozniakos10/test_python_package_release
|
|
6
|
+
Project-URL: Documentation, https://wozniakos10.github.io/test_python_package_release/
|
|
7
|
+
Project-URL: Repository, https://github.com/wozniakos10/test_python_package_release
|
|
8
|
+
Project-URL: Changelog, https://github.com/wozniakos10/test_python_package_release/blob/main/CHANGELOG.md
|
|
5
9
|
Author-email: Dawid Wozniak <wozniakos10@gmail.com>
|
|
6
10
|
License: MIT License
|
|
7
11
|
|
|
@@ -37,6 +41,8 @@ Description-Content-Type: text/markdown
|
|
|
37
41
|
Template repository demonstrating a complete CI/CD pipeline for Python packages
|
|
38
42
|
published to PyPI.
|
|
39
43
|
|
|
44
|
+
**Documentation:** https://wozniakos10.github.io/test_python_package_release/
|
|
45
|
+
|
|
40
46
|
## Quick start
|
|
41
47
|
|
|
42
48
|
```bash
|
|
@@ -48,9 +54,12 @@ uv run pytest
|
|
|
48
54
|
|
|
49
55
|
```
|
|
50
56
|
.
|
|
51
|
-
├── .github/workflows/ # CI, Claude review, release-please, publish
|
|
57
|
+
├── .github/workflows/ # CI, Claude review, release-please, publish, docker, docs
|
|
52
58
|
├── src/ # library code (src/ layout)
|
|
53
59
|
├── tests/ # pytest tests
|
|
60
|
+
├── docs/ # documentation pages (Markdown)
|
|
61
|
+
├── zensical.toml # documentation site config
|
|
62
|
+
├── Dockerfile
|
|
54
63
|
├── pyproject.toml # single source of truth: build, deps, ruff, pytest, tox
|
|
55
64
|
├── .pre-commit-config.yaml
|
|
56
65
|
├── commitlint.config.cjs
|
|
@@ -65,14 +74,15 @@ configured in `pyproject.toml` (no scattered config files).
|
|
|
65
74
|
| Tool | Purpose | Where it runs |
|
|
66
75
|
|---|---|---|
|
|
67
76
|
| [**uv**](https://docs.astral.sh/uv/) | Package manager, virtualenv handler, Python installer, build tool. Replaces `pip` + `venv` + `pip-tools` + `pyenv`. | Local + CI |
|
|
68
|
-
| [**ruff**](https://docs.astral.sh/ruff/) | Linter + formatter (replaces flake8, isort, black, pyupgrade). | pre-commit + CI lint job |
|
|
77
|
+
| [**ruff**](https://docs.astral.sh/ruff/) | Linter + formatter (replaces flake8, isort, black, pyupgrade). Also enforces Google-style docstrings on public code (`D` rules). | pre-commit + CI lint job |
|
|
69
78
|
| [**ty**](https://github.com/astral-sh/ty) | Static type checker by Astral (faster mypy alternative). | CI lint job + `tox -e type` |
|
|
70
|
-
| [**pytest**](https://docs.pytest.org/) | Test runner. | Local + CI test matrix |
|
|
71
|
-
| [**pytest-cov**](https://pytest-cov.readthedocs.io/) | Coverage reporting via `coverage.py
|
|
79
|
+
| [**pytest**](https://docs.pytest.org/) | Test runner; also runs the `>>>` examples in docstrings as doctests (`--doctest-modules`). | Local + CI test matrix |
|
|
80
|
+
| [**pytest-cov**](https://pytest-cov.readthedocs.io/) | Coverage reporting via `coverage.py`; enforces a minimum of 70% (`--cov-fail-under=70`). | Every `pytest` run (local + CI) |
|
|
72
81
|
| [**tox**](https://tox.wiki/) + [**tox-uv**](https://github.com/tox-dev/tox-uv) | Isolated test environments per Python version (3.11, 3.12, 3.13) backed by uv for speed. | Local + CI test matrix |
|
|
73
82
|
| [**pre-commit**](https://pre-commit.com/) | Git hook framework — runs ruff and conventional-commit checks before every commit. | Local |
|
|
74
83
|
| [**conventional-pre-commit**](https://github.com/compilerla/conventional-pre-commit) | Pure-Python validator for [Conventional Commits](https://www.conventionalcommits.org/) commit messages. | pre-commit (commit-msg stage) |
|
|
75
84
|
| [**commitlint**](https://commitlint.js.org/) | Node-based validator that re-checks every commit on a PR. | CI `commitlint` job |
|
|
85
|
+
| [**Zensical**](https://zensical.org/) + [**mkdocstrings**](https://mkdocstrings.github.io/python/) | Documentation site; the API Reference is generated from docstrings. | CI `docs` job, GitHub Pages on release |
|
|
76
86
|
| [**hatchling**](https://hatch.pypa.io/) | PEP 517 build backend used by `uv build` to produce wheel/sdist. | Build / publish |
|
|
77
87
|
| [**release-please**](https://github.com/googleapis/release-please) | Parses Conventional Commits → bumps version → updates CHANGELOG → tags releases. | CI on push to `main` |
|
|
78
88
|
| [**claude-code-action**](https://github.com/anthropics/claude-code-action) | Claude reviews PRs on demand when you comment `@claude`. | CI on PR comment |
|
|
@@ -101,6 +111,10 @@ uv run ty check src
|
|
|
101
111
|
# Build the distribution locally
|
|
102
112
|
uv build
|
|
103
113
|
|
|
114
|
+
# Documentation: live preview on http://localhost:8000, or strict build into site/
|
|
115
|
+
uv run --group docs zensical serve
|
|
116
|
+
uv run --group docs zensical build
|
|
117
|
+
|
|
104
118
|
# Add a new dependency (auto-updates uv.lock — commit both files)
|
|
105
119
|
uv add httpx
|
|
106
120
|
uv add --group dev pytest-mock
|
|
@@ -120,10 +134,80 @@ Examples:
|
|
|
120
134
|
Enforced locally by `conventional-pre-commit` (commit-msg hook) and in CI by
|
|
121
135
|
`commitlint`.
|
|
122
136
|
|
|
137
|
+
## Quality gates
|
|
138
|
+
|
|
139
|
+
Nothing lands on `main` without passing CI. A GitHub ruleset
|
|
140
|
+
(`main-protection`, see [setup step 7](#first-time-setup-after-cloning-the-template))
|
|
141
|
+
requires a PR and these status checks to be green before merging:
|
|
142
|
+
|
|
143
|
+
| Check | What it enforces |
|
|
144
|
+
|---|---|
|
|
145
|
+
| `lint` | `ruff check` (including docstring rules), `ruff format --check`, `ty check src` |
|
|
146
|
+
| `test (3.11)`, `test (3.12)`, `test (3.13)` | Unit tests and doctests pass **and** total coverage is at least 70% |
|
|
147
|
+
| `commitlint` | Every commit in the PR follows Conventional Commits |
|
|
148
|
+
| `docs` | The documentation site builds in strict mode |
|
|
149
|
+
|
|
150
|
+
### Test coverage
|
|
151
|
+
|
|
152
|
+
Coverage is measured on every `pytest` run: the flags live in
|
|
153
|
+
`[tool.pytest.ini_options].addopts` in `pyproject.toml`. If total coverage
|
|
154
|
+
drops below 70%, pytest exits with an error even when all tests pass, which
|
|
155
|
+
fails the `test` jobs and blocks the merge.
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
uv run pytest # tests + coverage table with missing lines
|
|
159
|
+
uv run pytest --cov-report=html # HTML report, then: open htmlcov/index.html
|
|
160
|
+
uv run pytest --no-cov # quick run without coverage
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
To change the threshold, edit `--cov-fail-under` in `pyproject.toml`.
|
|
164
|
+
|
|
165
|
+
## Documentation
|
|
166
|
+
|
|
167
|
+
The site at https://wozniakos10.github.io/test_python_package_release/ is
|
|
168
|
+
built with [Zensical](https://zensical.org/) from two sources:
|
|
169
|
+
|
|
170
|
+
- **Hand-written pages** in `docs/` (Markdown), listed in `nav` in
|
|
171
|
+
`zensical.toml`. `docs/superpowers/` holds internal design notes and is
|
|
172
|
+
excluded from the site.
|
|
173
|
+
- **API Reference**, generated automatically: the `api-autonav` plugin creates
|
|
174
|
+
one page per module in `src/test_python_package_release/`, and
|
|
175
|
+
`mkdocstrings` renders each function's signature, type hints and
|
|
176
|
+
Google-style docstring. A new module or function shows up in the docs
|
|
177
|
+
without touching any docs file.
|
|
178
|
+
|
|
179
|
+
Every public module and function needs a docstring (ruff `D` rules, Google
|
|
180
|
+
convention). Examples written as `>>>` doctests are executed by pytest, so
|
|
181
|
+
they cannot drift from the code:
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
def divide(a: float, b: float) -> float:
|
|
185
|
+
"""Divide one number by another.
|
|
186
|
+
|
|
187
|
+
Args:
|
|
188
|
+
a: Dividend.
|
|
189
|
+
b: Divisor.
|
|
190
|
+
|
|
191
|
+
Returns:
|
|
192
|
+
The quotient of ``a`` and ``b``.
|
|
193
|
+
|
|
194
|
+
Raises:
|
|
195
|
+
ZeroDivisionError: If ``b`` is zero.
|
|
196
|
+
|
|
197
|
+
Examples:
|
|
198
|
+
>>> divide(6, 3)
|
|
199
|
+
2.0
|
|
200
|
+
"""
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
`docs.yml` builds the site in strict mode on every PR (the `docs` check) and
|
|
204
|
+
deploys it to GitHub Pages when a release is published (or on manual run).
|
|
205
|
+
|
|
123
206
|
## Release flow
|
|
124
207
|
|
|
125
208
|
```
|
|
126
|
-
PR opened ──▶ ci.yml (lint, ty, pytest matrix, commitlint)
|
|
209
|
+
PR opened ──▶ ci.yml (lint, ty, pytest + doctests matrix, commitlint)
|
|
210
|
+
──▶ docs.yml (strict docs build)
|
|
127
211
|
│
|
|
128
212
|
└─ optional: comment "@claude" ──▶ claude-review.yml
|
|
129
213
|
|
|
@@ -134,12 +218,14 @@ PR merged ──▶ main ──▶ release-please.yml
|
|
|
134
218
|
|
|
135
219
|
Release PR merged ──▶ release-please tags + creates GitHub Release
|
|
136
220
|
│
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
221
|
+
├─ publish.yml ──▶ uv build
|
|
222
|
+
│ ──▶ TestPyPI (OIDC)
|
|
223
|
+
│ ──▶ PyPI (OIDC, gated env)
|
|
224
|
+
│
|
|
225
|
+
├─ docker-publish.yml ──▶ Docker Hub
|
|
226
|
+
│ (<version>, <major.minor>, sha-*)
|
|
140
227
|
│
|
|
141
|
-
└─
|
|
142
|
-
(<version>, <major.minor>, sha-*)
|
|
228
|
+
└─ docs.yml ──▶ GitHub Pages
|
|
143
229
|
```
|
|
144
230
|
|
|
145
231
|
## Docker image
|
|
@@ -197,13 +283,26 @@ Required repo configuration (Settings → Secrets and variables → Actions):
|
|
|
197
283
|
pattern that release-please produces — by default
|
|
198
284
|
`<package-name>-v*` (e.g. `test-python-package-release-v*`)
|
|
199
285
|
|
|
200
|
-
7. **
|
|
201
|
-
|
|
202
|
-
-
|
|
203
|
-
|
|
204
|
-
- Block force pushes
|
|
205
|
-
-
|
|
206
|
-
|
|
207
|
-
|
|
286
|
+
7. **Branch protection ruleset** for `main`: Settings → Rules → Rulesets →
|
|
287
|
+
New branch ruleset (this repo uses one named `main-protection`):
|
|
288
|
+
- **Enforcement status**: Active (a Disabled ruleset enforces nothing)
|
|
289
|
+
- **Target branches**: Include default branch (`main`)
|
|
290
|
+
- **Restrict deletions** and **Block force pushes**
|
|
291
|
+
- **Require a pull request before merging** (required approvals can stay
|
|
292
|
+
at 0 for a solo project)
|
|
293
|
+
- **Require status checks to pass**, then Add checks: `lint`,
|
|
294
|
+
`test (3.11)`, `test (3.12)`, `test (3.13)`, `commitlint`, `docs`.
|
|
295
|
+
A check appears in the search only after it has run at least once in
|
|
296
|
+
the repo. "Require branches to be up to date" is optional and stricter.
|
|
297
|
+
- Release PRs from release-please run the same checks (they are created
|
|
298
|
+
with `RELEASE_PLEASE_TOKEN`), so they merge like any other PR. Add
|
|
299
|
+
yourself to the bypass list only if you need an emergency override.
|
|
300
|
+
|
|
301
|
+
8. **GitHub Pages**: Settings → Pages → Source: **GitHub Actions**. Then in
|
|
302
|
+
Settings → Environments → `github-pages` (created automatically) add a
|
|
303
|
+
**tag** deployment rule `test-python-package-release-v*` next to `main`:
|
|
304
|
+
the deploy job runs on the release tag, which is rejected otherwise.
|
|
305
|
+
|
|
306
|
+
9. **(Optional) Production gate** for PyPI publishing — on Pro/Team/Enterprise
|
|
208
307
|
plans only: add a Required reviewer on the `pypi` environment to require
|
|
209
308
|
manual approval before production publish.
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
Template repository demonstrating a complete CI/CD pipeline for Python packages
|
|
4
4
|
published to PyPI.
|
|
5
5
|
|
|
6
|
+
**Documentation:** https://wozniakos10.github.io/test_python_package_release/
|
|
7
|
+
|
|
6
8
|
## Quick start
|
|
7
9
|
|
|
8
10
|
```bash
|
|
@@ -14,9 +16,12 @@ uv run pytest
|
|
|
14
16
|
|
|
15
17
|
```
|
|
16
18
|
.
|
|
17
|
-
├── .github/workflows/ # CI, Claude review, release-please, publish
|
|
19
|
+
├── .github/workflows/ # CI, Claude review, release-please, publish, docker, docs
|
|
18
20
|
├── src/ # library code (src/ layout)
|
|
19
21
|
├── tests/ # pytest tests
|
|
22
|
+
├── docs/ # documentation pages (Markdown)
|
|
23
|
+
├── zensical.toml # documentation site config
|
|
24
|
+
├── Dockerfile
|
|
20
25
|
├── pyproject.toml # single source of truth: build, deps, ruff, pytest, tox
|
|
21
26
|
├── .pre-commit-config.yaml
|
|
22
27
|
├── commitlint.config.cjs
|
|
@@ -31,14 +36,15 @@ configured in `pyproject.toml` (no scattered config files).
|
|
|
31
36
|
| Tool | Purpose | Where it runs |
|
|
32
37
|
|---|---|---|
|
|
33
38
|
| [**uv**](https://docs.astral.sh/uv/) | Package manager, virtualenv handler, Python installer, build tool. Replaces `pip` + `venv` + `pip-tools` + `pyenv`. | Local + CI |
|
|
34
|
-
| [**ruff**](https://docs.astral.sh/ruff/) | Linter + formatter (replaces flake8, isort, black, pyupgrade). | pre-commit + CI lint job |
|
|
39
|
+
| [**ruff**](https://docs.astral.sh/ruff/) | Linter + formatter (replaces flake8, isort, black, pyupgrade). Also enforces Google-style docstrings on public code (`D` rules). | pre-commit + CI lint job |
|
|
35
40
|
| [**ty**](https://github.com/astral-sh/ty) | Static type checker by Astral (faster mypy alternative). | CI lint job + `tox -e type` |
|
|
36
|
-
| [**pytest**](https://docs.pytest.org/) | Test runner. | Local + CI test matrix |
|
|
37
|
-
| [**pytest-cov**](https://pytest-cov.readthedocs.io/) | Coverage reporting via `coverage.py
|
|
41
|
+
| [**pytest**](https://docs.pytest.org/) | Test runner; also runs the `>>>` examples in docstrings as doctests (`--doctest-modules`). | Local + CI test matrix |
|
|
42
|
+
| [**pytest-cov**](https://pytest-cov.readthedocs.io/) | Coverage reporting via `coverage.py`; enforces a minimum of 70% (`--cov-fail-under=70`). | Every `pytest` run (local + CI) |
|
|
38
43
|
| [**tox**](https://tox.wiki/) + [**tox-uv**](https://github.com/tox-dev/tox-uv) | Isolated test environments per Python version (3.11, 3.12, 3.13) backed by uv for speed. | Local + CI test matrix |
|
|
39
44
|
| [**pre-commit**](https://pre-commit.com/) | Git hook framework — runs ruff and conventional-commit checks before every commit. | Local |
|
|
40
45
|
| [**conventional-pre-commit**](https://github.com/compilerla/conventional-pre-commit) | Pure-Python validator for [Conventional Commits](https://www.conventionalcommits.org/) commit messages. | pre-commit (commit-msg stage) |
|
|
41
46
|
| [**commitlint**](https://commitlint.js.org/) | Node-based validator that re-checks every commit on a PR. | CI `commitlint` job |
|
|
47
|
+
| [**Zensical**](https://zensical.org/) + [**mkdocstrings**](https://mkdocstrings.github.io/python/) | Documentation site; the API Reference is generated from docstrings. | CI `docs` job, GitHub Pages on release |
|
|
42
48
|
| [**hatchling**](https://hatch.pypa.io/) | PEP 517 build backend used by `uv build` to produce wheel/sdist. | Build / publish |
|
|
43
49
|
| [**release-please**](https://github.com/googleapis/release-please) | Parses Conventional Commits → bumps version → updates CHANGELOG → tags releases. | CI on push to `main` |
|
|
44
50
|
| [**claude-code-action**](https://github.com/anthropics/claude-code-action) | Claude reviews PRs on demand when you comment `@claude`. | CI on PR comment |
|
|
@@ -67,6 +73,10 @@ uv run ty check src
|
|
|
67
73
|
# Build the distribution locally
|
|
68
74
|
uv build
|
|
69
75
|
|
|
76
|
+
# Documentation: live preview on http://localhost:8000, or strict build into site/
|
|
77
|
+
uv run --group docs zensical serve
|
|
78
|
+
uv run --group docs zensical build
|
|
79
|
+
|
|
70
80
|
# Add a new dependency (auto-updates uv.lock — commit both files)
|
|
71
81
|
uv add httpx
|
|
72
82
|
uv add --group dev pytest-mock
|
|
@@ -86,10 +96,80 @@ Examples:
|
|
|
86
96
|
Enforced locally by `conventional-pre-commit` (commit-msg hook) and in CI by
|
|
87
97
|
`commitlint`.
|
|
88
98
|
|
|
99
|
+
## Quality gates
|
|
100
|
+
|
|
101
|
+
Nothing lands on `main` without passing CI. A GitHub ruleset
|
|
102
|
+
(`main-protection`, see [setup step 7](#first-time-setup-after-cloning-the-template))
|
|
103
|
+
requires a PR and these status checks to be green before merging:
|
|
104
|
+
|
|
105
|
+
| Check | What it enforces |
|
|
106
|
+
|---|---|
|
|
107
|
+
| `lint` | `ruff check` (including docstring rules), `ruff format --check`, `ty check src` |
|
|
108
|
+
| `test (3.11)`, `test (3.12)`, `test (3.13)` | Unit tests and doctests pass **and** total coverage is at least 70% |
|
|
109
|
+
| `commitlint` | Every commit in the PR follows Conventional Commits |
|
|
110
|
+
| `docs` | The documentation site builds in strict mode |
|
|
111
|
+
|
|
112
|
+
### Test coverage
|
|
113
|
+
|
|
114
|
+
Coverage is measured on every `pytest` run: the flags live in
|
|
115
|
+
`[tool.pytest.ini_options].addopts` in `pyproject.toml`. If total coverage
|
|
116
|
+
drops below 70%, pytest exits with an error even when all tests pass, which
|
|
117
|
+
fails the `test` jobs and blocks the merge.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
uv run pytest # tests + coverage table with missing lines
|
|
121
|
+
uv run pytest --cov-report=html # HTML report, then: open htmlcov/index.html
|
|
122
|
+
uv run pytest --no-cov # quick run without coverage
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
To change the threshold, edit `--cov-fail-under` in `pyproject.toml`.
|
|
126
|
+
|
|
127
|
+
## Documentation
|
|
128
|
+
|
|
129
|
+
The site at https://wozniakos10.github.io/test_python_package_release/ is
|
|
130
|
+
built with [Zensical](https://zensical.org/) from two sources:
|
|
131
|
+
|
|
132
|
+
- **Hand-written pages** in `docs/` (Markdown), listed in `nav` in
|
|
133
|
+
`zensical.toml`. `docs/superpowers/` holds internal design notes and is
|
|
134
|
+
excluded from the site.
|
|
135
|
+
- **API Reference**, generated automatically: the `api-autonav` plugin creates
|
|
136
|
+
one page per module in `src/test_python_package_release/`, and
|
|
137
|
+
`mkdocstrings` renders each function's signature, type hints and
|
|
138
|
+
Google-style docstring. A new module or function shows up in the docs
|
|
139
|
+
without touching any docs file.
|
|
140
|
+
|
|
141
|
+
Every public module and function needs a docstring (ruff `D` rules, Google
|
|
142
|
+
convention). Examples written as `>>>` doctests are executed by pytest, so
|
|
143
|
+
they cannot drift from the code:
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
def divide(a: float, b: float) -> float:
|
|
147
|
+
"""Divide one number by another.
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
a: Dividend.
|
|
151
|
+
b: Divisor.
|
|
152
|
+
|
|
153
|
+
Returns:
|
|
154
|
+
The quotient of ``a`` and ``b``.
|
|
155
|
+
|
|
156
|
+
Raises:
|
|
157
|
+
ZeroDivisionError: If ``b`` is zero.
|
|
158
|
+
|
|
159
|
+
Examples:
|
|
160
|
+
>>> divide(6, 3)
|
|
161
|
+
2.0
|
|
162
|
+
"""
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
`docs.yml` builds the site in strict mode on every PR (the `docs` check) and
|
|
166
|
+
deploys it to GitHub Pages when a release is published (or on manual run).
|
|
167
|
+
|
|
89
168
|
## Release flow
|
|
90
169
|
|
|
91
170
|
```
|
|
92
|
-
PR opened ──▶ ci.yml (lint, ty, pytest matrix, commitlint)
|
|
171
|
+
PR opened ──▶ ci.yml (lint, ty, pytest + doctests matrix, commitlint)
|
|
172
|
+
──▶ docs.yml (strict docs build)
|
|
93
173
|
│
|
|
94
174
|
└─ optional: comment "@claude" ──▶ claude-review.yml
|
|
95
175
|
|
|
@@ -100,12 +180,14 @@ PR merged ──▶ main ──▶ release-please.yml
|
|
|
100
180
|
|
|
101
181
|
Release PR merged ──▶ release-please tags + creates GitHub Release
|
|
102
182
|
│
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
183
|
+
├─ publish.yml ──▶ uv build
|
|
184
|
+
│ ──▶ TestPyPI (OIDC)
|
|
185
|
+
│ ──▶ PyPI (OIDC, gated env)
|
|
186
|
+
│
|
|
187
|
+
├─ docker-publish.yml ──▶ Docker Hub
|
|
188
|
+
│ (<version>, <major.minor>, sha-*)
|
|
106
189
|
│
|
|
107
|
-
└─
|
|
108
|
-
(<version>, <major.minor>, sha-*)
|
|
190
|
+
└─ docs.yml ──▶ GitHub Pages
|
|
109
191
|
```
|
|
110
192
|
|
|
111
193
|
## Docker image
|
|
@@ -163,13 +245,26 @@ Required repo configuration (Settings → Secrets and variables → Actions):
|
|
|
163
245
|
pattern that release-please produces — by default
|
|
164
246
|
`<package-name>-v*` (e.g. `test-python-package-release-v*`)
|
|
165
247
|
|
|
166
|
-
7. **
|
|
167
|
-
|
|
168
|
-
-
|
|
169
|
-
|
|
170
|
-
- Block force pushes
|
|
171
|
-
-
|
|
172
|
-
|
|
173
|
-
|
|
248
|
+
7. **Branch protection ruleset** for `main`: Settings → Rules → Rulesets →
|
|
249
|
+
New branch ruleset (this repo uses one named `main-protection`):
|
|
250
|
+
- **Enforcement status**: Active (a Disabled ruleset enforces nothing)
|
|
251
|
+
- **Target branches**: Include default branch (`main`)
|
|
252
|
+
- **Restrict deletions** and **Block force pushes**
|
|
253
|
+
- **Require a pull request before merging** (required approvals can stay
|
|
254
|
+
at 0 for a solo project)
|
|
255
|
+
- **Require status checks to pass**, then Add checks: `lint`,
|
|
256
|
+
`test (3.11)`, `test (3.12)`, `test (3.13)`, `commitlint`, `docs`.
|
|
257
|
+
A check appears in the search only after it has run at least once in
|
|
258
|
+
the repo. "Require branches to be up to date" is optional and stricter.
|
|
259
|
+
- Release PRs from release-please run the same checks (they are created
|
|
260
|
+
with `RELEASE_PLEASE_TOKEN`), so they merge like any other PR. Add
|
|
261
|
+
yourself to the bypass list only if you need an emergency override.
|
|
262
|
+
|
|
263
|
+
8. **GitHub Pages**: Settings → Pages → Source: **GitHub Actions**. Then in
|
|
264
|
+
Settings → Environments → `github-pages` (created automatically) add a
|
|
265
|
+
**tag** deployment rule `test-python-package-release-v*` next to `main`:
|
|
266
|
+
the deploy job runs on the release tag, which is rejected otherwise.
|
|
267
|
+
|
|
268
|
+
9. **(Optional) Production gate** for PyPI publishing — on Pro/Team/Enterprise
|
|
174
269
|
plans only: add a Required reviewer on the `pypi` environment to require
|
|
175
270
|
manual approval before production publish.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
uv sync --group dev
|
|
7
|
+
uv run pre-commit install --hook-type pre-commit --hook-type commit-msg
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Quality gates
|
|
11
|
+
|
|
12
|
+
A pull request can be merged into `main` only when these CI checks are green:
|
|
13
|
+
|
|
14
|
+
| Check | What it enforces |
|
|
15
|
+
|---|---|
|
|
16
|
+
| `lint` | `ruff check` (including docstring rules), `ruff format --check`, `ty check src` |
|
|
17
|
+
| `test (3.11)`, `test (3.12)`, `test (3.13)` | Unit tests and doctests pass, total coverage is at least 70% |
|
|
18
|
+
| `commitlint` | Every commit follows [Conventional Commits](https://www.conventionalcommits.org/) |
|
|
19
|
+
| `docs` | The documentation builds in strict mode |
|
|
20
|
+
|
|
21
|
+
## Writing docstrings
|
|
22
|
+
|
|
23
|
+
The API Reference is generated from docstrings, so every public module and
|
|
24
|
+
function needs a [Google-style](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
|
25
|
+
docstring. Ruff's `D` rules fail the `lint` job when one is missing.
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
def divide(a: float, b: float) -> float:
|
|
29
|
+
"""Divide one number by another.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
a: Dividend.
|
|
33
|
+
b: Divisor.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
The quotient of ``a`` and ``b``.
|
|
37
|
+
|
|
38
|
+
Raises:
|
|
39
|
+
ZeroDivisionError: If ``b`` is zero.
|
|
40
|
+
|
|
41
|
+
Examples:
|
|
42
|
+
>>> divide(6, 3)
|
|
43
|
+
2.0
|
|
44
|
+
"""
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Lines starting with `>>>` are doctests: pytest runs them and compares the
|
|
48
|
+
output with the line below, so examples in the docs can never go stale.
|
|
49
|
+
|
|
50
|
+
## Working on the docs
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
uv run --group docs zensical serve # live preview on http://localhost:8000
|
|
54
|
+
uv run --group docs zensical build # strict build into site/
|
|
55
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Docker
|
|
2
|
+
|
|
3
|
+
Every GitHub Release publishes a multi-arch image (`linux/amd64`,
|
|
4
|
+
`linux/arm64`) to Docker Hub with the tags `<version>`, `<major>.<minor>`,
|
|
5
|
+
`latest` and `sha-<commit>`.
|
|
6
|
+
|
|
7
|
+
Run the published image:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
docker run --rm <dockerhub-user>/test-python-package-release:latest
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Build and run it locally from the repository root:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
docker buildx build -t test-python-package-release .
|
|
17
|
+
docker run --rm test-python-package-release
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The image installs the package wheel into `python:3.13-slim` and runs as a
|
|
21
|
+
non-root user.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Getting started
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
The package is published on [PyPI](https://pypi.org/p/test-python-package-release)
|
|
6
|
+
and supports Python 3.11, 3.12 and 3.13.
|
|
7
|
+
|
|
8
|
+
=== "uv"
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
uv add test-python-package-release
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
=== "pip"
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install test-python-package-release
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
Every public function is available from the top-level package:
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from test_python_package_release import divide, truncate
|
|
26
|
+
|
|
27
|
+
divide(10, 4) # 2.5
|
|
28
|
+
truncate("Hello world", 8) # see the API Reference for exact behavior
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Functions that cannot produce a result raise a standard exception, for example
|
|
32
|
+
`divide(1, 0)` raises `ZeroDivisionError`. Each function's page in the
|
|
33
|
+
**API Reference** lists its arguments, return value, raised exceptions and
|
|
34
|
+
runnable examples.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# test-python-package-release
|
|
2
|
+
|
|
3
|
+
A small template library that demonstrates a complete CI/CD pipeline for a
|
|
4
|
+
Python package: linting, tests with a coverage gate, automated releases with
|
|
5
|
+
release-please, and publishing to PyPI, Docker Hub and this documentation site.
|
|
6
|
+
|
|
7
|
+
The library itself ships two groups of helpers:
|
|
8
|
+
|
|
9
|
+
- **Calculator**: `add`, `subtract`, `multiply`, `divide`, `power`, `modulo`,
|
|
10
|
+
`sqrt`, `is_divisible`
|
|
11
|
+
- **Strings**: `reverse_string`, `count_words`, `truncate`, `snake_to_camel`,
|
|
12
|
+
`camel_to_snake`
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
>>> from test_python_package_release import add, snake_to_camel
|
|
16
|
+
>>> add(2, 3)
|
|
17
|
+
5
|
|
18
|
+
>>> snake_to_camel("hello_world")
|
|
19
|
+
'helloWorld'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Head to [Getting started](getting-started.md) to install the package, or browse
|
|
23
|
+
the **API Reference** in the navigation for every function, generated directly
|
|
24
|
+
from the docstrings in the source code.
|