Files
gentoo-zh/scripts/pkgcheck-report.sh
T
Zakk b885f35b7a scripts: mark an unfinished pkgcheck scan instead of a finished one
pkgcheck-comment runs master's scripts, but the artifact comes from the
pull request's merge ref, which can predate the change that added the
complete marker. Such an artifact was reported as a scan that did not
finish (#14536). Stage now writes an incomplete marker when the scan did
not finish, so an artifact without either marker reads as before.

Signed-off-by: Zakk <zakk@gentoozh.org>
2026-10-09 11:32:47 +11:00

59 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# usage: pkgcheck-report.sh packages|scan|stage
set -euo pipefail
case "${1:?packages, scan or stage}" in
packages)
git config --global --add safe.directory '*'
# The merge ref parents are the current base tip and PR head.
git diff --name-only --diff-filter=d 'HEAD^1...HEAD^2' \
| awk -F/ 'NF > 2 { print $1"/"$2 }' | sort -u > touched.txt
: > packages.txt
while read -r pkg; do
ls "${pkg}"/*.ebuild >/dev/null 2>&1 || continue
echo "${pkg}" >> packages.txt
done < touched.txt
echo "count=$(wc -l < packages.txt)" >> "$GITHUB_OUTPUT"
cat packages.txt
;;
scan)
pmaint sync gentoo
head=$(git rev-parse HEAD)
scan() {
local out=$1
shift
pmaint regen --dir ~/.cache/pkgcheck/repos . > /dev/null
pkgcheck scan --checks=-RedundantVersionCheck --keywords=-NonsolvableDepsInDev \
"$@" > "${out}" 2>&1 || true
}
mapfile -t pkgs < packages.txt
scan report.txt "${pkgs[@]}"
git checkout --quiet 'HEAD^1'
: > base-report.txt
mapfile -t base_pkgs < <(
for pkg in "${pkgs[@]}"; do
ls "${pkg}"/*.ebuild > /dev/null 2>&1 && echo "${pkg}"
done
)
[ "${#base_pkgs[@]}" -eq 0 ] || scan base-report.txt "${base_pkgs[@]}"
git checkout --quiet "${head}"
python3 scripts/pkgcheck-new-findings.py base-report.txt report.txt > new.txt
echo '--- new ---'; cat new.txt
echo '--- all ---'; cat report.txt
: > scan-complete
;;
stage)
mkdir -p pkgcheck-report
git rev-parse --short 'HEAD^2' > pkgcheck-report/commit
cp packages.txt pkgcheck-report/packages 2>/dev/null || : > pkgcheck-report/packages
cp report.txt pkgcheck-report/report.txt 2>/dev/null || : > pkgcheck-report/report.txt
cp new.txt pkgcheck-report/new.txt 2>/dev/null || : > pkgcheck-report/new.txt
# the comment runs master's scripts, which may be newer than the ones that made this artifact
[ -f scan-complete ] || : > pkgcheck-report/incomplete
;;
esac