From 30912c69c68de6bb28944d21efc5ddffffba13c8 Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Sat, 19 Jul 2025 15:21:34 -0400 Subject: [PATCH] Run integration tests as separate CI job on Ubuntu only - Add pytest marker for integration tests - Configure automatic marking for tests/integration_tests/ folder via pytest hook - Split CI workflow into two jobs: regular tests (all platforms) and integration tests (Ubuntu only) - Integration tests can now be retried independently if they fail --- .github/workflows/run-tests.yml | 25 +++++++++++++++++++++++-- pyproject.toml | 9 +++++++++ tests/conftest.py | 9 +++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index bb9c7fb36..c9d212b4f 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -46,7 +46,28 @@ jobs: - name: Install FastMCP run: uv sync --locked - - name: Run tests - run: uv run pytest tests + - name: Run tests (excluding integration) + run: uv run pytest tests -m "not integration" + + run_integration_tests: + name: "Run integration tests" + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v6 + with: + enable-cache: true + cache-dependency-glob: "uv.lock" + python-version: "3.10" + + - name: Install FastMCP + run: uv sync --locked + + - name: Run integration tests + run: uv run pytest tests -m "integration" env: FASTMCP_GITHUB_TOKEN: ${{ secrets.FASTMCP_GITHUB_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml index 3e3dea61c..94fde3974 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -101,6 +101,15 @@ env = [ 'D:FASTMCP_LOG_LEVEL=DEBUG', 'D:FASTMCP_ENABLE_RICH_TRACEBACKS=0', ] +markers = [ + "integration: marks tests as integration tests (deselect with '-m \"not integration\"')", +] +# Automatically mark all tests in integration_tests folder +pythonpath = ["."] +testpaths = ["tests"] +python_files = ["test_*.py", "*_test.py"] +python_classes = ["Test*"] +python_functions = ["test_*"] [tool.pyright] include = ["src", "tests"] diff --git a/tests/conftest.py b/tests/conftest.py index e69de29bb..4fba247c6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -0,0 +1,9 @@ +import pytest + + +def pytest_collection_modifyitems(items): + """Automatically mark tests in integration_tests folder with 'integration' marker.""" + for item in items: + # Check if the test is in the integration_tests folder + if "integration_tests" in str(item.fspath): + item.add_marker(pytest.mark.integration)