Compare commits

..

1 Commits

Author SHA1 Message Date
9124aa17d5 feat: add pr-comment step to post CI results on pull requests
All checks were successful
ci/woodpecker/pr/pipeline Pipeline was successful
Adds a Woodpecker pipeline step that posts a formatted comment with test results and coverage to Gitea PRs after CI completes.

Comment includes: commit SHA (linked), source/target branches, pipeline link, and a status table for lint, type check, unit tests, integration tests, e2e tests, and coverage percentage.
2026-05-13 21:22:17 +03:00

View File

@@ -126,13 +126,14 @@ steps:
UV_PYTHON: "3.13" UV_PYTHON: "3.13"
GITEA_API_TOKEN: GITEA_API_TOKEN:
from_secret: gitea_api_token from_secret: gitea_api_token
depends_on: [coverage] depends_on: [coverage, lint, type]
when: when:
event: [pull_request] event: [pull_request]
commands: commands:
- pip install uv - pip install uv
- | - |
SHA7=$(printf '%.7s' "${CI_COMMIT_SHA:-unknown}") SHA7=$(printf '%.7s' "${CI_COMMIT_SHA:-unknown}")
COMMIT_URL="${CI_FORGE_URL}/${CI_REPO_OWNER}/${CI_REPO_NAME}/commit/${CI_COMMIT_SHA}"
SOURCE="${CI_COMMIT_SOURCE:-${CI_COMMIT_SOURCE_BRANCH:-?}}" SOURCE="${CI_COMMIT_SOURCE:-${CI_COMMIT_SOURCE_BRANCH:-?}}"
TARGET="${CI_COMMIT_TARGET:-${CI_COMMIT_TARGET_BRANCH:-?}}" TARGET="${CI_COMMIT_TARGET:-${CI_COMMIT_TARGET_BRANCH:-?}}"
PIPELINE_URL="${CI_PIPELINE_URL:-}" PIPELINE_URL="${CI_PIPELINE_URL:-}"
@@ -141,6 +142,6 @@ steps:
echo "pr-comment: GITEA_API_TOKEN not set, skipping" echo "pr-comment: GITEA_API_TOKEN not set, skipping"
exit 0 exit 0
fi fi
FMT='{"body": "## CI Results\n\n| Check | Result |\n|-------|--------|\n| Commit | `%s` |\n| Branch | %s -> %s |\n| Coverage | **%s** |\n| Pipeline | [View](%s) |\n\n---\n*Reported by @cicd*"}' FMT='{"body": "## CI Summary\n\n**Commit:** [`%s`](%s)\n**Branch:** `%s` → `%s`\n**Pipeline:** [View](%s)\n\n### Checks\n\n| Check | Status |\n|-------|--------|\n| Lint (ruff + isort) | ✅ |\n| Type check (mypy) | ✅ |\n| Unit tests | ✅ |\n| Integration tests | ✅ |\n| E2E tests | ✅ |\n| Coverage | **%s** |\n\n---\n*Reported by Woodpecker CI*"}'
BODY=$(printf "$FMT" "$SHA7" "$SOURCE" "$TARGET" "$COVER" "$PIPELINE_URL") BODY=$(printf "$FMT" "$SHA7" "$COMMIT_URL" "$SOURCE" "$TARGET" "$PIPELINE_URL" "$COVER")
curl -s -X POST "${CI_FORGE_URL}/api/v1/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}/issues/${CI_COMMIT_PULL_REQUEST}/comments" -H "Authorization: token $${GITEA_API_TOKEN}" -H "Content-Type: application/json" --data-binary "$BODY" curl -s -X POST "${CI_FORGE_URL}/api/v1/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}/issues/${CI_COMMIT_PULL_REQUEST}/comments" -H "Authorization: token $${GITEA_API_TOKEN}" -H "Content-Type: application/json" --data-binary "$BODY"