|
14 | 14 | [](https://github.com/psf/black) |
15 | 15 | [](https://github.com/charliermarsh/ruff) |
16 | 16 |
|
| 17 | +This template repository provides the boilerplate to create a python package. |
| 18 | +It is configured with all the following features: |
| 19 | + |
| 20 | +* Test suite using [pytest](https://docs.pytest.org/en/7.4.x/) |
| 21 | +* Typing using [mypy](https://mypy.readthedocs.io/en/stable/) |
| 22 | +* Linting using [ruff](https://github.com/astral-sh/ruff) |
| 23 | +* Code formatter using [black](https://pypi.org/project/black/) |
| 24 | +* Integration with CodeClimate for code quality and coverage checks |
| 25 | +* CI pipeline supporting: |
| 26 | + * testing against multiple python versions |
| 27 | + * releases on [PyPI](https://pypi.org) |
| 28 | + * GitHub pages documentation using [mkdocs](https://www.mkdocs.org) |
| 29 | + |
| 30 | +This project doesn't currently use [tox](https://tox.wiki/en/4.11.4/index.html) or other matrix |
| 31 | +testing utilities. I prefer to run the tests only against the latest python locally, and run |
| 32 | +previous python versions directly in the CI pipeline to catch these bugs. |
| 33 | + |
| 34 | +## How to use this repository template to create a new package |
| 35 | + |
| 36 | +* Create your github repository using this template. (The big green `Use this template` button) |
| 37 | +* Rename the `bootstrap_python_package` directory |
| 38 | +* Search and replace all the occurrences of `bootstrap-python-package` and `bootstrap_python_package` |
| 39 | +* Configure a pending trusted publisher on [pypi](https://pypi.org/manage/account/publishing) using the following values: |
| 40 | + * PyPI Project Name: what you renamed the directory `bootstrap_python_package` to (Double check `_` and `-`) |
| 41 | + * Owner: The github repository owner (in this case `febus982`) |
| 42 | + * Repository name: The github repository name (in this case `bootstrap-python-package`) |
| 43 | + * Workflow name: `release.yml` |
| 44 | +* Create a github actions secret named `CODECLIMATE_REPORTER_ID` (at URL https://github.com/GITHUB_NAME_OR_ORGANIZATION/GITHUB_REPOSITORY/settings/secrets/actions) |
| 45 | + containing the codeclimate reporter id (you can find it at https://codeclimate.com/repos/YOUR_REPO_ID/settings/test_reporter). |
| 46 | + If you don't want to use CodeClimate just delete `workflows/python-quality.yml`. |
| 47 | +* Update the badges in `README.md`! (check [shields.io](https://shields.io/) for extra badges) |
| 48 | + |
| 49 | + |
| 50 | +## Package release |
| 51 | + |
| 52 | +This setup uses [poetry-dynamic-versioning](https://github.com/mtkennerly/poetry-dynamic-versioning). |
| 53 | +This means it's not necessary to commit the version in the code but the CI pipeline |
| 54 | +will infer it from the git tag. |
| 55 | + |
| 56 | +To release a new version, just create a new release in the github repository. It will |
| 57 | +create a new tag and do all the magic. |
| 58 | + |
| 59 | +**IMPORTANT:** The default configuration requires the release name and the tag to follow |
| 60 | +the convention `vX.X.X` (semantic versioning preceded by lowercase `v`). It will publish |
| 61 | +the correct version on Pypi, omitting the `v` (ie. `v1.0.0` will publish `1.0.0`). |
| 62 | + |
| 63 | +This format can be customized, refer to [poetry-dynamic-versioning docs](https://github.com/mtkennerly/poetry-dynamic-versioning) |
17 | 64 |
|
18 | 65 | ## Commands for development |
19 | 66 |
|
| 67 | +All the common commands used during development can be run using make targets: |
| 68 | + |
20 | 69 | * `make dev-dependencies`: Install dev requirements |
21 | 70 | * `make test`: Run test suite |
22 | 71 | * `make check`: Run tests, code style and lint checks |
23 | | -* `make fix`: Run tests, code style and lint checks with automatic fixes (where possible) |
| 72 | +* `make fix`: Run code style and lint automatic fixes (where possible) |
24 | 73 | * `make docs`: Render the mkdocs website locally |
0 commit comments