From 0f0623d31cea1c06f56ac4f1f0bfdd60f106261b Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 02:27:27 +0000 Subject: [PATCH] Address PR review feedback and fix CI failures Co-Authored-By: Joe Moura --- .github/workflows/tests.yml | 1 + Dockerfile.test | 14 +++++++++++--- tests/test_python_compatibility.py | 27 ++++++++++++++++++++++++--- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b99cccdfe..006215ec9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,6 +13,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 strategy: + fail-fast: true # Stop testing on subsequent Python versions if an earlier one fails matrix: python-version: ['3.10', '3.11', '3.12', '3.13'] steps: diff --git a/Dockerfile.test b/Dockerfile.test index 3ad284fa3..cec6d1843 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -2,13 +2,21 @@ FROM python:3.13-slim-bookworm WORKDIR /app -RUN pip install --upgrade pip +# Health check +HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD python -c "import crewai" || exit 1 + +# Improved installation process +RUN pip install --upgrade pip && pip install --no-cache-dir -U pip setuptools wheel && rm -rf /root/.cache/pip/* \ + || { echo 'Installation failed'; exit 1; } # Copy the current directory contents into the container COPY . /app/ -# Install the package -RUN pip install -e . +# Install the package with error handling +RUN pip install -e . || { echo 'Package installation failed'; exit 1; } + +# Version confirmation +RUN python -c "import crewai; assert crewai.__version__, 'Version check failed'" # Test importing the package CMD ["python", "-c", "import crewai; print(f'Successfully imported crewai version {crewai.__version__}')"] diff --git a/tests/test_python_compatibility.py b/tests/test_python_compatibility.py index dd5df19f7..60b9a5165 100644 --- a/tests/test_python_compatibility.py +++ b/tests/test_python_compatibility.py @@ -1,10 +1,31 @@ """Tests for Python version compatibility.""" -import pytest import sys +import pytest +from packaging import version + + +def validate_python_version(): + """Validate that the current Python version is supported.""" + min_version = (3, 10) + max_version = (3, 14) + current = sys.version_info[:2] + + if not (min_version <= current < max_version): + raise RuntimeError( + f"This package requires Python {min_version[0]}.{min_version[1]} to " + f"{max_version[0]}.{max_version[1]-1}. You have Python {current[0]}.{current[1]}" + ) + def test_python_version_compatibility(): """Test that the package supports the current Python version.""" + assert isinstance(sys.version_info, tuple), "Version Information must be a tuple" + + current_version = version.parse(f"{sys.version_info.major}.{sys.version_info.minor}") + assert current_version >= version.parse("3.10"), "Python version too old" + assert current_version < version.parse("3.14"), "Python version too new" + # This test will fail if the package doesn't support the current Python version import crewai @@ -14,5 +35,5 @@ def test_python_version_compatibility(): # Print the crewai version for debugging print(f"CrewAI version: {crewai.__version__}") - # If we got here, the import worked, which means the package supports this Python version - assert True + # Validate Python version + validate_python_version()