Skip to content
name: Python Unit Tests
on:
pull_request:
branches: ["main", "feature*"]
paths:
- "python/**"
<<<<<<< HEAD

Check failure on line 8 in .github/workflows/python-unit-tests.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/python-unit-tests.yml

Invalid workflow file

You have an error in your yaml syntax on line 8
=======
env:
# Configure a constant location for the uv cache
UV_CACHE_DIR: /tmp/.uv-cache
>>>>>>> 21507472dbfb2f82c4cee14827624e2d14dc0b39
jobs:
python-unit-tests:
name: Python Unit Tests
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: true
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: [ubuntu-latest, windows-latest, macos-latest]
experimental: [false]
include:
- python-version: "3.13.0-beta.4"
os: "ubuntu-latest"
experimental: true
permissions:
contents: write
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@v4
<<<<<<< HEAD
- name: Install poetry
run: pipx install poetry
=======
- name: Set up uv
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Set up uv
if: ${{ matrix.os == 'windows-latest' }}
run: irm https://astral.sh/uv/install.ps1 | iex
shell: powershell
>>>>>>> 21507472dbfb2f82c4cee14827624e2d14dc0b39
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
<<<<<<< HEAD
cache: "poetry"
- name: Install dependencies
run: poetry install --with unit-tests
- name: Test with pytest
run: poetry run pytest --junitxml=pytest.xml ./tests/unit
=======
- name: Restore uv cache
id: cache
uses: actions/cache@v4
with:
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/uv.lock') }}
- name: Install the project
run: uv sync --all-extras --dev
- name: Test with pytest
run: uv run pytest --junitxml=pytest.xml ./tests/unit
>>>>>>> 21507472dbfb2f82c4cee14827624e2d14dc0b39
- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@main
with:
<<<<<<< HEAD
# A list of JUnit XML files, directories containing the former, and wildcard
# patterns to process.
# See @actions/glob for supported patterns.
path: python/pytest.xml
# (Optional) Add a summary of the results at the top of the report
summary: true
# (Optional) Select which results should be included in the report.
# Follows the same syntax as `pytest -r`
display-options: fEX
# (Optional) Fail the workflow if no JUnit XML was found.
fail-on-empty: true
# (Optional) Title of the test results section in the workflow summary
title: Test results
=======
path: python/pytest.xml
summary: true
display-options: fEX
fail-on-empty: true
title: Test results
- name: Minimize uv cache
run: uv cache prune --ci
>>>>>>> 21507472dbfb2f82c4cee14827624e2d14dc0b39
python-test-coverage:
name: Python Test Coverage
runs-on: [ubuntu-latest]
continue-on-error: true
permissions:
contents: write
defaults:
run:
working-directory: python
<<<<<<< HEAD
=======
env:
PYTHON_VERSION: "3.10"
>>>>>>> 21507472dbfb2f82c4cee14827624e2d14dc0b39
steps:
- uses: actions/checkout@v4
- name: Setup filename variables
run: echo "FILE_ID=${{ github.event.number }}" >> $GITHUB_ENV
<<<<<<< HEAD
- name: Install poetry
run: pipx install poetry
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "poetry"
- name: Install dependencies
run: poetry install --with unit-tests
- name: Test with pytest
run: poetry run pytest -q --junitxml=pytest.xml --cov=semantic_kernel --cov-report=term-missing:skip-covered ./tests/unit | tee python-coverage.txt
=======
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Restore uv cache
uses: actions/cache@v4
with:
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/uv.lock') }}
- name: Install the project
run: uv sync --all-extras --dev
- name: Test with pytest
run: uv run pytest -q --junitxml=pytest.xml --cov=semantic_kernel --cov-report=term-missing:skip-covered ./tests/unit | tee python-coverage.txt
>>>>>>> 21507472dbfb2f82c4cee14827624e2d14dc0b39
- name: Upload coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: python-coverage-${{ env.FILE_ID }}.txt
path: python/python-coverage.txt
overwrite: true
retention-days: 1
- name: Upload pytest.xml
if: always()
uses: actions/upload-artifact@v4
with:
name: pytest-${{ env.FILE_ID }}.xml
path: python/pytest.xml
overwrite: true
retention-days: 1
<<<<<<< HEAD
=======
- name: Minimize uv cache
run: uv cache prune --ci
>>>>>>> 21507472dbfb2f82c4cee14827624e2d14dc0b39