From c05a0c03f556c6652e7bd4228d5c7ec5b28306b1 Mon Sep 17 00:00:00 2001 From: Lucian Buzzo Date: Thu, 11 Sep 2025 19:13:40 +0100 Subject: [PATCH] feat: add CI/CD workflows for automated releases and unit testing --- .github/runs-on.yml | 1 + .github/workflows/release-please.yml | 57 +++++++++++++++ .github/workflows/run-unit-tests.yml | 39 ++++++++++ .release-please-config.json | 20 ++++++ .release-please-manifest.json | 3 + README.md | 102 +++++++++++++++++++++++++++ 6 files changed, 222 insertions(+) create mode 100644 .github/runs-on.yml create mode 100644 .github/workflows/release-please.yml create mode 100644 .github/workflows/run-unit-tests.yml create mode 100644 .release-please-config.json create mode 100644 .release-please-manifest.json diff --git a/.github/runs-on.yml b/.github/runs-on.yml new file mode 100644 index 0000000..f5b92c4 --- /dev/null +++ b/.github/runs-on.yml @@ -0,0 +1 @@ +_extends: repo-settings diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..efc3f6f --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,57 @@ +# Automate generation of release PRs using Conventional Commits +# See https://github.com/googleapis/release-please + +name: release-please + +on: + push: + branches: [ master ] + workflow_dispatch: + +jobs: + release-please: + timeout-minutes: 30 + runs-on: ubuntu-latest + # expose the step outputs at the job level so other jobs can use them + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + steps: + - name: Run release-please + id: release + uses: googleapis/release-please-action@v4 + with: + # Use whatever token you currently use; GITHUB_TOKEN also works + token: ${{ secrets.GHA_NODEJS_TOKEN }} + config-file: .release-please-config.json + manifest-file: .release-please-manifest.json + + publish: + name: Build & publish to PyPI + needs: release-please + # only run if a release/tag was created by the job above + if: ${{ needs.release-please.outputs.release_created == 'true' }} + runs-on: ubuntu-latest + permissions: + contents: read + # not strictly required by pypa/gh-action-pypi-publish, but fine to leave minimal + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install build backend + run: | + python -m pip install --upgrade pip + pip install build + + - name: Build sdist and wheel + run: python -m build + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@v1.10.2 + with: + password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml new file mode 100644 index 0000000..985716f --- /dev/null +++ b/.github/workflows/run-unit-tests.yml @@ -0,0 +1,39 @@ +name: Run Unit Tests + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + run-unit-tests: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Set up Just + uses: extractions/setup-just@v3 + + - name: Install UV + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + + - name: Install dependencies + run: | + uv sync + uv pip install -e . + + - name: Copy .env.template to .env + run: | + cp .env.template .env + + - name: Run linting + run: | + just lint diff --git a/.release-please-config.json b/.release-please-config.json new file mode 100644 index 0000000..e7f3295 --- /dev/null +++ b/.release-please-config.json @@ -0,0 +1,20 @@ +{ + "changelog-sections": [ + {"type": "feat", "section": "Features"}, + {"type": "fix", "section": "Bug Fixes"}, + {"type": "perf", "section": "Performance Improvements"}, + {"type": "docs", "section": "Documentation", "hidden": false}, + {"type": "style", "section": "Styles", "hidden": false}, + {"type": "refactor", "section": "Code Refactoring", "hidden": false}, + {"type": "test", "section": "Tests", "hidden": false}, + {"type": "build", "section": "Build System", "hidden": false}, + {"type": "ci", "section": "Continuous Integration", "hidden": false}, + {"type": "chore", "section": "Miscellaneous Chores", "hidden": false}, + {"type": "revert", "section": "Reverts"} + ], + "packages": { + ".": { + "release-type": "python" + } + } +} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..3d2ac0b --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.1.0" +} \ No newline at end of file diff --git a/README.md b/README.md index e69de29..95ca58c 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,102 @@ +# types-nameparser + +[![PyPI version](https://badge.fury.io/py/types-nameparser.svg)](https://badge.fury.io/py/types-nameparser) +[![Python versions](https://img.shields.io/pypi/pyversions/types-nameparser.svg)](https://pypi.org/project/types-nameparser/) + +Typing stubs for the [nameparser](https://github.com/derek73/python-nameparser) library. + +## Overview + +This package provides type information (stub files) for the `nameparser` library, enabling better IDE support and static type checking when working with human name parsing functionality. + +The `nameparser` library is a Python library for parsing human names into their component parts (first name, last name, middle name, title, suffix, etc.), but it doesn't include type hints. This package fills that gap by providing comprehensive type stubs. + +## Installation + +```bash +pip install types-nameparser +``` + +Or if you're using [uv](https://github.com/astral-sh/uv): + +```bash +uv add types-nameparser +``` + +## Usage + +After installation, you can use the type stubs with your existing `nameparser` code: + +```python +from nameparser import HumanName + +# Now you get full type hints and IDE support! +name = HumanName("Dr. John Michael Smith Jr.") +print(name.first) # "John" +print(name.last) # "Smith" +print(name.middle) # "Michael" +print(name.title) # "Dr." +print(name.suffix) # "Jr." +``` + +## Type Information + +The stubs provide type information for the `HumanName` class with the following properties: + +- `first: str` - First name component +- `last: str` - Last name component +- `middle: str` - Middle name component +- `title: str` - Title component (Mr., Mrs., Dr., etc.) +- `suffix: str` - Suffix component (Jr., Sr., III, etc.) +- `nickname: str` - Nickname component + +## Development + +This project uses [uv](https://github.com/astral-sh/uv) for dependency management and [just](https://github.com/casey/just) for task running. + +### Setup + +```bash +# Install dependencies +just install +``` + +### Available Commands + +```bash +# Run linting +just lint + +# Run linting with auto-fix +just lint-fix + +# Format code +just format + +# Type checking +just type-check + +# Run tests +just test + +# Run tests with coverage +just test-cov +``` + +## Requirements + +- Python 3.10+ +- The actual `nameparser` library (this package only provides type stubs) + +## License + +This project is licensed under the same terms as the original `nameparser` library. + +## Contributing + +Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change. + +## Related Projects + +- [nameparser](https://github.com/derek73/python-nameparser) - The original name parsing library +- [typeshed](https://github.com/python/typeshed) - Collection of type stubs for Python standard library and third-party packages