From 285498d448bc05f4e552a970b4b1ba48d9654cd6 Mon Sep 17 00:00:00 2001 From: Arseny Boykov Date: Mon, 11 Nov 2024 14:09:51 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=EF=B8=8F=20Move=20to=20UV?= =?UTF-8?q?=20and=20Ruff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 116 +++++++++++++++++++++------------------ pyproject.toml | 69 +++++++++++++---------- 2 files changed, 104 insertions(+), 81 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3019ad7..7a2d5d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,31 +12,60 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.13' - - name: Install Poetry - uses: snok/install-poetry@v1.4.1 + - name: Install UV + uses: astral-sh/setup-uv@v3 with: - virtualenvs-create: false - version: 1.1.15 + enable-cache: true + cache-suffix: "${{ matrix.os }}-${{ matrix.python-version }}" + cache-dependency-glob: "**/pyproject.toml" - - name: Load cached wheels - id: cached-pip-wheels - uses: actions/cache@v2 + - name: Install dependencies + run: uv sync --extra typing + + - name: check + run: uv run ruff check parametrize + + - name: format + run: uv run ruff format parametrize + + + type-check: + needs: lint + strategy: + fail-fast: false + matrix: + os: ["ubuntu-latest", "macos-latest", "windows-latest"] + python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + defaults: + run: + shell: bash # required for windows + runs-on: ${{ matrix.os }} + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 with: - path: | - ~/cache - poetry.lock - key: venv-${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }} + python-version: ${{ matrix.python-version }} + + - name: Install UV + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + cache-suffix: "${{ matrix.os }}-${{ matrix.python-version }}" + cache-dependency-glob: "**/pyproject.toml" - name: Install dependencies - run: poetry install --no-interaction --no-root + run: uv sync --extra typing - - name: flake8 - run: flake8 parametrize tests + - name: Run MyPy + run: uv run mypy parametrize test: needs: lint @@ -51,65 +80,46 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Check out repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Install Poetry - uses: snok/install-poetry@v1.4.1 - with: - virtualenvs-create: false - version: 1.1.15 - - - name: Load cached wheels - id: cached-pip-wheels - uses: actions/cache@v2 + - name: Install uv + uses: astral-sh/setup-uv@v3 with: - path: | - ~/cache - poetry.lock - key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }} + enable-cache: true + cache-suffix: "${{ matrix.os }}-${{ matrix.python-version }}" + cache-dependency-glob: "**/pyproject.toml" - name: Install dependencies - run: poetry install --no-interaction --no-root - - - name: Run mypy - run: mypy parametrize + run: uv sync --extra test - name: Run tests run: pytest tests --cov=parametrize - deploy: needs: test if: "success() && startsWith(github.ref, 'refs/tags/')" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.13' - - name: Install Poetry - uses: snok/install-poetry@v1.4.1 - with: - virtualenvs-create: false - version: 1.1.15 - - - name: Install poetry-dynamic-versioning - run: python -m pip install poetry-dynamic-versioning - - - name: Bump version - run: poetry-dynamic-versioning + - name: Build + run: uv build - name: Generate Changelog run: python tools/get_changes.py ${{ github.ref }} > changelog.txt - - name: Upload to pypi - run: poetry publish --build --username __token__ --password ${{ secrets.PYPI_TOKEN }} + - name: Upload to PyPI + env: + UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: uv publish - name: Release uses: softprops/action-gh-release@v1 diff --git a/pyproject.toml b/pyproject.toml index 11460fd..fe3533f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,16 @@ -[tool.poetry] + +[project] name = "parametrize" -version = "0.0.0" description = "Drop-in @pytest.mark.parametrize replacement working with unittest.TestCase" -authors = ["Bobronium "] -license = "MIT" +authors = [ + {name = "Bobronium", email = "write@bobronium.me"} +] +dynamic = ["version"] +license = {text = "MIT"} +requires-python = ">=3.6" readme = "readme.md" -repository = "https://github.com/Bobronium/parametrize/" +keywords = ["pytest", "parametrize", "unittest"] +homepage = "https://github.com/Bobronium/parametrize/" classifiers = [ "Development Status :: 3 - Alpha", "Framework :: Pytest", @@ -28,34 +33,42 @@ classifiers = [ "Typing :: Typed", ] -[tool.black] -target_version = ["py36", "py37", "py38", "py39"] +[tool.ruff] +target-version = "py37" # technically it should be py36, but ruff doesn't support it line-length = 100 -[tool.poetry-dynamic-versioning] -vcs = "git" -style = "semver" +[tool.ruff.lint] +select = ["E4", "E7", "E9", "F", "B", "Q"] -[tool.poetry.dependencies] -python = "^3.6.2" -[tool.poetry.dev-dependencies] -black = "^21.4b2" -isort = "^5.8.0" -mypy = "^0.971" +[tool.uv-dynamic-versioning] +vcs = "git" +style = "semver" -flake8 = "^3.9.1" -flake8-use-fstring = "^1.1" -flake8-comprehensions = "^3.4.0" -flake8-bugbear = "^21.4.3" -flake8-black = "^0.2.1" -flake8-isort = "^4.0.0" +[project.optional-dependencies] +typing = [ + "mypy==0.971", +] +test = [ + "pytest-cov>=2.11.1", + "pytest-sugar>=0.9.4", + "pytest-mock>=3.6.0" +] +lint = [ + "ruff", +] +dev = [ + "parametrize[lint,typing,test]" +] -pytest = "^6.2.3" -pytest-cov = "^2.11.1" -pytest-sugar = "^0.9.4" -pytest-mock = "^3.6.0" +[tool.setuptools.dynamic] +version = {vcs = "git", style = "semver"} [build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" +requires = ["hatchling", "uv-dynamic-versioning"] +build-backend = "hatchling.build" + +[tool.hatch.version] +source = "uv-dynamic-versioning" +vcs = "git" +style = "semver"