Skip to content

Commit

Permalink
🛠️️ Move to UV and Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobronium committed Nov 11, 2024
1 parent 4aa2fa6 commit 285498d
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 81 deletions.
116 changes: 63 additions & 53 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
- 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
Expand All @@ -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/[email protected]
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/[email protected]
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
Expand Down
69 changes: 41 additions & 28 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
authors = [
{name = "Bobronium", email = "[email protected]"}
]
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",
Expand All @@ -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"

0 comments on commit 285498d

Please sign in to comment.