python-repo-template

CI Codecov CodeQL Snyk Checks Secrets Scan Python Version Code style: black GitHub last commit License

Modern Python project template with Poetry, Makefile workflows, automated testing, linting, and GitHub Actions CI/CD.

All notable changes to this project will be documented in CHANGELOG.

Supports Python 3.12, 3.13

✨ What’s Included

πŸ”§ Development Tools

πŸ” Security & Code Quality

πŸš€ CI/CD

πŸš€ Getting Started

1. Create Repository from Template

Click β€œUse this template” on GitHub or:

mkdir new_repo_name
cd new_repo_name
git init
git pull https://github.com/kyhau/python-repo-template

2. Customize Your Project

Update these files:

3. Set Up Development Environment

Quick setup (recommended for first-time setup):

make setup-init

Manual setup (if you prefer step-by-step):

make setup-venv    # Configure Poetry to use local virtualenv
make install-all   # Install all dependencies

πŸ“‹ Development Workflow

Common Commands

make setup-init         # First-time setup (configure, lock, install everything)
make help               # Show all available commands
make install-all        # Install all dependencies (main, dev, test)
make test               # Run tests without coverage
make test-with-coverage # Run tests with coverage
make format-python      # Auto-format Python code
make lint-python        # Lint Python code
make lint-yaml          # Lint YAML files
make pre-commit         # Run all quality checks (format, lint, test)
make build              # Build the package
make clean              # Clean build artifacts

Running Tests

# Run tests with coverage
make test-with-coverage

# Run tests only
make test

# Format and lint code
make format-python
make lint-python
make lint-yaml

Managing Dependencies

# Update dependencies to latest compatible versions
make update-deps

# Regenerate lock file
make lock

πŸ—οΈ Project Structure

python-repo-template/
β”œβ”€β”€ .github/
β”‚   β”œβ”€β”€ workflows/        # CI/CD workflows
β”‚   └── dependabot.yml    # Dependency updates config
β”œβ”€β”€ app/                  # Your Python package
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── main.py
β”œβ”€β”€ tests/                # Unit tests
β”‚   └── test_main.py
β”œβ”€β”€ pyproject.toml        # Project metadata and dependencies
β”œβ”€β”€ Makefile              # Build and test commands
└── README.md             # This file

πŸ“¦ Building and Releasing

# Build the package
make build

# The built package will be in dist/
ls dist/