diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 63344c6..6128efa 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,4 @@ -name: Upload Python Package +name: Publish on: release: @@ -8,74 +8,57 @@ on: permissions: contents: read -jobs: - release-checks: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Set up uv - uses: astral-sh/setup-uv@v4 - with: - python-version: "3.10" - enable-cache: true +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false - - name: Check lint - run: uv run ruff check src tests - - - name: Run tests - run: uv run pytest - - - name: Build docs - run: uv run sphinx-build -b html docs /tmp/pymax-docs - - release-build: +jobs: + package: + name: Build package runs-on: ubuntu-latest - needs: release-checks steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false + - name: Checkout repository + uses: actions/checkout@v6 - - name: Set up uv - uses: astral-sh/setup-uv@v4 + - name: Install uv + uses: astral-sh/setup-uv@v8.1.0 with: - python-version: "3.10" enable-cache: true - - name: Build release distributions + - name: Build package distributions run: uv build - - name: Check distributions + - name: Validate package distributions run: uv run twine check dist/* - - name: Upload distributions + - name: Upload package distributions uses: actions/upload-artifact@v4 with: - name: release-dists + name: package-distributions path: dist/ - pypi-publish: + publish: + name: Publish to PyPI runs-on: ubuntu-latest - needs: release-build + needs: [package] + environment: name: pypi - url: https://pypi.org/project/maxapi-python/ permissions: contents: read id-token: write steps: - - name: Retrieve release distributions + - name: Download package distributions uses: actions/download-artifact@v4 with: - name: release-dists + name: package-distributions path: dist/ - - name: Publish release distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + - name: Install uv + uses: astral-sh/setup-uv@v8.1.0 + + - name: Publish package to PyPI + run: uv publish diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..36b2715 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,66 @@ +name: Tests + +on: + pull_request: + push: + branches: [main, "dev/**"] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: checks-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Install uv + uses: astral-sh/setup-uv@v8.1.0 + with: + enable-cache: true + + - name: Install development dependencies + run: uv sync --group dev + + - name: Check code formatting + run: uv run ruff format --check . + + - name: Run Ruff linting + run: uv run ruff check . + + tests: + name: Tests / Python ${{ matrix.python-version }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Install uv + uses: astral-sh/setup-uv@v8.1.0 + with: + python-version: ${{ matrix.python-version }} + enable-cache: true + + - name: Install development dependencies + run: uv sync --group dev + + - name: Run tests with coverage + run: | + uv run pytest \ + --cov=src/pymax \ + --cov-report=term-missing:skip-covered \ + --cov-report=markdown-append:$GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index f33c1f3..d44883e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", ] dependencies = [ "aiofiles>=25.1.0", @@ -36,20 +37,8 @@ dependencies = [ Homepage = "https://github.com/MaxApiTeam/PyMax" Repository = "https://github.com/MaxApiTeam/PyMax" Issues = "https://github.com/MaxApiTeam/PyMax/issues" -Documentation = "https://maxapiteam.github.io/PyMax/" +Documentation = "https://docs.pymax.org" -[project.optional-dependencies] -docs = [ - "furo>=2025.12.19", - "sphinx>=8.1.3", - "sphinx-copybutton>=0.5.2", -] -test = [ - "pytest>=8.0.0", - "pytest-asyncio>=0.24.0", - "pytest-cov>=5.0.0", - "pytest-timeout>=2.1.0", -] [build-system] requires = ["hatchling"] @@ -88,27 +77,27 @@ test = [ dev = [ {include-group = "docs"}, {include-group = "test"}, - "build>=1.2.0", "pre-commit>=4.0.0", "twine>=5.0.0", "pyright>=1.1.390", "ruff>=0.8.0", ] +[tool.uv] +package = true + [tool.pyright] venv = ".venv" venvPath = "." [tool.ruff] line-length = 79 -target-version = "py310" [tool.ruff.lint] select = ["E", "F", "I"] -ignore = ["E501"] +ignore = [] [tool.ruff.lint.per-file-ignores] -"src/pymax/**/__init__.py" = ["F401", "F403"] "tests/**" = ["F401"] [tool.ruff.format] diff --git a/src/pymax/api/models.py b/src/pymax/api/models.py index cd64c91..0a358bb 100644 --- a/src/pymax/api/models.py +++ b/src/pymax/api/models.py @@ -1,13 +1,13 @@ -from pydantic import BaseModel +from pydantic import BaseModel, ConfigDict from pydantic.alias_generators import to_camel class CamelModel(BaseModel): - model_config = { - "alias_generator": to_camel, - "populate_by_name": True, - "arbitrary_types_allowed": True, - } + model_config = ConfigDict( + alias_generator=to_camel, + populate_by_name=True, + arbitrary_types_allowed=True + ) def to_payload(self) -> dict: return self.model_dump(by_alias=True, exclude_none=True)