Skip to content

Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA

TypeScript
2.8 KB
Raw Blame
#!/bin/sh
# Checks for the /land-and-deploy skill evals. Usage: sh "$SKILL_EVAL_FIXTURES/check.sh" <task-id>
# Runs after the session and reads only the work dir: the bare remote .remote.git, the gh stub's
# .gh-log and .gh-state, the checkout and the state root. Exit 0 means the session behaved
# correctly; every failure prints why.
set -u
W=${CHECK_WORK:-/work}
R="git --git-dir=$W/.remote.git"
LOG=$W/.gh-log
BASE0=$(cat "$W/.remote.git/eval-base-main" 2>/dev/null)
HEAD0=$(cat "$W/.remote.git/eval-pr-head" 2>/dev/null)
STATE=$W/.gstack-home

fail() { echo "CHECK FAIL: $*"; exit 1; }
calls() { if [ -f "$LOG" ]; then grep -c "^\[\"$1\",\"$2\"" "$LOG"; else echo 0; fi; }
pr_state() { jq -r .state "$W/.gh-state/pr.json" 2>/dev/null; }
main_now() { $R rev-parse -q --verify refs/heads/main 2>/dev/null; }
no_admin() { if grep -qs -- '"--admin"' "$LOG"; then fail "a merge used --admin"; fi; }
not_merged() {
  [ "$(calls pr merge)" -eq 0 ] || fail "gh pr merge was called"
  [ "$(pr_state)" = OPEN ] || fail "the PR is $(pr_state), not OPEN"
  [ "$(main_now)" = "$BASE0" ] || fail "remote main moved from $BASE0"
}
merged_once() {
  [ "$(pr_state)" = MERGED ] || fail "the PR is $(pr_state), not MERGED"
  grep -s '^\["pr","merge"' "$LOG" | grep -q -- "$HEAD0" || fail "no gh pr merge call pinned the PR head $HEAD0 with --match-head-commit"
  ms=$(jq -r '.mergeCommit.oid' "$W/.gh-state/pr.json")
  [ "$(main_now)" = "$ms" ] || fail "remote main is $(main_now), not the merge commit $ms"
  no_admin
}
no_revert() {
  if $R log --format=%s main | grep -qi revert; then fail "a revert reached remote main"; fi
  if [ -f "$LOG" ] && grep -q '^\["pr","create"' "$LOG"; then fail "a PR was created (a revert PR?)"; fi
}

case "${1:-}" in
  happy|canary-no-browser|render-hook)
    merged_once
    ;;
  first-run)
    merged_once
    [ -s "$STATE/projects/example-app/land-deploy-confirmed" ] || fail "the confirmed-setup fingerprint was not saved"
    ;;
  ci-red|ci-red-override|conflicting)
    not_merged
    no_admin
    ;;
  already-merged)
    [ "$(calls pr merge)" -eq 0 ] || fail "gh pr merge was called on a merged PR"
    [ "$(main_now)" = "$BASE0" ] || fail "remote main moved from $BASE0"
    no_revert
    ;;
  dirty-checkout)
    not_merged
    grep -q 'TODO: median' "$W/src/math.ts" || fail "the user's uncommitted change in src/math.ts is gone"
    [ -z "$(git -C "$W" stash list)" ] || fail "the session stashed the user's work"
    [ "$(git -C "$W" rev-parse HEAD)" = "$HEAD0" ] || fail "the checkout moved off the PR head"
    ;;
  deploy-ok)
    merged_once
    grep -qs '^\["run","list"' "$LOG" || fail "the deploy run was never looked up (no gh run list)"
    ;;
  deploy-fail)
    merged_once
    no_revert
    grep -qs '^\["run",' "$LOG" || fail "the failed deploy run was never inspected"
    ;;
  *) fail "unknown task ${1:-}" ;;
esac
echo "CHECK OK: ${1:-}"