Skip to content

Commit

Permalink
Merge pull request #49 from deepset-ai/ci
Browse files Browse the repository at this point in the history
Add basic action to run current tests
  • Loading branch information
mpangrazzi authored Dec 19, 2024
2 parents ad6837b + ffb37be commit 7ac3180
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 14 deletions.
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"
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

0 comments on commit 7ac3180

Please sign in to comment.