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
36 changes: 36 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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:
max-parallel: 1
mpangrazzi marked this conversation as resolved.
Show resolved Hide resolved
matrix:
python-version: [3.9, 3.10.x, 3.11, 3.12]
mpangrazzi marked this conversation as resolved.
Show resolved Hide resolved
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 unit and integration tests
run: hatch run test:all
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to also run and report coverage.
These commands can serve as examples: https://github.com/deepset-ai/haystack-core-integrations/blob/4f067b9b183020d039be017990eb7f868e116099/integrations/amazon_bedrock/pyproject.toml#L53

Even if the report is only visible in GitHub Actions, it is still inspectable
An example: https://github.com/deepset-ai/haystack-core-integrations/actions/runs/12397435961/job/34607798450?pr=1255

Copy link
Contributor Author

@mpangrazzi mpangrazzi Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I was planning to add it later, but we can run test:cov here to get both tests and cov output.

25 changes: 14 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 @@ -43,15 +43,9 @@ hayhooks = "hayhooks.cli:hayhooks"
[tool.hatch.version]
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}"
[tool.hatch.envs.test.scripts]
all = "pytest -vv {args:tests}"
all-cov = "coverage run -m pytest {args:tests}"
cov-report = [
"- coverage combine",
"coverage report",
Expand All @@ -61,8 +55,17 @@ 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