Introduces a full test suite under the tests/ directory, including API, service, connector, and utility tests, along with fixtures and documentation. Expands Makefile with granular test commands for unit, integration, API, service, connector, coverage, and quick tests. Adds configuration files for pytest and coverage reporting, and provides a quickstart guide for testing workflow.
140 lines
3.5 KiB
YAML
140 lines
3.5 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test:
|
|
name: Run Tests
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
python-version: ["3.13"]
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v4
|
|
with:
|
|
enable-cache: true
|
|
cache-dependency-glob: "uv.lock"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
uv sync --extra dev
|
|
|
|
- name: Run unit tests
|
|
run: |
|
|
uv run pytest tests/ -v -m "not requires_opensearch and not requires_langflow" --cov=src --cov-report=xml --cov-report=term-missing --cov-fail-under=1
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v4
|
|
if: always()
|
|
with:
|
|
file: ./coverage.xml
|
|
flags: unittests
|
|
name: codecov-umbrella
|
|
fail_ci_if_error: false
|
|
|
|
integration-test:
|
|
name: Integration Tests
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
opensearch:
|
|
image: opensearchproject/opensearch:2.11.0
|
|
env:
|
|
discovery.type: single-node
|
|
OPENSEARCH_INITIAL_ADMIN_PASSWORD: Admin@123
|
|
DISABLE_SECURITY_PLUGIN: true
|
|
options: >-
|
|
--health-cmd "curl -f http://localhost:9200/_cluster/health || exit 1"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
ports:
|
|
- 9200:9200
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.13
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.13"
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v4
|
|
with:
|
|
enable-cache: true
|
|
cache-dependency-glob: "uv.lock"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
uv sync --extra dev
|
|
|
|
- name: Wait for OpenSearch
|
|
run: |
|
|
timeout 60 bash -c 'until curl -s http://localhost:9200/_cluster/health | grep -q "\"status\":\"green\"\\|\"status\":\"yellow\""; do sleep 2; done'
|
|
|
|
- name: Run integration tests
|
|
env:
|
|
OPENSEARCH_HOST: localhost
|
|
OPENSEARCH_PORT: 9200
|
|
OPENSEARCH_USER: admin
|
|
OPENSEARCH_PASSWORD: Admin@123
|
|
run: |
|
|
uv run pytest tests/ -v -m "integration and requires_opensearch" --cov=src --cov-report=xml --cov-report=term-missing || true
|
|
|
|
lint:
|
|
name: Linting
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.13
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.13"
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v4
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
uv sync --extra dev
|
|
|
|
- name: Check Python formatting with ruff (if available)
|
|
run: |
|
|
uv pip install ruff || true
|
|
uv run ruff check src/ tests/ --exit-zero || true
|
|
continue-on-error: true
|
|
|
|
test-summary:
|
|
name: Test Summary
|
|
runs-on: ubuntu-latest
|
|
needs: [test, integration-test]
|
|
if: always()
|
|
|
|
steps:
|
|
- name: Check test results
|
|
run: |
|
|
if [ "${{ needs.test.result }}" != "success" ]; then
|
|
echo "❌ Unit tests failed"
|
|
exit 1
|
|
fi
|
|
echo "✅ All required tests passed"
|