Files
gentoo-zh/scripts/comment-status.sh
Zakk 06cf3c541b .github: report emerge elog in the pull request comment
The emerge job failed on any saved elog, so warn elog from eclasses,
such as CONFIG_CHECK without kernel sources in the CI container, failed
pull requests whose package was fine. The job now fails only on QA and
error elog. Portage also saves log elog now, and every target's elog is
uploaded and reported in a new section of the pkgcheck report comment,
so reviewers still see the warnings and post-install notes. When
dependency resolution or the emerge fails, the section shows the last
lines of its output, because the elog alone does not show the cause. The
build.log of each package that failed is uploaded as an artifact and
linked from its row.

pkgcheck-comment now also handles the requested event of pkgcheck and
emerge-on-pr, so each section shows that its run is in progress, and
removes the elog section when a push leaves no emerge targets. Because
runs of both sections and of older pushes edit the same comment at once,
upsert-comment-section.sh writes only while the pull request head is
still the run's commit, and reads the comment back to write again when
another run overwrote its section.

Signed-off-by: Zakk <zakk@gentoozh.org>
2026-10-22 09:34:26 +11:00

29 lines
855 B
Bash
Executable File

#!/usr/bin/env bash
# usage: comment-status.sh <section> [<status>]
# Sets a section of the pkgcheck report comment to its heading and a status
# line, or removes the section when no status is given.
set -euo pipefail
MARKER='<!-- pkgcheck-report -->'
section=${1:?section}
status=${2:-}
body_file=$(mktemp)
trap 'rm -f "$body_file"' EXIT
pr=$(scripts/pr-at-commit.sh "$GITHUB_REPOSITORY" "$HEAD_SHA")
if [ -z "$pr" ]; then
echo 'no open pull request at this commit'
exit 0
fi
echo "pull request #${pr}"
if [ -n "$status" ]; then
case $section in
pkgcheck) echo '## Pull request pkgcheck report' ;;
elog) echo '## emerge elog' ;;
esac > "$body_file"
echo >> "$body_file"
echo "*Status*: ${status}" >> "$body_file"
fi
scripts/upsert-comment-section.sh "$GITHUB_REPOSITORY" "$pr" "$MARKER" "$section" "$body_file"