diff --git a/.github/workflows/coverage-badge.yaml b/.github/workflows/coverage-badge.yml similarity index 91% rename from .github/workflows/coverage-badge.yaml rename to .github/workflows/coverage-badge.yml index 1462da567..6b2f133dd 100644 --- a/.github/workflows/coverage-badge.yaml +++ b/.github/workflows/coverage-badge.yml @@ -10,14 +10,12 @@ on: - 'pyproject.toml' - 'requirements.txt' - '.github/workflows/unit-tests.yml' - - '.github/workflows/codecov-badge.yaml' # This workflow + - '.github/workflows/coverage-badge.yml' # This workflow workflow_dispatch: jobs: unit-tests: runs-on: ubuntu-latest - env: - PYTHON_VERSION: "3.12" steps: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -27,7 +25,7 @@ jobs: - name: Run unit tests run: | - PYTHON_VERSION=${{ env.PYTHON_VERSION }} ./scripts/unit-tests.sh + ./scripts/unit-tests.sh - name: Coverage Badge uses: tj-actions/coverage-badge-py@1788babcb24544eb5bbb6e0d374df5d1e54e670f # v2.0.4 diff --git a/docs/source/contributing/testing.md b/docs/source/contributing/testing.md index 237d4eaa6..47bf9dea7 100644 --- a/docs/source/contributing/testing.md +++ b/docs/source/contributing/testing.md @@ -4,42 +4,3 @@ Tests are of three different kinds: - Unit tests - Provider focused integration tests - Client SDK tests - -## Unit Tests - -Unit tests verify individual components and functions in isolation. They are fast, reliable, and don't require external services. - -### Prerequisites - -1. **Python Environment**: Ensure you have Python 3.12+ installed -2. **uv Package Manager**: Install `uv` if not already installed -3. **Virtual Environment**: Activate the project's virtual environment - -### Running Unit Tests - -#### Using the Unit Test Script (Recommended) - -The easiest way to run unit tests is by using the provided script: - -```bash -# Run all unit tests and generate coverage report -PYTHON_VERSION=3.12 ./scripts/unit-tests.sh -``` - -### Test Configuration - -- **Test Discovery**: Tests are automatically discovered in the `tests/unit/` directory -- **Async Support**: Tests use `--asyncio-mode=auto` for automatic async test handling -- **Coverage**: Tests generate coverage reports in `htmlcov/` directory -- **Python Version**: Defaults to Python 3.12, but can be overridden with `PYTHON_VERSION` environment variable - -### Coverage Reports - -After running tests, you can view coverage reports: - -```bash -# Open HTML coverage report in browser -open htmlcov/index.html # macOS -xdg-open htmlcov/index.html # Linux -start htmlcov/index.html # Windows -``` diff --git a/tests/unit/README.md b/tests/unit/README.md index c95c3a0e7..06e22fb8c 100644 --- a/tests/unit/README.md +++ b/tests/unit/README.md @@ -1,9 +1,17 @@ # Llama Stack Unit Tests +## Unit Tests + +Unit tests verify individual components and functions in isolation. They are fast, reliable, and don't require external services. + +### Prerequisites + +1. **Python Environment**: Ensure you have Python 3.12+ installed +2. **uv Package Manager**: Install `uv` if not already installed + You can run the unit tests by running: ```bash -source .venv/bin/activate ./scripts/unit-tests.sh [PYTEST_ARGS] ``` @@ -19,3 +27,21 @@ If you'd like to run for a non-default version of Python (currently 3.12), pass source .venv/bin/activate PYTHON_VERSION=3.13 ./scripts/unit-tests.sh ``` + +### Test Configuration + +- **Test Discovery**: Tests are automatically discovered in the `tests/unit/` directory +- **Async Support**: Tests use `--asyncio-mode=auto` for automatic async test handling +- **Coverage**: Tests generate coverage reports in `htmlcov/` directory +- **Python Version**: Defaults to Python 3.12, but can be overridden with `PYTHON_VERSION` environment variable + +### Coverage Reports + +After running tests, you can view coverage reports: + +```bash +# Open HTML coverage report in browser +open htmlcov/index.html # macOS +xdg-open htmlcov/index.html # Linux +start htmlcov/index.html # Windows +```