test-python-package-release 0.4.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.
Files changed (37) hide show
  1. test_python_package_release-0.6.0/.dockerignore +17 -0
  2. test_python_package_release-0.6.0/.github/.release-please-manifest.json +3 -0
  3. test_python_package_release-0.6.0/.github/workflows/docker-publish.yml +48 -0
  4. test_python_package_release-0.6.0/.github/workflows/docs.yml +47 -0
  5. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/.gitignore +3 -0
  6. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/CHANGELOG.md +25 -0
  7. test_python_package_release-0.6.0/Dockerfile +18 -0
  8. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/PKG-INFO +137 -18
  9. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/README.md +131 -16
  10. test_python_package_release-0.6.0/docs/contributing.md +55 -0
  11. test_python_package_release-0.6.0/docs/docker.md +21 -0
  12. test_python_package_release-0.6.0/docs/getting-started.md +34 -0
  13. test_python_package_release-0.6.0/docs/index.md +24 -0
  14. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/pyproject.toml +20 -4
  15. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/src/test_python_package_release/__init__.py +2 -2
  16. test_python_package_release-0.6.0/src/test_python_package_release/calculator.py +178 -0
  17. test_python_package_release-0.6.0/src/test_python_package_release/strings.py +95 -0
  18. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/uv.lock +448 -2
  19. test_python_package_release-0.6.0/zensical.toml +52 -0
  20. test_python_package_release-0.4.0/.github/.release-please-manifest.json +0 -3
  21. test_python_package_release-0.4.0/src/test_python_package_release/calculator.py +0 -38
  22. test_python_package_release-0.4.0/src/test_python_package_release/strings.py +0 -26
  23. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/.github/dependabot.yml +0 -0
  24. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/.github/release-please-config.json +0 -0
  25. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/.github/workflows/ci.yml +0 -0
  26. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/.github/workflows/claude-review.yml +0 -0
  27. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/.github/workflows/publish.yml +0 -0
  28. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/.github/workflows/release-please.yml +0 -0
  29. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/.pre-commit-config.yaml +0 -0
  30. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/.python-version +0 -0
  31. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/LICENSE +0 -0
  32. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/commitlint.config.cjs +0 -0
  33. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/docs/superpowers/plans/2026-05-30-python-package-release-template.md +0 -0
  34. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/docs/superpowers/specs/2026-05-30-python-package-release-template-design.md +0 -0
  35. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/tests/__init__.py +0 -0
  36. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/tests/test_calculator.py +0 -0
  37. {test_python_package_release-0.4.0 → test_python_package_release-0.6.0}/tests/test_strings.py +0 -0
@@ -0,0 +1,17 @@
1
+ .git
2
+ .github
3
+ .venv
4
+ .tox
5
+ .pytest_cache
6
+ .ruff_cache
7
+ .ty_cache
8
+ .vscode
9
+ .claude
10
+ .DS_Store
11
+ __pycache__
12
+ *.py[oc]
13
+ dist
14
+ build
15
+ tests
16
+ docs
17
+ test.py
@@ -0,0 +1,48 @@
1
+ name: Docker Publish
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ env:
9
+ IMAGE_NAME: ${{ vars.DOCKERHUB_USERNAME }}/test-python-package-release
10
+
11
+ jobs:
12
+ docker:
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ contents: read
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Docker meta
20
+ id: meta
21
+ uses: docker/metadata-action@v6
22
+ with:
23
+ images: ${{ env.IMAGE_NAME }}
24
+ # release-please tags look like "test-python-package-release-v1.2.3"
25
+ tags: |
26
+ type=semver,pattern={{version}},match=v(\d+\.\d+\.\d+.*)$
27
+ type=semver,pattern={{major}}.{{minor}},match=v(\d+\.\d+\.\d+.*)$
28
+ type=sha
29
+
30
+ - uses: docker/setup-qemu-action@v4
31
+ - uses: docker/setup-buildx-action@v4
32
+
33
+ - name: Login to Docker Hub
34
+ uses: docker/login-action@v4
35
+ with:
36
+ username: ${{ vars.DOCKERHUB_USERNAME }}
37
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
38
+
39
+ - name: Build and push
40
+ uses: docker/build-push-action@v7
41
+ with:
42
+ context: .
43
+ platforms: linux/amd64,linux/arm64
44
+ push: true
45
+ tags: ${{ steps.meta.outputs.tags }}
46
+ labels: ${{ steps.meta.outputs.labels }}
47
+ cache-from: type=gha
48
+ cache-to: type=gha,mode=max
@@ -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
@@ -21,3 +21,6 @@ build/
21
21
  .ty_cache/
22
22
  .coverage
23
23
  htmlcov/
