Skip to content

rjoydip/pytent

Pytent

ci uv pre-commit conventional commits pyright ruff

A project template with UV package manager and CI integration.

πŸš€ Features

  • UV - An extremely fast Python package and project manager, written in Rust.
  • Ruff - An extremely fast Python linter and code formatter, written in Rust.
  • Pytest - The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
  • Pyright - Static Type Checker for Python
  • uv-secure - Scan your uv.lock file for dependencies with known vulnerabilities
  • pre-commit - A framework for managing and maintaining multi-language pre-commit hooks
  • commitizen - Create committing rules for projects πŸš€ auto bump versions ⬆️ and auto changelog generation πŸ“‚

πŸ“‹ Prerequisites

  • Python >=3.12+ - Download the latest version
  • Docker Desktop - Docker Desktop is a one-click-install or Podman - The best free & open source container tools
  • UV - An extremely fast Python package and project manager, written in Rust.

πŸ›  Installation

  • Clone the repository:

Install project dependencies:

uv sync --all-packages
  • Ruff
uv tool install ruff
  • Pyright
uv tool install pyright
  • Pip Audit
uv tool install uv-secure
  • Pre-commit
uv tool install pre-commit uvx pre-commit install
  • Commitizen
uv tool install commitizen

Upgrade Tools

uv tool upgrade [...TOOL_NAMES]

Development

Local Development

  • Audit package vulnerability
uvx uv-secure .
  • Run Pre-commit against all the files
uvx pre-commit run --all-files
  • Run code formatting and linting:
# local uvx ruff check . --fix # ci uvx ruff check --output-format=json . > artifacts/ruff-output.json
  • Run typechecking:
# local uvx pyright . # ci uvx pyright . --outputjson > artifacts/pyright-output.json 2>&1
  • Run tests:
# local uv run pytest # ci uv run pytest --cov=packages --cov-report=json:artifacts/coverage.json
  • Complexity Analysis
# local uvx xenon . # or uvx xenon . --paths-in-front > artifacts/complexity-report.json

Local application development

# Development uv run fastapi dev services/app --port 8000 --host 127.0.0.1 # Production uv run fastapi run services/app/main.py --port 8000 --host 127.0.0.1

Docker/Podman Development

Build and run the api in Docker/Podman:

docker build -t app . docker run <IMAGE_NAME> # Or podman build -t app . podman run <IMAGE_NAME>

Docker/Podman compose

Build and run the api in Docker/Podman compose:

docker compose up --build # Or podman compose up --build

Commitizen Commands

Command Description Alias
cz commit Create a new commit cz c
cz bump Bump version and update changelog -
cz changelog Generate changelog cz ch
cz check Validate commit messages -
cz version Show version information -

🌐 API Endpoints

  • GET /: Returns a "API is working" message
  • GET /healthcheck: Returns a system check message

πŸ§ͺ Testing

Tests are located in the tests/ directory. Run the test suite using:

uv run pytest

πŸ” Project Structure

pytent/ β”œβ”€ .devcontainer/ β”‚ └─ devcontainer.json β”œβ”€ .github/ β”‚ β”œβ”€ actions/ β”‚ β”‚ └─ setup/ β”‚ β”‚ └─ action.yml β”‚ β”œβ”€ workflows/ β”‚ β”‚ β”œβ”€ ci.yml β”‚ β”‚ └─ release.yml β”‚ └─ dependabot.yml β”œβ”€ artifacts/ β”‚ └─ .gitkeep β”œβ”€ docs/ β”‚ └─ .gitkeep β”œβ”€ packages/ β”‚ β”œβ”€ error/ β”‚ β”‚ β”œβ”€ __init__.py β”‚ β”‚ β”œβ”€ exceptions.py β”‚ β”‚ └─ handler.py β”‚ └─ log/ β”‚ β”œβ”€ __init__.py β”‚ └─ logger.py β”œβ”€ scripts/ β”‚ └─ .gitkeep β”œβ”€ services/ β”‚ β”œβ”€ api/ β”‚ β”‚ β”œβ”€ __init__.py β”‚ β”‚ β”œβ”€ main.py β”‚ └─ functions/ β”‚ β”œβ”€ src/ β”‚ β”‚ └─ main.py β”‚ └─ requirements.txt β”œβ”€ tests/ β”‚ β”œβ”€ e2e/ β”‚ β”‚ └─ .gitkeep β”‚ β”œβ”€ fixtures/ β”‚ β”‚ └─ .gitkeep β”‚ └─ integration/ β”‚ β”‚ └─ .gitkeep β”‚ └─ unit/ β”‚ └─ .test_hello.py β”œβ”€ tools/ β”‚ └─ .gitkeep β”œβ”€ .gitattributes β”œβ”€ .gitignore β”œβ”€ .pre-commit-config.yaml β”œβ”€ .python-version β”œβ”€ .tool-versions β”œβ”€ CHANGELOG.md β”œβ”€ docker-compose.yml β”œβ”€ Dockerfile β”œβ”€ LICENSE β”œβ”€ pyproject.toml β”œβ”€ README.md └─ uv.lock

πŸ‘₯ Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

Released under MIT by @rjoydip.

About

A monorepo project template with UV package manager

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors