Skip to content

Commit

Permalink
build: use action composition
Browse files Browse the repository at this point in the history
  • Loading branch information
15r10nk committed Dec 31, 2024
1 parent b1a9a9f commit 4170c03
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 73 deletions.
21 changes: 21 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: General Setup
description: checkout & setup python
inputs:
python-version: # id of input
description: the python version to use
required: false
default: '3.12'
runs:
using: composite
steps:
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{inputs.python-version}}

- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: ${{inputs.python-version}}
architecture: x64
allow-prereleases: true
11 changes: 1 addition & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,9 @@ jobs:
extra_deps: ['"--with=pytest==8.3.3" "--with=pydantic<2"', '"--with=pytest>=8.3.4" "--with=pydantic>2"']
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{matrix.python-version}}

- name: Set up Python
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 ${{matrix.extra_deps}} duty test ${{ matrix.os == 'ubuntu-latest' && 'coverage=True' }}
Expand Down
81 changes: 18 additions & 63 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ readme = "README.md"
requires-python = ">=3.8"
version = "0.18.1"

[dependency-groups]
dev = [
"duty>=1.4.2",
"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",
"pytest-xdist>=3.6.1",
"coverage[toml]>=7.6.1",
"coverage-enable-subprocess>=1.0",
"pytest>=8.3.4",
"dirty-equals>=0.7.0",
"attrs>=24.3.0",
"pydantic>=1",
]

[project.entry-points.pytest11]
inline_snapshot = "inline_snapshot.pytest_plugin"

Expand Down Expand Up @@ -97,51 +115,6 @@ 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.10", "3.9", "3.8","pypy3.9","pypy3.10"]
pytest=["8.3.3","8.3.4"]

[tool.hatch.envs.hatch-test.overrides]
matrix.pytest.dependencies = [
{ value = "pytest==8.3.3", if = ["8.3.3"] },
{ value = "pytest>=8.3.4", if = ["8.3.4"] },
]


[tool.hatch.envs.hatch-test]
# Info for everyone who packages this library:
# The following dependencies are installed with uv if you run `pytest --use-uv`
# and used for specific tests in specific versions:
# - pydantic v1 & v2
# - attrs
# But you dont have to use uv to test this library.
# You can also just install the dependencies and use `pytest` normally
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.release]
detached=true
dependencies=[
Expand Down Expand Up @@ -181,21 +154,3 @@ version = "command: cz bump --get-next"

[tool.pytest.ini_options]
markers=["no_rewriting: marks tests which need no code rewriting and can be used with pypy"]

[dependency-groups]
dev = [
"duty>=1.4.2",
"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",
"pytest-xdist>=3.6.1",
"coverage[toml]>=7.6.1",
"coverage-enable-subprocess>=1.0",
"pytest>=8.3.4",
"dirty-equals>=0.7.0",
"attrs>=24.3.0",
"pydantic>=1",
]

0 comments on commit 4170c03

Please sign in to comment.