A demo repository showcasing Python project development and packaging best practices using uv. This project demonstrates project structure, dependency management, containerization with Docker and automated code quality, security scanning and deployment workflows using GitHub Actions (GHA).
Table of Contents
- Project Overview
- Getting Started
- Development Setup
- Development Workflow
- Documentation
- Acknowledgements
- License
This repository serves as a demonstration and learning resource. To use this as a template for new projects, refer to the setup guide in the documentation.
- Python packaging:
- Dependency management with uv
- Automated versioning using setuptools-scm
- GHA workflows for CI/CD and security:
- Code quality checks with pre-commit, ruff, mypy, and pytest
- Security scans with Safety, CodeQL, Dependabot, and Zizmor
- Python package deployment to Test PyPI
- Container image deployment to GitHub Container Registry
- Developer tools: VS Code integration, development containers, Taskfile automation
.github/workflows- GHA for CI/CD pipelines, security scanning and dependency updates (see GitHub Actions Workflows).pyproject.toml- Python package config, dependencies, and build settingsTaskfile.yml- Automated tasks for setting up the dev environment, running code quality checks and more. Runtask helpto see all available tasks or refer to the Command Cheatsheet.
Full overview of the repository structure is available in the Repository Structure documentation.
Results of the security scans are visible in the Security tab of the GitHub repository.
The uv-demo package is a minimal package with a single function that prints the package name. You can install this package from Test PyPI or pull the containerized version from GHCR. The main purpose of this repository is to explore development tools and observe the CI/CD pipeline in action. To get started, follow the steps in the Development Workflow section.
Note
This package is published to Test PyPI for demonstration purposes. Test PyPI is a testing environment for package deployment without affecting the official PyPI index. If you're using this repo to test out your own deployment pipeline, make sure not to publish test versions to the official PyPI index.
Install the demo package from Test PyPI:
pip install -i https://test.pypi.org/simple/ uv-demoimport uv_demo
uv_demo.main()
# > Hello from uv-demo!
# > Version: 0.0.1Or pull and run the container:
docker pull ghcr.io/ac-willeke/uv-demo:latest
docker run --rm ghcr.io/ac-willeke/uv-demo:latest
# > Hello from uv-demo!
# > Version: 0.0.1Tip
Recommended Setup: Use GitHub Codespaces or VS Code Devcontainers for a consistent environment. Local OS setup without containers requires extra configuration.
The following steps configure your development environment using VS Code Dev Containers. For local setup without containers, refer to the setup guide in the documentation.
- Docker
- Visual Studio Code
- VS Code Dev Containers extension
-
Open the project: Clone and open the project folder in VS Code or use GitHub Codespaces.
-
Start the devcontainer: When prompted, reopen the folder in the Devcontainer. If not prompted, manually trigger it via the Command Palette (
Ctrl+Shift+PorCmd+Shift+P) and select "Dev Containers: Reopen in Container". -
Automatic setup: The devcontainer automatically:
- Configures VS Code with recommended settings and extensions per devcontainer.json
- Installs development tools: Git, uv, pre-commit, Task
- Sets up the Python environment with dependencies in
.venvviatask dev-setup, which runsuv sync --devand executes code quality checks and test coverage
-
Test the installation with Task commands:
Task is used to automate common development tasks (see Taskfile.yml).
# Test the package task run # or uv run uv-demo # Run quality checks task check # Run local CI workflow task ci-local # Clean up task clean
-
Test the notebook: Open
notebooks/demo.ipynband select the.venvkernel. If you have problems activating the.venvrefer to the setup guide. -
Configure the GitHub Repository: If you fork this repository or use it to create your a new repository from scratch, you'll need to configure your GitHub repository to connect with Test PyPI, Safety and Code Coverage. Also, verify that your security scans are properly set up. See the GitHub Repository Configuration section in the setup guide for instructions.
Follow PEP8, use type hints, and include docstrings in reStructuredText format. All quality checks are automated through Task commands, pre-commit hooks and CI workflows.
See the Code Quality and Security Standards guide to see which rules are enforced in this repo.
The repository includes automated workflows for code quality, security, and deployment:
| Workflow | Trigger | Purpose |
|---|---|---|
| CI Python | push, pull_request to main |
Code quality checks, testing, coverage |
| CD Python | push to main with version tags |
Package deployment to Test PyPI |
| CD Docker | push to main with version tags |
Container deployment to GitHub Registry |
| Safety Scan | push, pull_request, schedule |
Python dependency vulnerability scanning |
| CodeQL Analysis | push, pull_request, schedule |
Code security analysis |
| Zizmor Security | push, pull_request |
GHA workflow security |
The demo workflows can be customized or removed based on your specific project requirements. At minimum, I recommend including the CI Python workflow for code quality and testing, as well as the Security workflows: CodeQL, Safety, and Zizmor.
Use these commands for local development and testing:
# Setup and quality checks
task install # Install dependencies and setup environment
task check # Run all quality checks
task ci-local # Simulate CI pipeline locally
# Testing and running
task test # Run test suite
task run # Run the demo package
task run-docker # Run in Docker container
# Code formatting and security
task format # Format code with ruff
task security # Run security scansFor more commands see: Command Cheatsheet
The main branch is protected with the following rules:
- Require pull request reviews before merging
- Require status checks to pass before merging
- Require branches to be up to date before merging
This project incorporates best practices from the Python and DevOps communities, including:
- Astral-sh's uv Documentation and Docker configuration example astral-sh/uv-docker-example
- Eric Riddoch's Taking Python to Production course
- Marvelous MLOps MLOps with Databricks course
This project is licensed under the MIT License - see the LICENSE file for details.