π Creating a New Projectο
Via cruft
(recommended):
pip install --user cruft # Install `cruft` on your path for easy access
cruft create https://github.com/TeoZosa/cookiecutter-cruft-poetry-tox-pre-commit-ci-cd
Via cookiecutter
:
pip install --user cookiecutter # Install `cookiecutter` on your path for easy access
cookiecutter gh:TeoZosa/cookiecutter-cruft-poetry-tox-pre-commit-ci-cd
Note: Cookiecutter uses gh:
as short-hand for https://github.com/
π Linking an Existing Projectο
If the project was originally installed via
cookiecutter
, you must first use
cruft
to link the project with the original
template:
cruft link https://github.com/TeoZosa/cookiecutter-cruft-poetry-tox-pre-commit-ci-cd
Then/else:
cruft update
β¨οΈ Featuresο
π Project Standardization and Automationο
π¨ Developer Workflow Automationο
Python packaging and dependency management with Poetry
Project workflow orchestration with Make as an interface shim
Self-documenting Makefile; just type
make
on the command line to display auto-generated documentation on available targets:
Automated Cookiecutter template synchronization with cruft
Test automation with Tox
Code quality tooling automation and management with pre-commit
Continuous integration and deployment with GitHub Actions
π± Conditionally Rendered Python Package or Project Boilerplateο
β‘οΈ Performanceο
π¦οΈ C-Extension Compilationο
Python module to C-extension compilation (enabled by standard Python type hints) with Mypyc
Automatically configured for Python package builds (see the templateβs build.py file)
β οΈοΈ Warning
Mypyc is currently alpha software. Itβs only recommended for production use cases with careful testing, and if you are willing to contribute fixes or to work around issues you will encounter.
π§ Maintainabilityο
π·οΈ Type Checking and Data Validationο
Run-time type-checking with Typeguard
See the Typeguard user guide for usage overview
π₯ Tip
Complementary to type-checking, function-specific input validation is another useful technique. This helps eliminate an implicit knowledge violation from hidden argument requirements:βHidden argument requirements occur when a method signature implies a wider range of valid inputs than the method actually accepts. For example, accepting an int while only allowing numbers 1 to 10 is a hidden constraint.β [1]
[1] C. Riccomini and D. Ryaboy, The Missing README: A Guide for the New Software Engineer, Paperback. No Starch Press, 2021.
β οΈ Testing/Coverageο
Testing with
pytest
Mutation testing with mutmut
βΉοΈ Info
For a good overview of how property-based testing and mutation testing work together to improve the value and quality of your tests, see this stackoverflow post and the follow-up by themutmut
author.
Code coverage with Coverage.py
Coverage reporting with Codecov
π¨ Lintingο
Code quality:
Code formatting:
General file formatting:
Unsanitary commits:
Secrets with
detect-secrets
Debugger imports and py37+
breakpoint()
calls withdebug-statements
Large files with
check-added-large-files
Invalid Python files with
check-ast
π· CI/CDο
Docker image builds and pushes to Docker Hub[4]
Documentation building and hosting with Read the Docs
Release notes (PR-based) drafting and publishing with Release Drafter
Dependency updates with Dependabot
Automated Dependabot PR merging with the Dependabot Auto Merge GitHub Action[4]
Project issue labels management with GitHub Labeler
Lightweight polyglot static analysis for code quality enforcement in addition to bug and security vulnerability identification with Semgrep
π Observabilityο
π Loggingο
Structured logging with
structlog-sentry-logger
(viastructlog
)Granular control flow context logging (via call stack introspection):
Namespaced module-specific loggers
Function name logging
Environment-dependent standard output stream log formatting:
Production: JSON logs
Development: Colorized human-readable logs, with JSON logs saved locally for retrospective analysis
[Optional] Exception logging to Sentry with
structlog-sentry
π₯ Error Trackingο
[Optional] Exception monitoring with Sentry
see: the cookiecutterβs
.env
file for a detailed activation guide
ποΈ Securityο
π Static Application Security Testing (SAST)ο
ποΈ Accessibilityο
π Project Documentationο
Documentation building with Sphinx
Rich automatic documentation from type annotations and docstrings (NumPy, Google, etc.) with
sphinx-autoapi
Automated emoji shortcode conversion[5]
Docstring coverage with
interrogate
Automated README table of contents generation with
markdown-toc
Publishing to Confluence with Atlassian Confluence Builder for Sphinx
βοΈ Design Documentation and Production Deployment Checklistsο
Production service design documentation and deployment checklist templates with Mercariβs
production-readiness-checklist
ποΈ Architecture Documentationο
[Optional] Architecture knowledge management with Log4brains to systematically facilitate and record the planning process and context for each of a software systemβs architectural changes that occur over time and their consequences.
See: Documenting Architecture Decisions for an overview on Architecture Decision Records (ADR)
π§ββοΈ Legalο
π Licenseο
cookiecutter-cruft-poetry-tox-pre-commit-ci-cd is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.