golangLAKEHOUSE/justfile
root e31638204d S0.3: just verify + pre-push hook gates the smoke chain
Sprint 0 / R-004 / GATE-0.4 — the 9-smoke chain is no longer
documentation only. One command (`just verify`) runs vet + tests +
all 9 smokes; pre-push hook calls it; a regression cannot leave
this machine without explicit --no-verify override.

Recipes:
  just verify          full gate (33s wall on this box)
  just smoke <day>     single smoke (d1..d6, g1, g1p, g2)
  just smoke-all       all 9 smokes only
  just doctor          dep probe with structured output
                       (--json for CI / pre-push)
  just install-hooks   install .git/hooks/pre-push
  just fmt|vet|test|build|clean

scripts/doctor.sh probes Go ≥1.25, gcc, MinIO at :9000 with bucket
lakehouse-go-primary, Ollama at :11434 with nomic-embed-text loaded,
/etc/lakehouse/secrets-go.toml with [s3.primary]. Each missing dep
prints its install fix command. JSON mode emits the same shape for
CI / pre-push consumers.

README updated with the task-runner section + just install-hooks
on cold-start. Hooks live in .git/hooks/ (untracked); install
recipe recreates them on a fresh clone.

PATH note: justfile prepends /usr/local/go/bin so recipes find Go
without depending on the parent shell's PATH (ADR-001 §1.x lives
go there).

Verified: just verify exits 0 in 33s wall (vet ~0.1s + test ~0.1s +
9 smokes deterministic per audit baseline). Pre-push hook installed
and bash -n clean.

Closes audit risk R-004 (smokes not gated).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 04:56:50 -05:00

104 lines
3.4 KiB
Makefile

# golangLAKEHOUSE — task runner.
#
# Sprint 0 acceptance gate (R-004): smokes are no longer documentation
# only — `just verify` is the single command that runs vet + tests +
# the 9 smokes. The pre-push hook calls this; CI calls this; reviewers
# call this. One source of truth.
#
# Usage:
# just # alias for `just --list`
# just verify # vet + test + all 9 smokes (full gate)
# just smoke <day> # single smoke (d1..d6, g1, g1p, g2)
# just smoke-all # all 9 smokes only
# just doctor # dependency probe
# just fmt / vet / test / build
# Go lives at /usr/local/go/bin per ADR-001 §1.x; prepend so every
# recipe sees it without depending on the parent shell's PATH.
export PATH := "/usr/local/go/bin:" + env('PATH', '')
# Default recipe shows the menu so `just` alone is a discoverable entry point.
default:
@just --list
# Full Sprint 0 gate: vet + tests + 9 smokes. Pre-push hook calls this.
verify: vet test smoke-all
@echo ""
@echo "[verify] PASS — go vet + go test + 9 smokes all green"
# Static analysis. Runs first so we fail fast on syntax / shape issues.
vet:
@echo "[vet] go vet ./..."
@go vet ./...
# Go unit tests, short mode. Excludes hardware-in-the-loop tags.
test:
@echo "[test] go test -short -count=1 ./..."
@go test -short -count=1 ./...
# Format Go source. Idempotent; CI can run with --check via `just fmt-check`.
fmt:
@gofmt -w cmd internal scripts
# Verify formatting without modifying. Non-zero exit means run `just fmt`.
fmt-check:
@diff -u <(echo -n) <(gofmt -d cmd internal scripts)
# Build every binary into bin/. Mirrors what each smoke does internally.
build:
@echo "[build] go build -o bin/ ./cmd/..."
@go build -o bin/ ./cmd/...
# Single smoke. Day is the suffix before _smoke.sh — d1, d2, …, g2.
smoke day:
@bash scripts/{{day}}_smoke.sh
# All 9 smokes in dependency order. Halts on first failure.
smoke-all:
#!/usr/bin/env bash
set -euo pipefail
for day in d1 d2 d3 d4 d5 d6 g1 g1p g2; do
printf "[smoke-all] %s ... " "$day"
SECONDS=0
if bash "scripts/${day}_smoke.sh" >/tmp/smoke_${day}.log 2>&1; then
printf "PASS (%ss)\n" "$SECONDS"
else
printf "FAIL (%ss)\n" "$SECONDS"
echo ""
echo " last 20 lines of /tmp/smoke_${day}.log:"
tail -20 "/tmp/smoke_${day}.log" | sed 's/^/ /'
exit 1
fi
done
# Dependency probe. Add --json for machine-readable output.
doctor *args:
@bash scripts/doctor.sh {{args}}
# Install pre-push hook so `git push` runs `just verify` first.
install-hooks:
#!/usr/bin/env bash
set -euo pipefail
HOOK=".git/hooks/pre-push"
cat > "$HOOK" <<'HOOK'
#!/usr/bin/env bash
# golangLAKEHOUSE pre-push hook (managed by `just install-hooks`).
# Runs the Sprint 0 gate before letting commits leave this machine.
set -e
cd "$(git rev-parse --show-toplevel)"
echo "[pre-push] running just verify ..."
if ! just verify; then
echo ""
echo "[pre-push] FAIL — push aborted. Fix the gate or use --no-verify (NOT recommended)."
exit 1
fi
HOOK
chmod +x "$HOOK"
echo "[install-hooks] $HOOK installed and executable"
# Clean built binaries + smoke logs. Does NOT touch reports/ or data/.
clean:
@rm -rf bin/
@rm -f /tmp/smoke_*.log
@echo "[clean] bin/ removed, smoke logs cleared"