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

feat: tests on PR & push to main #21

Merged
merged 7 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Hatch
run: pip install hatch

- name: Run tests
run: hatch run tests

code-quality:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Hatch
run: pip install hatch

- name: Run mypy
run: hatch run code-quality:mypy src tests

- name: Run black
run: hatch run code-quality:format

- name: Run ruff
run: hatch run code-quality:lint-ci
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ detached = true
[tool.hatch.envs.dc.scripts]
build = "mkdir -p dist && zip -r dist/custom_component.zip ./* -x 'dist/*' '**/__pycache__/*'"
push = "curl --request POST --url https://api.cloud.deepset.ai/api/v2/custom_components --header 'accept: application/json' --header \"Authorization: Bearer $API_KEY\" --form 'file=@dist/custom_component.zip;type=application/zip'"
build-and-push = "mkdir -p dist && zip -r dist/custom_component.zip ./* -x 'dist/*' '**/__pycache__/*' && curl --request POST --url https://api.cloud.deepset.ai/api/v2/custom_components --header 'accept: application/json' --header \"Authorization: Bearer $API_KEY\" --form 'file=@dist/custom_component.zip;type=application/zip'"
build-and-push = "hatch run code-quality:all && mkdir -p dist && zip -r dist/custom_component.zip ./* -x 'dist/*' '**/__pycache__/*' && curl --request POST --url https://api.cloud.deepset.ai/api/v2/custom_components --header 'accept: application/json' --header \"Authorization: Bearer $API_KEY\" --form 'file=@dist/custom_component.zip;type=application/zip'"
Copy link
Member Author

Choose a reason for hiding this comment

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

thats a bit drastic, but it should help us fixing bugs in dC

list = "curl --request GET --url https://api.cloud.deepset.ai/api/v2/custom_components --header 'accept: application/json' --header \"Authorization: Bearer $API_KEY\""
build-windows = "powershell -Command \"& {{ if (-Not (Test-Path dist)) {{mkdir dist}}; if (Test-Path dist/custom_component.zip) {{ Remove-Item dist/custom_component.zip }}; Get-ChildItem -Path . | Where-Object {{ $_.FullName -notlike '*\\dist*' }} | Compress-Archive -DestinationPath dist/custom_component.zip -Update }}"
push-windows = "curl --request POST --url https://api.cloud.deepset.ai/api/v2/custom_components --header \"accept: application/json\" --header \"Authorization: Bearer %API_KEY%\" --form \"file=@dist/custom_component.zip;type=application/zip\""
Expand All @@ -63,6 +63,13 @@ dependencies = [
packages = ["src/dc_custom_component"]

[tool.hatch.envs.code-quality.scripts]
format = "black src tests --check"
format-fix = "black src tests"
lint = "ruff check . --output-format=github"
lint-ci = "ruff check . --output-format=github"
lint-fix = "ruff check . --fix --output-format=github"
hooks = "pre-commit install"
docstrings = "pydocstyle src"
all = "mypy src tests && black src tests && ruff check --fix ."

[tool.mypy]
Expand Down
2 changes: 0 additions & 2 deletions tests/example_components/test_keyword_booster.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
from haystack import Document
from dc_custom_component.example_components.rankers.keyword_booster import (
KeywordBooster,
Expand Down Expand Up @@ -86,7 +85,6 @@ def test_serialization(self) -> None:
assert deserialized.magic_word == Secret.from_env_var("MY_ENV_VAR")

def test_serialization_from_dict(self) -> None:

deserialized: SecretKeywordBooster = SecretKeywordBooster.from_dict(
{
"type": "dc_custom_component.example_components.rankers.keyword_booster.SecretKeywordBooster",
Expand Down
Loading