diff --git a/.github/workflows/ci-test.yaml b/.github/workflows/ci-test.yaml new file mode 100644 index 0000000..e405b36 --- /dev/null +++ b/.github/workflows/ci-test.yaml @@ -0,0 +1,55 @@ +name: CI Test + +on: + pull_request: + types: + - opened + - synchronize + +jobs: + test-rust-core: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Run tests + run: make test + + test-python-binding: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install uv + run: pip install uv + + - name: Install dependencies + working-directory: bindings/python + run: source start.sh + + - name: Run tests + working-directory: bindings/python + run: make test + + - name: Install docker-compose + run: | + sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + docker-compose --version + + - name: Run integration tests + working-directory: bindings/python + run: | + make test-integration diff --git a/.gitignore b/.gitignore index 0bd1d11..fcfc13f 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ dist/ # Added by cargo /target +.ruff_cache/ +.venv/ diff --git a/Makefile b/Makefile index c9633f7..8a8c246 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,9 @@ -POETRY := poetry -RUFF := .venv/bin/ruff -PYTEST := .venv/bin/pytest - -.PHONY: build -build: lint - $(POETRY) build - -.PHONY: publish -publish: build - $(POETRY) publish --username=__token__ --password=$(INFTYAI_PYPI_TOKEN) - -.PHONY: lint -lint: - $(RUFF) check . +CARGO := cargo .PHONY: format format: - $(RUFF) format . - $(RUFF) check --fix . + $(CARGO) fmt .PHONY: test -test: lint - $(PYTEST) tests/unit --timeout=15 - -.PHONY: test-integration -test-integration: lint - $(PYTEST) tests/integration --timeout=30 - ' -.PHONY: test-all -test-all: test test-integration +test: format + $(CARGO) test diff --git a/bindings/python/Makefile b/bindings/python/Makefile new file mode 100644 index 0000000..9db814d --- /dev/null +++ b/bindings/python/Makefile @@ -0,0 +1,31 @@ +POETRY := poetry +RUFF := .venv/bin/ruff +PYTEST := .venv/bin/pytest + +.PHONY: build +build: lint + $(POETRY) build + +.PHONY: publish +publish: build + $(POETRY) publish --username=__token__ --password=$(INFTYAI_PYPI_TOKEN) + +.PHONY: lint +lint: + $(RUFF) check . + +.PHONY: format +format: + $(RUFF) format . + $(RUFF) check --fix . + +.PHONY: test +test: lint + $(PYTEST) tests/unit --timeout=15 + +.PHONY: test-integration +test-integration: lint + $(PYTEST) tests/integration --timeout=30 + +.PHONY: test-all +test-all: test test-integration diff --git a/bindings/python/README.md b/bindings/python/README.md new file mode 100644 index 0000000..34f4514 --- /dev/null +++ b/bindings/python/README.md @@ -0,0 +1 @@ +# Python Binding for AMRS diff --git a/amrs/__init__.py b/bindings/python/amrs/__init__.py similarity index 100% rename from amrs/__init__.py rename to bindings/python/amrs/__init__.py diff --git a/amrs/config.py b/bindings/python/amrs/config.py similarity index 100% rename from amrs/config.py rename to bindings/python/amrs/config.py diff --git a/amrs/router/__init__.py b/bindings/python/amrs/router/__init__.py similarity index 100% rename from amrs/router/__init__.py rename to bindings/python/amrs/router/__init__.py diff --git a/amrs/router/random.py b/bindings/python/amrs/router/random.py similarity index 100% rename from amrs/router/random.py rename to bindings/python/amrs/router/random.py diff --git a/amrs/router/router.py b/bindings/python/amrs/router/router.py similarity index 100% rename from amrs/router/router.py rename to bindings/python/amrs/router/router.py diff --git a/amrs/store/__init__.py b/bindings/python/amrs/store/__init__.py similarity index 100% rename from amrs/store/__init__.py rename to bindings/python/amrs/store/__init__.py diff --git a/amrs/store/store.py b/bindings/python/amrs/store/store.py similarity index 100% rename from amrs/store/store.py rename to bindings/python/amrs/store/store.py diff --git a/pyproject.toml b/bindings/python/pyproject.toml similarity index 100% rename from pyproject.toml rename to bindings/python/pyproject.toml diff --git a/start.sh b/bindings/python/start.sh similarity index 100% rename from start.sh rename to bindings/python/start.sh diff --git a/tests/__init__.py b/bindings/python/tests/__init__.py similarity index 100% rename from tests/__init__.py rename to bindings/python/tests/__init__.py diff --git a/tests/integration_tests/__init__.py b/bindings/python/tests/integration/__init__.py similarity index 100% rename from tests/integration_tests/__init__.py rename to bindings/python/tests/integration/__init__.py diff --git a/bindings/python/tests/integration/config_test.py b/bindings/python/tests/integration/config_test.py new file mode 100644 index 0000000..0885f81 --- /dev/null +++ b/bindings/python/tests/integration/config_test.py @@ -0,0 +1,3 @@ + +def test_fake(): + print("This is a fake test to ensure the test suite runs.") diff --git a/tests/unit/__init__.py b/bindings/python/tests/unit/__init__.py similarity index 100% rename from tests/unit/__init__.py rename to bindings/python/tests/unit/__init__.py diff --git a/tests/unit/config_test.py b/bindings/python/tests/unit/config_test.py similarity index 100% rename from tests/unit/config_test.py rename to bindings/python/tests/unit/config_test.py diff --git a/bindings/python/tests/unit/conftest.py b/bindings/python/tests/unit/conftest.py new file mode 100644 index 0000000..3f02a29 --- /dev/null +++ b/bindings/python/tests/unit/conftest.py @@ -0,0 +1,3 @@ +from dotenv import load_dotenv + +load_dotenv(dotenv_path="../../.env.test") diff --git a/uv.lock b/bindings/python/uv.lock similarity index 100% rename from uv.lock rename to bindings/python/uv.lock diff --git a/src/client/client.rs b/src/client/client.rs index a7b9123..36a72b3 100644 --- a/src/client/client.rs +++ b/src/client/client.rs @@ -40,9 +40,12 @@ impl Client { mod tests { use super::*; use crate::config::{Config, ModelConfig, RoutingMode}; + use dotenvy::from_filename; #[test] fn test_client_new() { + from_filename(".env.test").ok(); + struct TestCase { name: &'static str, config: Config, diff --git a/src/config.rs b/src/config.rs index 521e3e4..876144d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -289,6 +289,8 @@ mod tests { #[test] fn test_populate_config() { + from_filename(".env.test").ok(); + let mut valid_cfg = Config::builder() .temperature(0.5) .max_output_tokens(1500) @@ -313,7 +315,7 @@ mod tests { assert!(valid_cfg.as_ref().unwrap().models[0].weight == -1); let mut valid_specified_cfg = Config::builder() - .provider("DEEPINFRA".to_string()) + .provider("AMRS".to_string()) .base_url("http://custom-api.ai".to_string()) .model( ModelConfig::builder() @@ -325,7 +327,7 @@ mod tests { valid_specified_cfg.as_mut().unwrap().populate(); assert!(valid_specified_cfg.is_ok()); - assert!(valid_specified_cfg.as_ref().unwrap().provider == "DEEPINFRA".to_string()); + assert!(valid_specified_cfg.as_ref().unwrap().provider == "AMRS".to_string()); assert!( valid_specified_cfg.as_ref().unwrap().models[0].base_url == Some("http://custom-api.ai".to_string()) diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py deleted file mode 100644 index eae9640..0000000 --- a/tests/unit/conftest.py +++ /dev/null @@ -1,3 +0,0 @@ -from dotenv import load_dotenv - -load_dotenv(dotenv_path=".env.test")