diff --git a/.github/workflows/check-pr-title.yml b/.github/workflows/check-pr-title.yml index d5efb0b..479fa1a 100644 --- a/.github/workflows/check-pr-title.yml +++ b/.github/workflows/check-pr-title.yml @@ -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 }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..5597f9f --- /dev/null +++ b/.github/workflows/release-please.yml @@ -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 + diff --git a/README.md b/README.md index 64be519..ad72143 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 ``` @@ -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 \ No newline at end of file +- Include administrators + +## NOTE +- The python version should be aligned in `pyproject.toml` and `.mise.toml`. \ No newline at end of file diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..8ae84dd --- /dev/null +++ b/release-please-config.json @@ -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" +} + diff --git a/src/dummy.py b/src/dummy.py index ce6a7fd..5ecc81a 100644 --- a/src/dummy.py +++ b/src/dummy.py @@ -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): diff --git a/tests/utest/test_dummy.py b/tests/test_dummy.py similarity index 72% rename from tests/utest/test_dummy.py rename to tests/test_dummy.py index ef12c1f..b38da52 100644 --- a/tests/utest/test_dummy.py +++ b/tests/test_dummy.py @@ -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