diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..ccc743c --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,35 @@ +name: Tests + +on: + push: + branches: + - main + pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + +env: + HATCH_VERSION: "1.14.0" + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.9, '3.10', 3.11, 3.12] + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Hatch + run: pip install hatch==${{ env.HATCH_VERSION }} + + - name: Run tests and generate coverage report + run: hatch run test:cov diff --git a/pyproject.toml b/pyproject.toml index e44b332..3987b26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "hayhooks" dynamic = ["version"] description = 'Grab and deploy Haystack pipelines' readme = "README.md" -requires-python = ">=3.7,<3.13" +requires-python = ">=3.9,<3.13" license = "Apache-2.0" keywords = [] authors = [ @@ -44,25 +44,31 @@ hayhooks = "hayhooks.cli:hayhooks" source = "vcs" [tool.hatch.envs.default] -dependencies = [ - "coverage[toml]>=6.5", - "pytest", - "pytest-mock", -] -[tool.hatch.envs.default.scripts] -test = "pytest {args:tests}" -test-cov = "coverage run -m pytest {args:tests}" +installer = "uv" + +[tool.hatch.envs.test.scripts] +all = "pytest -vv {args:tests}" +all-cov = "coverage run -m pytest {args:tests}" cov-report = [ "- coverage combine", "coverage report", ] cov = [ - "test-cov", + "all-cov", "cov-report", ] +[tool.hatch.envs.test] +extra-dependencies = [ + "coverage[toml]>=6.5", + "pytest", + "pytest-mock", + "qdrant-haystack", + "trafilatura", +] + [[tool.hatch.envs.all.matrix]] -python = ["3.10", "3.11", "3.12"] +python = ["3.9", "3.10", "3.11", "3.12"] [tool.hatch.envs.lint] detached = true diff --git a/tests/test_handle_callable_type.py b/tests/test_handle_callable_type.py index 529b6cf..1b68b24 100644 --- a/tests/test_handle_callable_type.py +++ b/tests/test_handle_callable_type.py @@ -1,5 +1,4 @@ from collections.abc import Callable as CallableABC -from types import NoneType from typing import Any, Callable, Optional, Union import haystack @@ -20,7 +19,7 @@ (str, False), (Any, False), (Union[int, str], False), - (Optional[Callable[[haystack.dataclasses.streaming_chunk.StreamingChunk], NoneType]], True), + (Optional[Callable[[haystack.dataclasses.streaming_chunk.StreamingChunk], type(None)]], True), ], ) def test_is_callable_type(t, expected): @@ -33,7 +32,7 @@ def test_skip_callables_when_creating_pipeline_models(): "generator": { "system_prompt": {"type": Optional[str], "is_mandatory": False, "default_value": None}, "streaming_callback": { - "type": Optional[Callable[[haystack.dataclasses.streaming_chunk.StreamingChunk], NoneType]], + "type": Optional[Callable[[haystack.dataclasses.streaming_chunk.StreamingChunk], type(None)]], "is_mandatory": False, "default_value": None, },