# This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python name: Python tests permissions: contents: read on: push: branches: - "main" - "dev" - "dev*" - "feat/*" - "test" pull_request: branches: - "main" - "dev" - "dev*" - "feat/*" - "test" jobs: build: strategy: fail-fast: false matrix: os: - "ubuntu-latest" - "windows-latest" - "macos-14" - "macos-15" # Ref: https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-where-your-workflow-runs/choosing-the-runner-for-a-job python-version: - "3.10" - "3.11" - "3.12" - "3.13" runs-on: ${{ matrix.os }} timeout-minutes: 30 steps: - uses: actions/checkout@v4 - name: Install poetry # This is a temporary fix to ensure compatibility with Poetry & virtualenv # Revert to the original installation method once the poetry==2.1.4 is released run: | echo "virtualenv==20.32.0" > constraints.txt pipx install poetry==2.1.3 --pip-args="--constraint=constraints.txt" rm constraints.txt - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: 'poetry' # Dependency and building tests - name: Install main dependencies run: | poetry install --no-root --no-interaction - name: Check no top-level optional dependencies run: | poetry run python scripts/check_dependencies.py - name: Build sdist and wheel run: poetry build - name: Test wheel installation on Windows if: startsWith(matrix.os, 'windows') run: | Get-ChildItem dist/*.whl | ForEach-Object { pip install $_.FullName } pip uninstall -y memoryos - name: Test wheel installation on Linux / Mac if: ${{ !startsWith(matrix.os, 'windows') }} run: | pip install dist/*.whl pip uninstall -y memoryos - name: Test sdist installation on Windows if: startsWith(matrix.os, 'windows') run: | Get-ChildItem dist/*.tar.gz | ForEach-Object { pip install $_.FullName } pip uninstall -y memoryos - name: Test sdist installation on Linux / Mac if: ${{ !startsWith(matrix.os, 'windows') }} run: | pip install dist/*.tar.gz pip uninstall -y memoryos # Ruff checks - name: Install test group dependencies run: | poetry install --no-interaction --with test - name: Ruff checks run: | poetry run ruff check poetry run ruff format --check # PyTest checks - name: Install all extra dependencies # macos-13 doesn't support torch==2.7.1 # So, pytest won't work if: ${{ !startsWith(matrix.os, 'macos-13') }} run: | poetry install --no-interaction --extras all - name: PyTest unit tests with coverage if: ${{ !startsWith(matrix.os, 'macos-13') }} shell: bash run: | poetry run pytest tests -vv --durations=10 \ --cov=src/memos \ --cov-report=term-missing \ --cov-fail-under=28