|
| 1 | +--- |
| 2 | +name: pr-workflow |
| 3 | +description: Create pull requests for python-zeroconf/python-zeroconf. Use when creating PRs, submitting changes, or preparing contributions. |
| 4 | +allowed-tools: Read, Bash, Glob, Grep |
| 5 | +--- |
| 6 | + |
| 7 | +# python-zeroconf PR Workflow |
| 8 | + |
| 9 | +When creating a pull request for `python-zeroconf/python-zeroconf`, |
| 10 | +follow these steps. Repo-wide conventions live in |
| 11 | +[CLAUDE.md](../../../CLAUDE.md); this skill summarises the parts |
| 12 | +that matter at PR-creation time. |
| 13 | + |
| 14 | +## 1. Create branch from origin/master |
| 15 | + |
| 16 | +The default branch is `master`, not `main`. `origin` already |
| 17 | +points at `python-zeroconf/python-zeroconf` — there is no fork in |
| 18 | +this workflow. Always re-fetch first so the branch is based on |
| 19 | +the latest `master`: |
| 20 | + |
| 21 | +```bash |
| 22 | +git fetch origin |
| 23 | +git checkout -b <branch-name> origin/master |
| 24 | +``` |
| 25 | + |
| 26 | +If you accidentally branch from `main`, `gh pr create` will fail |
| 27 | +because the base branch does not exist. |
| 28 | + |
| 29 | +## 2. There is no PR template |
| 30 | + |
| 31 | +`python-zeroconf` does not ship a `.github/PULL_REQUEST_TEMPLATE.md` |
| 32 | +— PR bodies are free-form. Aim for a body that looks roughly like: |
| 33 | + |
| 34 | +``` |
| 35 | +## Summary |
| 36 | +<1–3 sentence prose description of what changed and why> |
| 37 | +
|
| 38 | +## Details |
| 39 | +<bullets explaining the non-obvious parts: RFC sections cited, |
| 40 | +performance characteristics measured, edge cases handled> |
| 41 | +
|
| 42 | +## Test plan |
| 43 | +- [ ] <how you verified the change> |
| 44 | +- [ ] <new tests added under tests/ — point at the file> |
| 45 | +``` |
| 46 | + |
| 47 | +Cite the relevant RFC section (RFC 6762 / RFC 6763) for any |
| 48 | +behaviour change that affects packet contents or timing — |
| 49 | +reviewers shouldn't have to reverse-engineer why a constant moved |
| 50 | +or a probe interval changed. |
| 51 | + |
| 52 | +## 3. Commit message conventions |
| 53 | + |
| 54 | +Commit messages are linted by `commitlint` with |
| 55 | +`@commitlint/config-conventional`, _and_ by `commitizen` in |
| 56 | +pre-commit (`stages: [commit-msg]`). Both must pass. |
| 57 | + |
| 58 | +- **Conventional Commits prefix is required.** Pick from: |
| 59 | + `feat`, `fix`, `perf`, `refactor`, `docs`, `test`, `build`, |
| 60 | + `ci`, `chore`, `style`, `revert`. The `feat`/`fix`/`perf` |
| 61 | + prefixes show up in the release-notes; `chore*` and `ci*` are |
| 62 | + excluded by semantic-release (`exclude_commit_patterns` in |
| 63 | + `pyproject.toml`), so use those for housekeeping. |
| 64 | +- **Imperative-mood subject.** "fix: handle empty answer", not |
| 65 | + "fix: handled empty answer". |
| 66 | +- **No header length cap.** The commitlint config sets |
| 67 | + `header-max-length: [0, "always", Infinity]`, so a slightly |
| 68 | + longer subject is fine if it earns the space; don't pad. |
| 69 | +- **No `Co-Authored-By` trailers from automated agents.** |
| 70 | +- **One logical change per commit.** Let pre-commit run (ruff |
| 71 | + lint + format, mypy, flake8, codespell, cython-lint, |
| 72 | + pyupgrade). If a hook auto-fixes something, re-stage and |
| 73 | + re-commit; the commit-msg hook re-runs on the new commit. |
| 74 | + |
| 75 | +## 4. Cython / `.pxd` discipline |
| 76 | + |
| 77 | +If the PR touches any module listed in `TO_CYTHONIZE` |
| 78 | +(`build_ext.py`): |
| 79 | + |
| 80 | +- Update the sibling `.pxd` in the same commit if you changed a |
| 81 | + `cdef class` layout or a `cpdef`/`cdef` signature. |
| 82 | +- Do not hand-edit the in-tree `.c` files; the build regenerates |
| 83 | + them, and they're excluded from sdist (`exclude = ["**/*.c"]` |
| 84 | + in `pyproject.toml`). |
| 85 | +- Verify the extension still builds locally: |
| 86 | + `REQUIRE_CYTHON=1 poetry install` (re-installs in-place, |
| 87 | + failing loudly if Cython rejects anything). |
| 88 | +- Verify it still works without the extension: |
| 89 | + `SKIP_CYTHON=1 poetry install && poetry run pytest tests/`. |
| 90 | + |
| 91 | +## 5. Push and create the PR |
| 92 | + |
| 93 | +```bash |
| 94 | +git push -u origin <branch-name> |
| 95 | +gh pr create --repo python-zeroconf/python-zeroconf --base master \ |
| 96 | + --title "<conventional-commit subject>" \ |
| 97 | + --body-file /tmp/pr-body.md |
| 98 | +``` |
| 99 | + |
| 100 | +Always pass the body via `--body-file`, never `--body "..."` with |
| 101 | +shell-escaping — Markdown backticks, asterisks, and angle |
| 102 | +brackets must pass through verbatim. |
| 103 | + |
| 104 | +The PR title should match the commit subject (same Conventional |
| 105 | +Commits prefix). If the PR ends up squash-merged, the title |
| 106 | +becomes the merged commit message, so it has to satisfy |
| 107 | +commitlint on its own. |
| 108 | + |
| 109 | +## 6. After the PR is open |
| 110 | + |
| 111 | +CI runs three jobs: |
| 112 | + |
| 113 | +- `lint` — `pre-commit/action`. If pre-commit passed locally |
| 114 | + this passes too. |
| 115 | +- `commitlint` — `wagoid/commitlint-github-action`. Validates |
| 116 | + every commit on the PR; if you amended after pushing, force- |
| 117 | + push the branch so the rewritten commits get linted. |
| 118 | +- `test` — the full pytest matrix across CPython 3.9–3.14, |
| 119 | + 3.14t (free-threaded), and PyPy 3.9 / 3.10, on Linux + macOS + |
| 120 | + Windows. The free-threaded entry is the canary for unguarded |
| 121 | + shared-state bugs; failures there are often genuine even when |
| 122 | + the GIL-enabled rows pass. |
| 123 | + |
| 124 | +CodSpeed also runs on PRs (`CodSpeedHQ/action`) and posts a |
| 125 | +benchmark delta as a check. A regression there is signal — if |
| 126 | +the PR is a perf change, the comment is the evidence; if not, a |
| 127 | +red CodSpeed check usually means the hot path picked up an extra |
| 128 | +Python-level branch and wants a second look. |
0 commit comments