Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic action to run current tests #49

Merged
merged 13 commits into from
Dec 19, 2024
Merged
35 changes: 35 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 17 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
mpangrazzi marked this conversation as resolved.
Show resolved Hide resolved
license = "Apache-2.0"
keywords = []
authors = [
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions tests/test_handle_callable_type.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from collections.abc import Callable as CallableABC
from types import NoneType
from typing import Any, Callable, Optional, Union

import haystack
Expand All @@ -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):
Expand All @@ -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,
},
Expand Down
Loading