|
| 1 | +# Contributing to pyCosign |
| 2 | + |
| 3 | +First off, **thank you for taking the time to contribute!** |
| 4 | +The following guidelines help keep the project consistent and maintainable. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## Table of Contents |
| 9 | +1. [Code of Conduct](#code-of-conduct) |
| 10 | +2. [Getting Started](#getting-started) |
| 11 | +3. [Branching & Workflow](#branching--workflow) |
| 12 | +4. [Commit Conventions](#commit-conventions) |
| 13 | +5. [Developer Certificate of Origin (DCO)](#developer-certificate-of-origin-dco) |
| 14 | +6. [Coding Style](#coding-style) |
| 15 | +7. [Testing](#testing) |
| 16 | +8. [Pull-Request Checklist](#pull-request-checklist) |
| 17 | +9. [Release Process](#release-process) |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Code of Conduct |
| 22 | +We follow the [Contributor Covenant](https://www.contributor-covenant.org/version/2/1/code_of_conduct/) v2.1. |
| 23 | +Please be respectful and inclusive in all interactions. |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +### Getting Started (Poetry) |
| 28 | + |
| 29 | +```bash |
| 30 | +# clone |
| 31 | +git clone https://github.com/your-org/pycosign.git |
| 32 | +cd pycosign |
| 33 | + |
| 34 | +# install Poetry (if not already) |
| 35 | +curl -sSL https://install.python-poetry.org | python3 - |
| 36 | + |
| 37 | +# create & activate venv + install deps |
| 38 | +poetry install --with dev |
| 39 | + |
| 40 | +# drop into project shell |
| 41 | +poetry shell |
| 42 | + |
| 43 | +# install git hooks |
| 44 | +pre-commit install |
| 45 | + |
| 46 | +*Poetry automatically selects Python ≥ 3.10 on your system or the one specified in pyproject.toml. All dev tools—ruff, black, mypy, pytest, invoke—are declared under [tool.poetry.group.dev].* |
| 47 | + |
| 48 | +### Prerequisites |
| 49 | + |
| 50 | +| Tool | Required Version | Notes | |
| 51 | +|------------------|------------------|-------| |
| 52 | +| **Poetry** | 1.8 or newer | Dependency & virtual-env manager | |
| 53 | +| **Python** | 3.10 – 3.12 | Poetry will auto-select within this range | |
| 54 | +| **cosign CLI** | ≥ 2.2 | `brew install sigstore/tap/cosign` or download release binary | |
| 55 | +| **plantuml** | _optional_ | Render `.puml` diagrams locally (`brew install plantuml`) | |
| 56 | +| **Docker** | _optional_ | Quick PlantUML preview, OCI registry tests | |
| 57 | + |
| 58 | +## Branching & Workflow |
| 59 | + |
| 60 | +* **`main`** — always releasable; tagged releases are cut from here. |
| 61 | +* **Feature branches** — name `feature/<short-topic>` (e.g., `feature/registry-push`). |
| 62 | +* **Bug-fix branches** — name `bugfix/<issue-#>` (e.g., `bugfix/42-null-sig-path`). |
| 63 | +* **Documentation-only branches** — name `docs/<topic>`. |
| 64 | + |
| 65 | +Workflow: |
| 66 | + |
| 67 | +1. Create an **Issue** if one doesn’t exist. |
| 68 | +2. Branch from `main` with the naming rules above. |
| 69 | +3. Work locally in a Poetry shell: |
| 70 | + ```bash |
| 71 | + poetry shell |
| 72 | + git checkout -b feature/my-cool-thing |
| 73 | + ``` |
| 74 | +4. Keep commits small, descriptive, and signed (`git commit -s`). |
| 75 | +5. Push to your fork / to the repo: `git push -u origin feature/my-cool-thing`. |
| 76 | +6. Open a **pull request** against `main`. GitHub Actions will run: |
| 77 | + * lint → test → type-check → coverage → packaging checks. |
| 78 | +7. Address review comments; squash-merge once approved. |
| 79 | +> **Tip:** Use `git rebase -i main` to keep history clean before opening the PR. |
| 80 | + |
| 81 | +## Commit Conventions |
| 82 | + |
| 83 | +We follow **Conventional Commits**: |
| 84 | +```bash |
| 85 | +feature(signer): add --push flag for sign-blob |
| 86 | +bugfix(verifier): handle missing Rekor bundle gracefully |
| 87 | +docs: update README diagrams |
| 88 | +``` |
| 89 | + |
| 90 | +## Developer Certificate of Origin (DCO) |
| 91 | + |
| 92 | +By submitting a PR you certify you have the right to submit the work under the project’s [MIT license](LICENSE). |
| 93 | +Sign your commits: |
| 94 | + |
| 95 | +```bash |
| 96 | +git commit -s -m "bugfix: correct typo" |
| 97 | +``` |
| 98 | +The `-s` flag adds the required `Signed-off-by` line. |
| 99 | + |
| 100 | +## Coding Style |
| 101 | + |
| 102 | +* **ruff** for linting (`black`, `isort`, `flake8` rules) |
| 103 | +* Docstrings follow **Google style**. |
| 104 | + |
| 105 | +Run all checks: |
| 106 | + |
| 107 | +* **black** for formatting (PEP 8 compliant). |
| 108 | +```bash |
| 109 | +poetry run black --verbose pycosign |
| 110 | +``` |
| 111 | + |
| 112 | +* **isort** your imports, so you don't have to. |
| 113 | +```bash |
| 114 | +poetry run isort --verbose pycosign |
| 115 | +``` |
| 116 | +
|
| 117 | +## Testing |
| 118 | +
|
| 119 | +* **pytest** with **pytest-asyncio** for async routines. |
| 120 | +* 90%+ coverage target. |
| 121 | +
|
| 122 | +```bash |
| 123 | +pytest -q |
| 124 | +``` |
| 125 | +CI will fail if coverage drops below the threshold. |
| 126 | +
|
| 127 | +## Pull-Request Checklist |
| 128 | +
|
| 129 | +Before requesting a review, make sure you can check **every** box below: |
| 130 | +
|
| 131 | +- [ ] **Issue linked** (e.g., “Closes #123”) or marked N/A for trivial docs fixes. |
| 132 | +- [ ] **Unit / integration tests** added or updated; `poetry run pytest` passes locally. |
| 133 | +- [ ] **Docs updated** (`README`, `docs/`, or inline docstrings) if behavior changed. |
| 134 | +- [ ] **Changelog entry** added under `## [Unreleased]` in `CHANGELOG.md`. |
| 135 | +- [ ] `pre-commit run --all-files` passes (ruff, black, mypy, etc.). |
| 136 | +- [ ] All commits are **signed** (`git commit -s`) to satisfy the DCO. |
| 137 | +- [ ] PR title follows **Conventional Commits** (e.g., `feat(verifier): add policy flag`). |
| 138 | +- [ ] CI status is green (GitHub Actions). |
| 139 | +
|
| 140 | +> 🔒 PRs without a Signed-off-by line will be blocked by the DCO GitHub check. |
| 141 | +
|
| 142 | +## Release Process |
| 143 | +
|
| 144 | +1. Merge all features into `main`. |
| 145 | +2. Bump version with `bumpver update --push-tag`. |
| 146 | +3. GitHub Action builds sdist & wheels and uploads to PyPI. |
| 147 | +4. Draft release notes in `CHANGELOG.md`. |
| 148 | +
|
| 149 | +Happy hacking! 💙 |
0 commit comments