mirror of
https://github.com/Sea-Haven-Industries/shoc-pr-review-runner.git
synced 2026-09-30 09:53:11 +00:00
Manually-dispatched GitHub Actions workflow that reviews SHOC pull requests in a clean environment: exact-head checkout of shoc-frontend-new and shoc-backend, clean build/test gates, a truthful evidence report, a single-shot Fireworks review, deterministic output validation, and published artifacts. The runner never writes to the product repositories or their pull requests. The review checklists move here from the reviewers' local Cursor commands so the instructions live outside both product repos. Phase 1 does not provision a database, start either application, or run live browser flows; the evidence report records those as NOT_RUN so a review cannot claim them. Security architecture: building a PR executes its author's code, so the workflow is split. The gates job runs that code holding no Fireworks key and revokes its App token first; the review job holds the key, executes no product code, and re-checks out this repo fresh. Product checkouts live outside the workspace, the App token is downscoped at mint time, gate results fail closed on any duplicate key, changed files are read from git objects rather than the filesystem, and the validator re-checks every claim against the gate table.
62 lines
2.1 KiB
Bash
Executable file
62 lines
2.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Validate the workflow_dispatch inputs (spec §8.2) and normalize PR references.
|
|
#
|
|
# Reads: REVIEW_TYPE, FRONTEND_PR, BACKEND_PR, FRONTEND_REPO, BACKEND_REPO
|
|
# Writes: frontend_pr / backend_pr (numbers, empty when not in scope) to
|
|
# $GITHUB_OUTPUT when present, else stdout.
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
# shellcheck source=lib.sh
|
|
source "$SCRIPT_DIR/lib.sh"
|
|
|
|
require_env REVIEW_TYPE FRONTEND_REPO BACKEND_REPO
|
|
|
|
# normalize_pr <raw> <expected-repo> -> prints the PR number
|
|
# Accepts a bare number or a full PR URL. Rejects URLs pointing anywhere other
|
|
# than the expected repository.
|
|
normalize_pr() {
|
|
local raw="$1" repo="$2"
|
|
raw="$(printf '%s' "$raw" | tr -d '[:space:]')"
|
|
if [[ "$raw" =~ ^[0-9]+$ ]]; then
|
|
printf '%s' "$raw"
|
|
return 0
|
|
fi
|
|
if [[ "$raw" =~ ^https://github\.com/([^/]+/[^/]+)/pull/([0-9]+)(/.*)?$ ]]; then
|
|
local url_repo="${BASH_REMATCH[1]}" num="${BASH_REMATCH[2]}"
|
|
[ "$url_repo" = "$repo" ] || die "PR URL points at '$url_repo', expected '$repo'"
|
|
printf '%s' "$num"
|
|
return 0
|
|
fi
|
|
die "invalid PR reference '$raw' (expected a number or a $repo PR URL)"
|
|
}
|
|
|
|
frontend_pr=""
|
|
backend_pr=""
|
|
|
|
case "$REVIEW_TYPE" in
|
|
frontend)
|
|
[ -n "${FRONTEND_PR:-}" ] || die "review_type=frontend requires frontend_pr"
|
|
frontend_pr="$(normalize_pr "$FRONTEND_PR" "$FRONTEND_REPO")"
|
|
;;
|
|
backend)
|
|
[ -n "${BACKEND_PR:-}" ] || die "review_type=backend requires backend_pr"
|
|
backend_pr="$(normalize_pr "$BACKEND_PR" "$BACKEND_REPO")"
|
|
;;
|
|
paired)
|
|
[ -n "${FRONTEND_PR:-}" ] || die "review_type=paired requires frontend_pr"
|
|
[ -n "${BACKEND_PR:-}" ] || die "review_type=paired requires backend_pr"
|
|
frontend_pr="$(normalize_pr "$FRONTEND_PR" "$FRONTEND_REPO")"
|
|
backend_pr="$(normalize_pr "$BACKEND_PR" "$BACKEND_REPO")"
|
|
;;
|
|
*)
|
|
die "invalid review_type '$REVIEW_TYPE' (frontend|backend|paired)"
|
|
;;
|
|
esac
|
|
|
|
out="${GITHUB_OUTPUT:-/dev/stdout}"
|
|
{
|
|
printf 'frontend_pr=%s\n' "$frontend_pr"
|
|
printf 'backend_pr=%s\n' "$backend_pr"
|
|
} >>"$out"
|
|
|
|
log "inputs valid: review_type=$REVIEW_TYPE frontend_pr=${frontend_pr:-none} backend_pr=${backend_pr:-none}"
|