From 262801288eb8dcdcf7d688968615fd56b85804c8 Mon Sep 17 00:00:00 2001 From: Frank Hoffmann <15r10nk-git@polarbit.de> Date: Tue, 31 Dec 2024 11:33:36 +0100 Subject: [PATCH] build: remove duty again --- .github/workflows/ci.yml | 33 ++++++++------------- pyproject.toml | 64 +++++++++++++++++++++++++++++++++++----- 2 files changed, 69 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53375c4..51340be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,18 +14,10 @@ jobs: python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: Install uv - uses: astral-sh/setup-uv@v5 - with: - python-version: ${{matrix.python-version}} - - - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 + - uses: ./.github/actions/setup with: python-version: ${{matrix.python-version}} - architecture: x64 - allow-prereleases: true - - run: uv run duty check_types + - run: uvx hatch run +py=${{matrix.python-version}} types:check test: runs-on: ubuntu-latest @@ -34,6 +26,9 @@ jobs: python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', pypy3.9, pypy3.10] os: [ubuntu-latest, windows-latest, macos-13] extra_deps: ['"--with=pytest==8.3.3" "--with=pydantic<2"', '"--with=pytest>=8.3.4" "--with=pydantic>2"'] + env: + TOP: ${{github.workspace}} + COVERAGE_PROCESS_START: ${{github.workspace}}/pyproject.toml steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: ./.github/actions/setup @@ -41,8 +36,11 @@ jobs: python-version: ${{matrix.python-version}} - run: | - uv run ${{matrix.extra_deps}} duty test ${{ matrix.os == 'ubuntu-latest' && 'coverage=True' }} + uv run ${{matrix.extra_deps}} -m ${{ matrix.os == 'ubuntu-latest' && 'coverage run -m' || '' }} pytest -n=auto + - run: | + uv run -m coverage combine mv .coverage .coverage.${{ matrix.python-version }}-${{matrix.os}}-${{strategy.job-index}} + if: matrix.os == 'ubuntu-latest' - name: Upload coverage data uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 @@ -62,15 +60,7 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Install uv - uses: astral-sh/setup-uv@v5 - with: - python-version: '3.12' - - - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 - with: - # Use latest Python, so it understands all syntax. - python-version: '3.12' + - uses: ./.github/actions/setup - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: @@ -114,6 +104,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 0 + - uses: ./.github/actions/setup - name: Check if the commit has a vx.y.z tag id: check-version @@ -126,7 +117,7 @@ jobs: echo "should_continue=false" >> "$GITHUB_OUTPUT" fi - - run: pip install hatch scriv + - run: uv pip install hatch scriv - name: build package run: hatch build diff --git a/pyproject.toml b/pyproject.toml index c9b4aff..b577c5e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,6 @@ version = "0.18.1" [dependency-groups] dev = [ - "duty>=1.4.2", "hypothesis>=6.75.5", "mypy>=1.2.0", "pyright>=1.1.359", @@ -104,6 +103,8 @@ dependencies = [ "pytest", "black" ] +[tool.hatch.envs.default] +installer="uv" [tool.hatch.envs.docs.scripts] build = "mkdocs build --strict" @@ -115,18 +116,73 @@ serve = "mkdocs serve" dependencies=["cogapp","lxml","requests"] scripts.update="cog -r docs/**.md" +[[tool.hatch.envs.hatch-test.matrix]] +python = ["3.13", "3.12", "3.11", "3.8","pypy3.9","pypy3.10"] +extra-deps=["low","hight"] + +[tool.hatch.envs.hatch-test.overrides] +matrix.extra-deps.dependencies = [ + { value = "pytest==8.3.3", if = ["low"] }, + { value = "pytest>=8.3.4", if = ["hight"] }, + { value = "pydantic<2", if = ["low"] }, + { value = "pydantic>=2", if = ["hight"] }, +] + +[tool.hatch.envs.hatch-test] +extra-dependencies = [ + "dirty-equals>=0.7.0", + "hypothesis>=6.75.5", + "mypy>=1.2.0", + "pyright>=1.1.359", + "pytest-subtests>=0.11.0", + "pytest-freezer>=0.4.8", + "pytest-mock>=3.14.0" +] +env-vars.TOP = "{root}" + +[tool.hatch.envs.hatch-test.scripts] +run = "pytest{env:HATCH_TEST_ARGS:} --use-uv {args}" +run-cov = "coverage run -m pytest{env:HATCH_TEST_ARGS:} --use-uv {args}" +cov-combine = "coverage combine" +cov-report=["coverage report","coverage html"] + +[tool.hatch.envs.types] +extra-dependencies = [ + "mypy>=1.0.0", + "pytest", + "hypothesis>=6.75.5", + "pydantic", + "attrs" +] + +[[tool.hatch.envs.types.matrix]] +python = ["3.8", "3.9", "3.10", "3.11", "3.12","3.13"] + +[tool.hatch.envs.types.scripts] +check = "mypy --install-types --non-interactive {args:src/inline_snapshot tests}" + +[tool.mypy] +exclude = "tests/.*_samples" + +[tool.pyright] +venv = "test-3-12" +venvPath = ".nox" + + [tool.hatch.envs.release] detached=true dependencies=[ "scriv", "commitizen" ] + [tool.hatch.envs.release.scripts] create=[ "scriv collect", "- pre-commit run -a", "cz bump" ] + publish=[ "git push --force-with-lease", "git push --tags", @@ -140,12 +196,6 @@ publish-package=[ "scriv github-release" ] -[tool.mypy] -exclude = "tests/.*_samples" - -[tool.pyright] -venv = "test-3-12" -venvPath = ".nox" [tool.scriv]