Tests #4895
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| on: | |
| push: | |
| branches: [ main, master, develop ] | |
| pull_request: | |
| branches: [ main, master, develop ] | |
| schedule: | |
| # Run nightly at 2 AM UTC | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: # Allow manual triggering | |
| jobs: | |
| test: | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 30 # Set overall job timeout | |
| strategy: | |
| fail-fast: false # Don't cancel other jobs if one fails | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
| exclude: | |
| # Skip some combinations to reduce CI time | |
| - os: macos-latest | |
| python-version: "3.9" | |
| - os: windows-latest | |
| python-version: "3.9" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 # Shallow clone for faster checkout | |
| timeout-minutes: 10 # Increased from 2 to handle network delays | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| timeout-minutes: 3 | |
| - name: Install uv | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
| timeout-minutes: 5 | |
| - name: Cache uv dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cache/uv | |
| .venv | |
| key: ${{ runner.os }}-uv-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-uv-${{ matrix.python-version }}- | |
| ${{ runner.os }}-uv- | |
| timeout-minutes: 2 | |
| - name: Install system dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc g++ build-essential | |
| timeout-minutes: 5 | |
| - name: Install system dependencies (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| # macOS already has Xcode command line tools | |
| echo "Using system compiler tools" | |
| timeout-minutes: 1 | |
| - name: Install system dependencies (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| # Windows doesn't need special setup for pip packages | |
| echo "Using Visual Studio build tools" | |
| timeout-minutes: 1 | |
| - name: Setup development environment | |
| run: | | |
| echo " Setting up development environment with uv..." | |
| uv venv --clear .venv | |
| if [ "$RUNNER_OS" == "Windows" ]; then | |
| source .venv/Scripts/activate | |
| else | |
| source .venv/bin/activate | |
| fi | |
| uv pip install -e . | |
| timeout-minutes: 15 | |
| shell: bash | |
| - name: Run tests via uv | |
| env: | |
| MPLBACKEND: Agg # Avoid GUI issues in matplotlib | |
| HYPOTHESIS_PROFILE: ci # Use CI profile for Hypothesis | |
| run: | | |
| echo " Running tests..." | |
| if [ "$RUNNER_OS" == "Windows" ]; then | |
| source .venv/Scripts/activate | |
| else | |
| source .venv/bin/activate | |
| fi | |
| uv pip install pytest hypothesis pyarrow | |
| if [ -f "run_tests.py" ]; then | |
| timeout 600 uv run python run_tests.py || echo " Tests timed out after 10 minutes" | |
| else | |
| uv run pytest tests/ || echo " Tests failed" | |
| fi | |
| timeout-minutes: 30 | |
| shell: bash | |
| - name: Run metamorphic tests | |
| env: | |
| MPLBACKEND: Agg | |
| HYPOTHESIS_PROFILE: ci | |
| run: | | |
| echo " Running metamorphic tests..." | |
| if [ "$RUNNER_OS" == "Windows" ]; then | |
| source .venv/Scripts/activate | |
| else | |
| source .venv/bin/activate | |
| fi | |
| uv run pytest -q -k metamorphic tests/ || echo " Metamorphic tests failed" | |
| timeout-minutes: 5 | |
| shell: bash | |
| - name: Upload test results | |
| if: always() | |
| run: | | |
| echo "Test execution completed" | |
| echo "Check the logs above for detailed test results" | |
| timeout-minutes: 1 | |
| test-minimal: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 # Shorter timeout for minimal test | |
| name: "Test with minimal dependencies (Python 3.9)" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 # Shallow clone for faster checkout | |
| timeout-minutes: 10 # Increased from 2 to handle network delays | |
| - name: Set up Python 3.9 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.9" | |
| timeout-minutes: 3 | |
| - name: Install uv | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
| timeout-minutes: 5 | |
| - name: Install minimal dependencies | |
| run: | | |
| uv venv --clear .venv | |
| source .venv/bin/activate | |
| uv pip install setuptools wheel | |
| # Only install absolutely required dependencies | |
| uv pip install numpy scipy tqdm bitarray rdflib | |
| # Try to install networkx with version flexibility | |
| uv pip install "networkx>=2.5" || uv pip install networkx | |
| timeout-minutes: 10 | |
| - name: Run tests (minimal) | |
| run: | | |
| echo " Python version: $(python --version)" | |
| echo " Installed packages:" | |
| source .venv/bin/activate | |
| uv pip list | head -20 | |
| echo " Running tests with minimal dependencies..." | |
| timeout 400 uv run python run_tests.py || echo " Minimal tests timed out after 6.7 minutes" | |
| echo " Minimal dependency tests completed" | |
| echo "Note: Some tests may be skipped due to missing optional dependencies" | |
| timeout-minutes: 8 | |
| # Nightly job for thorough metamorphic testing | |
| metamorphic-nightly: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| name: "Nightly Metamorphic Tests" | |
| # Run only on schedule or manual trigger | |
| if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 # Shallow clone for faster checkout | |
| timeout-minutes: 10 # Increased from 2 to handle network delays | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.10" | |
| timeout-minutes: 3 | |
| - name: Install uv | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
| timeout-minutes: 5 | |
| - name: Install dependencies | |
| run: | | |
| uv venv --clear .venv | |
| source .venv/bin/activate | |
| uv pip install -e .[tests] | |
| timeout-minutes: 10 | |
| - name: Run extended metamorphic tests | |
| env: | |
| MPLBACKEND: Agg | |
| HYPOTHESIS_PROFILE: nightly | |
| HYPOTHESIS_MAX_EXAMPLES: 600 | |
| run: | | |
| echo " Running extended metamorphic tests..." | |
| echo "Configuration:" | |
| echo " - HYPOTHESIS_PROFILE: nightly" | |
| echo " - HYPOTHESIS_MAX_EXAMPLES: 600" | |
| source .venv/bin/activate | |
| uv run pytest -v -k metamorphic tests/test_metamorphic.py --tb=short | |
| timeout-minutes: 50 | |
| optional-features: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| name: "Optional features smoke (Python 3.11)" | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11" | |
| - name: Install uv | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
| - name: Install optional feature bundle | |
| run: | | |
| uv venv --clear .venv | |
| source .venv/bin/activate | |
| uv pip install -e ".[optional]" | |
| uv pip install pytest | |
| - name: Run selftest and optional capability checks | |
| env: | |
| MPLBACKEND: Agg | |
| run: | | |
| source .venv/bin/activate | |
| uv run python -m py3plex.cli selftest | |
| uv run pytest tests/test_cli.py -k selftest -q | |
| uv run pytest tests/test_capabilities_optional_missing.py -q | |
| coverage: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 35 | |
| name: "Coverage (Python 3.11)" | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11" | |
| - name: Install uv | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
| - name: Install dependencies with test extras | |
| run: | | |
| uv venv --clear .venv | |
| uv pip install -e ".[tests,arrow]" | |
| - name: Run tests with coverage | |
| continue-on-error: true | |
| env: | |
| MPLBACKEND: Agg | |
| HYPOTHESIS_PROFILE: ci | |
| run: | | |
| # Coverage visibility job: keep artifact generation even when unrelated | |
| # broad-suite regressions exist in this branch. | |
| uv run pytest tests/ --cov=py3plex --cov-report=term --cov-report=xml:coverage.xml | |
| - name: Upload coverage xml artifact | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-xml | |
| path: coverage.xml | |
| if-no-files-found: warn |