Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/check-pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ jobs:
steps:
- uses: deepakputhraya/action-pr-title@master
with:
min_length: 6 # Min length of the title
max_length: 72 # Max length of the title
github_token: ${{ github.token }} # Default: ${{ github.token }}
# Only allow Conventional Commits prefixes recognized by release-please
# feat: minor version bump, fix: patch version bump, others: no version bump
regex: '^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?: (.+)'
allowed_prefixes: 'feat,fix,docs,style,refactor,perf,test,build,ci,chore,revert'
disallowed_prefixes: ''
prefix_case_sensitive: false
min_length: 10
max_length: 72
verbal_description: 'Conventional Commit message compatible with release-please (e.g., "feat: Add new feature", "fix: Fix bug")'
github_token: ${{ github.token }}
23 changes: 23 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: release-please

on:
push:
branches:
- main
workflow_dispatch:

permissions:
contents: write
issues: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
config-file: release-please-config.json

10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ A template project for quickly starting Python projects with modern development

## Overview
This template provides a modern Python development environment with the following features:
- **Python 3.12+** support
- **Ruff** for code formatting and linting (replaces Black, isort, flake8)
- **pytest** for unit testing and coverage reporting
- **uv** for fast dependency management
- **Type hints** and **PEP 257** compliant docstring enforcement
- **GitHub Actions** for CI/CD pipeline
- **Release Please** for automated version management based on Conventional Commits
- Modular project structure (src layout)
- Logging configuration included

Expand All @@ -18,7 +18,10 @@ python-project-template/
├── src/ # Source code
├── tests/ # Test code
├── .github/ # GitHub Actions workflows
├── .cursorrules # Cursor IDE AI assistant rules and guidelines
├── .mise.toml # mise tool version manager configuration (Python and tool versions)
├── pyproject.toml # Project configuration and dependencies
├── release-please-config.json # Release Please configuration for automated version management
├── Makefile # Development commands
└── logging.conf # Logging configuration
```
Expand Down Expand Up @@ -47,4 +50,7 @@ $ make test # run unit tests
- Branch name pattern: `main`
- Require a pull request before merging & Require approvals
- Require status checks to pass before merging & Require branches to be up to date before merging
- Include administrators
- Include administrators

## NOTE
- The python version should be aligned in `pyproject.toml` and `.mise.toml`.
11 changes: 11 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"packages": {
".": {
"release-type": "python",
"package-name": "python-project-template",
"version-file": "pyproject.toml"
}
},
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}

12 changes: 11 additions & 1 deletion src/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@


def fibonacci(num: int) -> int:
"""Return fibonacci number."""
"""Calculate the nth Fibonacci number.

Args:
num: The position in the Fibonacci sequence (must be non-negative).

Returns:
The nth Fibonacci number.

Raises:
AssertionError: If num is negative.
"""
assert num >= 0
prev, curr = 0, 1
for _ in range(num):
Expand Down
7 changes: 6 additions & 1 deletion tests/utest/test_dummy.py → tests/test_dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@


def test_fibonacci() -> None:
"""Test fibonacci numbers."""
"""Test fibonacci function with various inputs.

Tests include:
- Negative input validation (should raise AssertionError)
- Fibonacci sequence values from 0 to 9
"""
with pytest.raises(AssertionError):
fibonacci(-1)
assert fibonacci(0) == 0
Expand Down