Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-architecture-mv/blob/main/scripts/test_pr_gate.sh # aien-architecture-mv Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-architecture-mv / scripts / test_pr_gate.sh` 201 lines ยท 12319 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # Offline test for pr-gate.sh. A fake `gh` on PATH answers from fixture JSON chosen by $CASE and 3 # records any merge command line. Local and crumb steps use real temporary git repos (bare origin 4 # plus worktree). The crumb step is retired (DRA-97): a `crumb` stub that exits 99 is on PATH and in 5 # $CRUMB, and the test proves it is never called. No network, no auth. 6 set -u 7 here="$(cd "$(dirname "$0")" && pwd)" 8 gate="$here/pr-gate.sh" 9 tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT 10 export GIT_AUTHOR_NAME=T GIT_AUTHOR_EMAIL=t@example.invalid GIT_COMMITTER_NAME=T GIT_COMMITTER_EMAIL=t@example.invalid 11 export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null 12 export SLEEP_SECS=0 13 FX="$tmp/fx"; mkdir -p "$FX" "$tmp/bin"; export FX 14 15 cat > "$tmp/bin/gh" <<'S' 16 #!/usr/bin/env bash 17 d="$FX/$CASE" 18 case "$1 $2" in 19 "pr view") 20 if echo "$*" | grep -q mergeCommit && [ -e "$d/merged-flag" ]; then cat "$d/merged.json" 21 elif [ -e "$d/updated.json" ] && [ -e "$d/viewed" ]; then cat "$d/updated.json" 22 else 23 touch "$d/viewed" 24 cat "$d/pr.json" 25 fi ;; 26 "pr list") cat "$d/list.json" ;; 27 "pr merge") 28 echo "$*" > "$d/merge.cmd" 29 if [ -e "$d/updated.json" ]; then 30 want=$(jq -r .headRefOid "$d/updated.json") 31 [[ " $* " == *" --match-head-commit $want "* ]] || { echo "head branch changed" >&2; exit 1; } 32 fi 33 touch "$d/merged-flag" ;; 34 api\ repos/*) 35 if [ -e "$d/prot404" ]; then echo "gh: Not Found (HTTP 404)" >&2; exit 1; fi 36 cat "$d/prot.json" ;; 37 *) echo "fake gh: unhandled: $*" >&2; exit 2 ;; 38 esac 39 S 40 cat > "$tmp/bin/crumb" <<'S' 41 #!/usr/bin/env bash 42 # retired: any call is a test failure (recorded, then exit 99) 43 echo "$*" >> "$FX/crumb-called" 44 exit 99 45 S 46 chmod +x "$tmp/bin/gh" "$tmp/bin/crumb" 47 export PATH="$tmp/bin:$PATH" CRUMB="$tmp/bin/crumb" 48 RETIRED='GATE crumb: SKIP retired 2026-11-07 \(DRA-97\); .crumb files are history' 49 50 pass=0; bad=0 51 ok() { pass=$((pass+1)); } 52 no() { bad=$((bad+1)); echo "TEST FAIL: $1"; } 53 run() { OUT=$("$gate" "$@" 2>&1); rc=$?; } 54 expect() { # expect