24
+
25
+ # Documentation build output
26
+ site/
@@ -1,5 +1,30 @@
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
+
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)
21
+
22
+
23
+ ### Features
24
+
25
+ * **docker:** publish image to Docker Hub on release ([1c7ccec](https://github.com/wozniakos10/test_python_package_release/commit/1c7ccec3b0395be10c8678728b43eb94002ed239))
26
+ * **docker:** publish image to Docker Hub on release ([75695c7](https://github.com/wozniakos10/test_python_package_release/commit/75695c78082df0888927b68f94b313db16ef8cfa))
27
+
3
28
  ## [0.4.0](https://github.com/wozniakos10/test_python_package_release/compare/test-python-package-release-v0.3.2...test-python-package-release-v0.4.0) (2026-05-31)
4
29
 
5
30
 
@@ -0,0 +1,18 @@
1
+ FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder
2
+
3
+ WORKDIR /app
4
+ COPY pyproject.toml uv.lock README.md LICENSE ./
5
+ COPY src ./src
6
+ RUN uv build --wheel --out-dir /dist
7
+
8
+ FROM python:3.13-slim
9
+
10
+ LABEL org.opencontainers.image.source="https://github.com/wozniakos10/test_python_package_release"
11
+
12
+ COPY --from=builder /dist/*.whl /tmp/
13
+ RUN pip install --no-cache-dir /tmp/*.whl && rm /tmp/*.whl
14
+
15
+ RUN useradd --create-home appuser
16
+ USER appuser
17
+
18
+ CMD ["python", "-c", "import test_python_package_release as p; print(f'test-python-package-release {p.__version__}'); print('2 + 3 =', p.add(2, 3))"]
@@ -1,7 +1,11 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: test-python-package-release
3
- Version: 0.4.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`. | On-demand (`pytest --cov`) |
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,11 +218,33 @@ PR merged ──▶ main ──▶ release-please.yml
134
218
 
135
219
  Release PR merged ──▶ release-please tags + creates GitHub Release
136
220
  │
137
- └─ publish.yml ──▶ uv build
138
- ──▶ TestPyPI (OIDC)
139
- ──▶ PyPI (OIDC, gated env)
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-*)
227
+ │
228
+ └─ docs.yml ──▶ GitHub Pages
140
229
  ```
141
230
 
231
+ ## Docker image
232
+
233
+ Each GitHub Release also publishes a multi-arch image (amd64, arm64) to
234
+ Docker Hub. To try it locally:
235
+
236
+ ```bash
237
+ docker build -t test-python-package-release .
238
+ docker run --rm test-python-package-release
239
+ ```
240
+
241
+ Required repo configuration (Settings → Secrets and variables → Actions):
242
+
243
+ - Variable `DOCKERHUB_USERNAME`: your Docker Hub username
244
+ - Secret `DOCKERHUB_TOKEN`: a Docker Hub
245
+ [personal access token](https://app.docker.com/settings/personal-access-tokens)
246
+ with Read & Write scope
247
+
142
248
  ## First-time setup after cloning the template
143
249
 
144
250
  1. **Rename the package**: update `name` in `pyproject.toml`, the directory
@@ -177,13 +283,26 @@ Release PR merged ──▶ release-please tags + creates GitHub Release
177
283
  pattern that release-please produces — by default
178
284
  `<package-name>-v*` (e.g. `test-python-package-release-v*`)
179
285
 
180
- 7. **(Optional) Branch protection ruleset** for `main`:
181
- - Require a PR before merging
182
- - Require status checks: `lint`, `test (3.11)`, `test (3.12)`,
183
- `test (3.13)`, `commitlint`
184
- - Block force pushes, restrict deletions
185
- - Add yourself to the bypass list so you can merge release-please PRs
186
-
187
- 8. **(Optional) Production gate** for PyPI publishing — on Pro/Team/Enterprise
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
188
307
  plans only: add a Required reviewer on the `pypi` environment to require
189
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`. | On-demand (`pytest --cov`) |
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,11 +180,33 @@ PR merged ──▶ main ──▶ release-please.yml
100
180
 
101
181
  Release PR merged ──▶ release-please tags + creates GitHub Release
102
182
  │
103
- └─ publish.yml ──▶ uv build
104
- ──▶ TestPyPI (OIDC)
105
- ──▶ PyPI (OIDC, gated env)
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-*)
189
+ │
190
+ └─ docs.yml ──▶ GitHub Pages
106
191
  ```
107
192
 
193
+ ## Docker image
194
+
195
+ Each GitHub Release also publishes a multi-arch image (amd64, arm64) to
196
+ Docker Hub. To try it locally:
197
+
198
+ ```bash
199
+ docker build -t test-python-package-release .
200
+ docker run --rm test-python-package-release
201
+ ```
202
+
203
+ Required repo configuration (Settings → Secrets and variables → Actions):
204
+
205
+ - Variable `DOCKERHUB_USERNAME`: your Docker Hub username
206
+ - Secret `DOCKERHUB_TOKEN`: a Docker Hub
207
+ [personal access token](https://app.docker.com/settings/personal-access-tokens)
208
+ with Read & Write scope
209
+
108
210
  ## First-time setup after cloning the template
109
211
 
110
212
  1. **Rename the package**: update `name` in `pyproject.toml`, the directory
@@ -143,13 +245,26 @@ Release PR merged ──▶ release-please tags + creates GitHub Release
143
245
  pattern that release-please produces — by default
144
246
  `<package-name>-v*` (e.g. `test-python-package-release-v*`)
145
247
 
146
- 7. **(Optional) Branch protection ruleset** for `main`:
147
- - Require a PR before merging
148
- - Require status checks: `lint`, `test (3.11)`, `test (3.12)`,
149
- `test (3.13)`, `commitlint`
150
- - Block force pushes, restrict deletions
151
- - Add yourself to the bypass list so you can merge release-please PRs
152
-
153
- 8. **(Optional) Production gate** for PyPI publishing — on Pro/Team/Enterprise
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
154
269
  plans only: add a Required reviewer on the `pypi` environment to require
155
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
+ ```