Files
CI-templates/.gitea/workflows/python/pytest.yml
T
Brian Bjarke Jensen 243a5432d8
Test CI Templates / validate-syntax (push) Successful in 11s
Test CI Templates / test-python-code-quality (3.11) (push) Failing after 5s
Test CI Templates / test-python-pytest (true, 3.12) (push) Failing after 4s
Test CI Templates / test-web-formatting (true, false, 20) (push) Failing after 5s
Test CI Templates / test-python-code-quality (3.10) (push) Failing after 5s
Test CI Templates / test-python-code-quality (3.12) (push) Failing after 5s
Test CI Templates / test-python-code-quality (false, false, basic) (push) Failing after 5s
Test CI Templates / test-python-code-quality (false, true, skip-pyupgrade) (push) Failing after 5s
Test CI Templates / test-python-pytest (false, 3.11) (push) Failing after 5s
Test CI Templates / test-python-pytest (false, 3.12) (push) Failing after 5s
Test CI Templates / test-python-pytest (true, 3.11) (push) Failing after 5s
Test CI Templates / test-web-formatting (false, false, 20) (push) Failing after 5s
Test CI Templates / test-web-formatting (false, true, 18) (push) Failing after 5s
Test CI Templates / test-web-formatting (false, true, 20) (push) Failing after 5s
Test CI Templates / test-web-formatting (true, false, 18) (push) Failing after 5s
Test CI Templates / test-monorepo (push) Failing after 5s
Test CI Templates / test-web-formatting (true, true, 18) (push) Failing after 5s
Test CI Templates / test-web-formatting (true, true, 20) (push) Failing after 5s
Test CI Templates / test-results (push) Successful in 2s
Test CI Templates / test-python-code-quality (true, false, skip-mypy) (push) Failing after 5s
Test CI Templates / test-web-formatting (false, false, 18) (push) Failing after 5s
Test CI Templates / test-edge-cases (push) Failing after 5s
fixed tests
2025-09-19 20:25:51 +02:00

112 lines
3.2 KiB
YAML

---
name: Python Test Pipeline
"on":
workflow_call:
inputs:
python-version:
description: 'Python version to use (e.g., "3.12")'
required: false
type: string
default: "3.12"
working-directory:
description: 'Working directory for the project'
required: false
type: string
default: "."
uv-extras:
description: 'UV extras to install (e.g., "dev,test")'
required: false
type: string
default: "all-extras"
pytest-args:
description: 'Additional arguments to pass to pytest'
required: false
type: string
default: ""
coverage-package:
description: 'Package name for coverage reporting (e.g., "my_package")'
required: false
type: string
default: ""
skip-coverage-comment:
description: 'Skip posting coverage comment to PR'
required: false
type: boolean
default: false
api-url:
description: 'Gitea API URL for posting comments'
required: false
type: string
default: ""
secrets:
CI_RUNNER_TOKEN:
description: 'Token for posting PR comments'
required: false
jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working-directory }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Install uv
run: pip install uv
- name: Install dependencies
env:
UV_LINK_MODE: copy
run: |
if [ "${{ inputs.uv-extras }}" = "all-extras" ]; then
uv sync --all-extras
else
uv sync --extra ${{ inputs.uv-extras }}
fi
- name: Run pytest
env:
PYTHONPATH: .
run: |
if [ -n "${{ inputs.coverage-package }}" ]; then
uv run pytest --cov=${{ inputs.coverage-package }} \
--cov-report=term-missing ${{ inputs.pytest-args }} > coverage.txt
else
uv run pytest ${{ inputs.pytest-args }}
fi
- name: Post coverage summary to PR
if: >-
${{
!inputs.skip-coverage-comment &&
inputs.coverage-package != '' &&
github.event_name == 'pull_request' &&
inputs.api-url != ''
}}
env:
API_URL: ${{ inputs.api-url }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
CI_RUNNER_TOKEN: ${{ secrets.CI_RUNNER_TOKEN }}
run: |
if [ -f coverage.txt ]; then
COVERAGE=$(cat coverage.txt)
COMMENT_BODY="**Test Coverage Report:**\n\`\`\`\n$COVERAGE\n\`\`\`"
API_ENDPOINT="$API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/comments"
curl -s -X POST \
"$API_ENDPOINT" \
-H "Authorization: token $CI_RUNNER_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"body\": \"$COMMENT_BODY\"}"
fi