Files
python-repositories/.gitea/workflows/test.yml
T
Brian Bjarke JensenandCursor 0315a33a3b
PR Title Check / check-title (pull_request) Successful in 4s
Test Python Package / unit-tests (pull_request) Successful in 10s
Code Quality Pipeline / code-quality (pull_request) Successful in 24s
Test Python Package / integration-tests (pull_request) Successful in 20s
Test Python Package / coverage-report (pull_request) Successful in 24s
Avoid cross-job artifacts; combine coverage with --cov-append.
Gitea artifact download is unreliable with v3 actions, so the report job re-runs both suites on one runner after parallel test gates pass.

Co-authored-by: Cursor <[email protected]>
2026-07-07 19:27:26 +02:00

117 lines
3.1 KiB
YAML

name: Test Python Package
on:
push:
branches:
- main
pull_request:
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
- name: Install uv
run: pip install uv
- name: Install dependencies
env:
UV_LINK_MODE: copy
run: uv sync --all-extras
- name: Run unit tests
run: uv run pytest tests/unit/ -m "not integration" -v
integration-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
- name: Install uv
run: pip install uv
- name: Install dependencies
env:
UV_LINK_MODE: copy
run: uv sync --all-extras
- name: Verify Docker
run: docker info
- name: Run integration tests
run: uv run pytest -m integration -v
coverage-report:
needs: [unit-tests, integration-tests]
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
- name: Install uv
run: pip install uv
- name: Install dependencies
env:
UV_LINK_MODE: copy
run: uv sync --all-extras
# Gitea Actions lacks cross-job artifact download APIs; re-run tests here
# with --cov-append on one runner for an accurate combined report.
- name: Run tests with combined coverage
run: |
uv run pytest tests/unit/ -m "not integration" \
--cov=python_repositories \
--cov-report=
uv run pytest -m integration \
--cov=python_repositories \
--cov-append \
--cov-report=term-missing > coverage.txt
cat coverage.txt
- name: Post coverage summary to PR
if: github.event_name == 'pull_request'
env:
API_URL: ${{ vars.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: |
PAYLOAD=$(python3 -c '
import json
import pathlib
coverage = pathlib.Path("coverage.txt").read_text()
print(
json.dumps(
{
"body": f"**Test Coverage Report:**\n```\n{coverage}\n```",
}
)
)
')
curl -sf -X POST "$API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/comments" \
-H "Authorization: token $CI_RUNNER_TOKEN" \
-H "Content-Type: application/json" \
-d "$PAYLOAD"