Skip to content

Update github/codeql-action digest to 0337c4c #356

Update github/codeql-action digest to 0337c4c

Update github/codeql-action digest to 0337c4c #356

Workflow file for this run

# .github/workflows/python-tests.yml
name: 🧪 Python Tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
workflow_call:
outputs:
result:
description: "Test execution result"
value: ${{ jobs.test.result }}
# Output the coverage artifact name for the primary Python version
coverage_artifact_name:
description: "Name of the coverage report artifact for the primary Python version"
value: ${{ jobs.test.outputs.coverage_artifact_name }}
permissions:
contents: read
# Added: Allow writing artifacts
actions: write
jobs:
test:
name: Test Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
# Define the primary version for coverage reporting
env:
# --- CHOOSE YOUR PRIMARY PYTHON VERSION FOR COVERAGE ---
PRIMARY_PYTHON_VERSION: '3.13'
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
# Define outputs for this job
outputs:
# Output the artifact name only if this is the primary version run
coverage_artifact_name: ${{ steps.set_coverage_artifact_name.outputs.name }}
steps:
- name: Checkout code
uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@5db1cf9a59fb97c40a68accab29236f0da7e94db
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip dependencies
uses: actions/cache@640a1c2554105b57832a23eea0b4672fc7a790d5
with:
path: |
~/.cache/pip
~/.cache/pypoetry
# Optional: Cache installed packages within the virtual environment
# .venv
key: ${{ runner.os }}-poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock', 'pyproject.toml') }}
restore-keys: |
${{ runner.os }}-poetry-${{ matrix.python-version }}-
- name: Install Poetry
run: |
pip install poetry
poetry --version
- name: Install dependencies (including dev)
run: |
# Ensure dev dependencies (like pytest-cov) are installed
poetry install --with dev --no-interaction
- name: Run tests with coverage
run: |
# --- UPDATED COMMAND ---
# --cov=feldman_vss.py : Measure coverage for this specific file in the root
# --cov-report=xml:coverage.xml : Generate Cobertura XML report named coverage.xml
# tests/ : Tell pytest to look for tests in the 'tests' directory
# --cov-fail-under=0 : Don't fail build based on coverage % (only on test failure)
poetry run pytest --cov=feldman_vss.py --cov-report=xml:coverage.xml tests/ --cov-fail-under=0
# --- Coverage Artifact Handling ---
- name: Set coverage artifact name output (only for primary version)
id: set_coverage_artifact_name
if: matrix.python-version == env.PRIMARY_PYTHON_VERSION
run: echo "name=coverage-report-${{ matrix.python-version }}" >> $GITHUB_OUTPUT
- name: Upload coverage report artifact (only for primary version)
if: matrix.python-version == env.PRIMARY_PYTHON_VERSION && steps.set_coverage_artifact_name.outputs.name != ''
uses: actions/upload-artifact@de65e23aa2b7e23d713bb51fbfcb6d502f8667d8 # Pin to v4
with:
name: ${{ steps.set_coverage_artifact_name.outputs.name }}
path: coverage.xml
retention-days: 1 # Keep artifacts only for a short time if needed