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

ci: Initial github actions #15

Merged
merged 33 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
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
21 changes: 21 additions & 0 deletions .github/actions/setup-python-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Setup Python Environment"
description: "Set up Python environment for the given Python version"

inputs:
python-version:
description: "Python version to use"
required: true
default: "3.12"

runs:
using: "composite"
steps:
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: "true"
cache-suffix: ${{ matrix.python-version }}

- name: Install Python dependencies
run: uv sync --frozen
shell: bash
89 changes: 89 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Main

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

concurrency:
# Cancel CI runs on a branch (other than main) on updates.defaults:
# This limits redundant runs, but also ensures we get signal on every
# merge to main.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ !contains(github.ref, 'main')}}

jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4

# TODO: Caching

- name: Set up the environment
uses: ./.github/actions/setup-python-env
id: setup

- name: Run `make fmt-check`
run: make fmt-check
# Runs this as long as setup succeeds.
if: ${{ !cancelled() && steps.setup.conclusion == 'success' }}

- name: Run `make check`
run: make check
# Runs this as long as setup succeeds.
if: ${{ !cancelled() && steps.setup.conclusion == 'success' }}

- name: Run `make check-lock`
run: make check-lock
# Runs this as long as setup succeeds.
if: ${{ !cancelled() && steps.setup.conclusion == 'success' }}

- name: Run `make deptry`
run: make deptry
# Runs this as long as setup succeeds.
if: ${{ !cancelled() && steps.setup.conclusion == 'success' }}

tests-and-type-check:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false
defaults:
run:
shell: bash
steps:
- name: Check out
uses: actions/checkout@v4

- name: Set up the environment
uses: ./.github/actions/setup-python-env
id: setup
with:
python-version: ${{ matrix.python-version }}

- name: Run `make test`
run: make testci

- name: Run `make mypy`
run: make mypy

- name: Upload coverage reports to Codecov with GitHub Action on Python 3.11
uses: codecov/codecov-action@v4
if: ${{ matrix.python-version == '3.11' }}

# check-docs:
# runs-on: ubuntu-latest
# steps:
# - name: Check out
# uses: actions/checkout@v4

# - name: Set up the environment
# uses: ./.github/actions/setup-python-env

# - name: Check if documentation can be built
# run: uv run mkdocs build -s
15 changes: 15 additions & 0 deletions .github/workflows/validate-codecov-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: validate-codecov-config

on:
pull_request:
paths: [codecov.yaml]
push:
branches: [main]

jobs:
validate-codecov-config:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Validate codecov configuration
run: curl -sSL --fail-with-body --data-binary @codecov.yaml https://codecov.io/validate
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,23 @@ docker-down:

.PHONY: integration
integration:
uv run pytest -v ./tests/integration_tests/
@echo "🚀 Testing code: Running pytest ./tests/inegration_tests (in memory only)"
@uv run pytest -vs ./tests/integration_tests/

.PHONY: unit
unit:
uv run pytest -vs ./tests/unit_tests/
@echo "🚀 Testing code: Running pytest ./tests/unit_tests"
@uv run pytest -vs ./tests/unit_tests/

.PHONY: test
test:
@echo "🚀 Testing code: Running pytest"
@uv run python -m pytest ./tests/unit_tests ./tests/integration_tests/ --cov --cov-config=pyproject.toml --cov-report=xml --stores=all
@uv run python -m pytest -vs ./tests/unit_tests ./tests/integration_tests/ --cov --cov-config=pyproject.toml --cov-report=xml --stores=all

.PHONY: test
testci:
@echo "🚀 Testing code: Running pytest"
@uv run python -m pytest -vs ./tests/unit_tests ./tests/integration_tests/ --cov --cov-config=pyproject.toml --cov-report=xml --stores=mem --stores=mem_denorm --stores=cassandra --stores=chroma --stores=opensearch

.PHONY: mypy
mypy:
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ simsimd = [
beautifulsoup4 = "bs4"
opensearch-py = "opensearchpy"

[tool.deptry.per_rule_ignores]
DEP002 = ["cassio"]

[tool.pytest.ini_options]
asyncio_mode = "auto"
pythonpath = ["."]
Expand Down Expand Up @@ -73,6 +76,7 @@ dev = [
"pytest-cov>=4.0.0",
"pytest-asyncio>=0.25.2",
"simsimd>=6.2.1",
"testcontainers>=4.9.0",
]

[tool.coverage.report]
Expand Down
11 changes: 9 additions & 2 deletions tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from pytest import Parser

from tests.integration_tests.stores import ALL_STORES
from tests.integration_tests.stores import ALL_STORES, TESTCONTAINER_STORES


@pytest.fixture(scope="session")
Expand All @@ -22,7 +22,14 @@ def pytest_addoption(parser: Parser):
action="append",
metavar="STORE",
choices=ALL_STORES + ["all"],
help="run tests for the given store",
help="run tests for the given store (default: 'mem' and 'mem_denorm')",
)
parser.addoption(
"--testcontainer",
action="append",
metavar="STORE",
choices=TESTCONTAINER_STORES + ["none"],
help="which stores to run testcontainers for (default: 'all')",
)


Expand Down
27 changes: 0 additions & 27 deletions tests/integration_tests/retrievers/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import pytest
from langchain_core.documents import Document

from tests.integration_tests.invoker import invoker
from tests.integration_tests.retrievers.animal_docs import animal_docs, animal_store
from tests.integration_tests.retrievers.parser_docs import (
Expand Down Expand Up @@ -29,27 +26,3 @@
parser_store,
invoker,
)


@pytest.fixture(scope="module")
def hello_docs() -> list[Document]:
greetings = Document(
id="greetings",
page_content="Typical Greetings",
metadata={
"incoming": "parent",
},
)

doc1 = Document(
id="doc1",
page_content="Hello World",
metadata={"outgoing": "parent", "keywords": ["greeting", "world"]},
)

doc2 = Document(
id="doc2",
page_content="Hello Earth",
metadata={"outgoing": "parent", "keywords": ["greeting", "earth"]},
)
return [greetings, doc1, doc2]
Loading
Loading