Files
ARTEX/scripts/test-bot-context.sh
T
BaaRai 524d1f70be fix(ci): give the triage bot a directory map instead of a truncated file list
repo_context() printed the first 120 tracked paths alphabetically, which
stopped at config/ on an 846-file tree, so the model never saw docs/ or
scripts/ and told a contributor on issue #271 that neither directory exists.

The summary now lists the root files, every top-level directory with its file
count, the second level, and the workflow, migration, docs and script paths.
Both prompts also state that the summary is not a listing, so a path missing
from it is never reported as a path that does not exist.

scripts/test-bot-context.sh guards the invariant in the shell CI job: every
top-level directory must appear in the summary. It fails against the previous
version, which is the point.
2026-11-17 01:07:07 +01:00

34 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# Guards the triage bot's repository summary (.github/scripts/bot.sh,
# repo_context). Every top-level directory must be visible in it: an earlier
# version printed the first 120 tracked paths alphabetically, which stopped at
# config/ and made the bot tell a contributor that docs/ and scripts/benchmark/
# do not exist.
set -uo pipefail
cd "$(dirname "$0")/.." || exit 1
eval "$(sed -n '/^repo_context()/,/^}$/p' .github/scripts/bot.sh)"
[ "$(type -t repo_context)" = "function" ] || { echo "repo_context not found in bot.sh"; exit 1; }
out=$(repo_context) || { echo "repo_context failed"; exit 1; }
[ -n "$out" ] || { echo "repo_context printed nothing"; exit 1; }
status=0
while read -r dir; do
case "$out" in
*" $dir/"*) ;;
*) echo "missing top-level directory in the bot summary: $dir"; status=1 ;;
esac
done < <(git ls-files | awk -F/ 'NF >= 2 { print $1 }' | sort -u)
# The two paths the truncated list used to hide, asserted by name.
for path in docs scripts/benchmark; do
case "$out" in
*" $path/"*) ;;
*) echo "missing from the bot summary: $path/"; status=1 ;;
esac
done
[ "$status" = 0 ] && echo "ok: the bot summary exposes every top-level directory"
exit "$status"