Skip to content

Merge pull request #137 from harumiWeb/dependabot/uv/starlette-1.0.1 #313

Merge pull request #137 from harumiWeb/dependabot/uv/starlette-1.0.1

Merge pull request #137 from harumiWeb/dependabot/uv/starlette-1.0.1 #313

Workflow file for this run

name: pytest
permissions:
contents: read
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
test:
runs-on: ${{ matrix.os }}
env:
PYTHONIOENCODING: "utf-8"
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[yaml,mcp]
pip install pytest pytest-cov pytest-mock
- name: Run tests (non-COM suite)
if: runner.os != 'Windows'
run: |
pytest -m "not com and not render" --maxfail=1 --disable-warnings -q --cov=exstruct --cov-report=xml --cov-fail-under=80
- name: Run tests (full suite with skips)
if: runner.os == 'Windows'
env:
SKIP_COM_TESTS: "1"
RUN_RENDER_SMOKE: "0" # enable with 1 when Excel+pypdfium2 are available
run: |
pytest -m "not com and not render" --maxfail=1 --disable-warnings -q --cov=exstruct --cov-report=xml --cov-fail-under=80
- name: Upload coverage to Codecov
if: runner.os == 'Linux' && matrix.python-version == '3.12'
uses: codecov/codecov-action@125fc84a9a348dbcf27191600683ec096ec9021c # v4.x.x
with:
files: coverage.xml
flags: unit
fail_ci_if_error: true
libreoffice-linux-smoke:
runs-on: ubuntu-24.04
timeout-minutes: 20
env:
PYTHONIOENCODING: "utf-8"
DEBIAN_FRONTEND: noninteractive
RUN_LIBREOFFICE_SMOKE: "1"
FORCE_LIBREOFFICE_SMOKE: "1"
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[yaml,mcp]
pip install pytest pytest-cov pytest-mock
- name: Install LibreOffice runtime
run: |
sudo apt-get update
sudo apt-get install -y libreoffice python3-uno
- name: Run LibreOffice smoke tests
run: |
pytest tests/core/test_libreoffice_smoke.py -m libreoffice --maxfail=1 --disable-warnings -q
libreoffice-windows-smoke:
runs-on: windows-2025
timeout-minutes: 25
env:
PYTHONIOENCODING: "utf-8"
RUN_LIBREOFFICE_SMOKE: "1"
FORCE_LIBREOFFICE_SMOKE: "1"
EXSTRUCT_LIBREOFFICE_PATH: 'C:\Program Files\LibreOffice\program\soffice.com'
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[yaml,mcp]
pip install pytest pytest-cov pytest-mock
- name: Install LibreOffice runtime
shell: powershell
run: |
choco install libreoffice-fresh -y --no-progress
- name: Discover LibreOffice runtime paths
shell: powershell
run: |
$programDir = Split-Path -Parent $env:EXSTRUCT_LIBREOFFICE_PATH
$consoleSoffice = Join-Path $programDir 'soffice.com'
$windowedSoffice = Join-Path $programDir 'soffice.exe'
if (Test-Path $consoleSoffice) {
$selectedSoffice = $consoleSoffice
} elseif (Test-Path $windowedSoffice) {
$selectedSoffice = $windowedSoffice
} else {
Write-Host "LibreOffice program directory contents:"
Get-ChildItem -Path $programDir -ErrorAction SilentlyContinue | Select-Object Name, FullName
throw "Could not find soffice.com or soffice.exe under $programDir"
}
"EXSTRUCT_LIBREOFFICE_PATH=$selectedSoffice" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Host "Selected LibreOffice executable: $selectedSoffice"
$patterns = @(
'python.exe',
'python.bin',
'python',
'python-core-*\python.exe',
'python-core-*\python',
'python-core-*\bin\python.exe',
'python-core-*\bin\python'
)
foreach ($pattern in $patterns) {
$searchPath = "$programDir\$pattern"
$candidate = Get-ChildItem -Path $searchPath -File -ErrorAction SilentlyContinue | Select-Object -First 1
if ($null -ne $candidate) {
"EXSTRUCT_LIBREOFFICE_PYTHON_PATH=$($candidate.FullName)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Host "Discovered LibreOffice Python: $($candidate.FullName)"
exit 0
}
}
Write-Host "LibreOffice program directory contents:"
Get-ChildItem -Path $programDir -ErrorAction SilentlyContinue | Select-Object Name, FullName
throw "Could not discover a bundled LibreOffice Python executable under $programDir"
- name: Verify LibreOffice runtime
shell: powershell
run: |
if (-not (Test-Path $env:EXSTRUCT_LIBREOFFICE_PATH)) {
throw "LibreOffice executable not found at $env:EXSTRUCT_LIBREOFFICE_PATH"
}
if (-not (Test-Path $env:EXSTRUCT_LIBREOFFICE_PYTHON_PATH)) {
throw "LibreOffice Python executable not found at $env:EXSTRUCT_LIBREOFFICE_PYTHON_PATH"
}
& $env:EXSTRUCT_LIBREOFFICE_PATH --version
if ($LASTEXITCODE -ne 0) {
throw "LibreOffice version probe failed with exit code $LASTEXITCODE"
}
- name: Run LibreOffice smoke tests
run: |
pytest tests/core/test_libreoffice_smoke.py -m libreoffice --maxfail=1 --disable-warnings -q