# Reusable workflow: Python testing with pytest # Usage: uses: wectrl-net/ci-templates/.gitea/workflows/test-python.yaml@main name: Test Python (pytest) on: workflow_call: inputs: python-version: description: "Python version to use" required: false type: string default: "3.13" working-directory: description: "Directory containing the Python project" required: false type: string default: "." install-command: description: "Command to install dependencies (empty = pip install pytest pytest-asyncio)" required: false type: string default: "" pytest-args: description: "Additional pytest arguments" required: false type: string default: "--ignore=venv -q" jobs: test: name: pytest runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: ${{ inputs.python-version }} - name: Install dependencies run: | if [ -n "${{ inputs.install-command }}" ]; then ${{ inputs.install-command }} elif [ -f "${{ inputs.working-directory }}/requirements.txt" ]; then pip install -r ${{ inputs.working-directory }}/requirements.txt pip install pytest pytest-asyncio else pip install pytest pytest-asyncio fi working-directory: ${{ inputs.working-directory }} - name: Run tests run: pytest ${{ inputs.pytest-args }} working-directory: ${{ inputs.working-directory }}