Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

chore: check.sh gotestsum summaries + install.sh style

Datad2638545997e
diff --git a/scripts/check.sh b/scripts/check.sh
index c74c44aa..5ad67dd4 100755
--- a/scripts/check.sh
+++ b/scripts/check.sh
@@ -1,86 +1,222 @@
#!/bin/bash
set -e
-echo "πŸ” Running pre-push checks (matches GitHub Actions CI)..."
+# check.sh β€” Local pre-push checks matching GitHub Actions CI
+# Uses gotestsum for structured test output with summaries
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
+BOLD='\033[1m'
+ACCENT='\033[38;2;251;191;36m'
+INFO='\033[38;2;136;146;176m'
+SUCCESS='\033[38;2;0;229;204m'
+ERROR='\033[38;2;230;57;70m'
+MUTED='\033[38;2;90;100;128m'
NC='\033[0m'
-check_step() {
- local step_name="$1"
- echo -e "\n${YELLOW}πŸ“‹ $step_name${NC}"
-}
+CORE_REGEX='^Test(Health|Orchestrator_|Navigate_|Tabs_|Config_|Metrics_|Cookies_|Error_|Eval_|Upload_|Screenshot_)'
+TMPDIR_CHECK=$(mktemp -d)
+trap 'rm -rf "$TMPDIR_CHECK" pinchtab coverage.out 2>/dev/null' EXIT
+
+ok() { echo -e " ${SUCCESS}βœ“${NC} $1"; }
+fail() { echo -e " ${ERROR}βœ—${NC} $1"; [ -n "${2:-}" ] && echo -e " ${MUTED}$2${NC}"; }
+hint() { echo -e " ${MUTED}$1${NC}"; }
-success_step() {
- local step_name="$1"
- echo -e "${GREEN}βœ… $step_name - PASSED${NC}"
+section() {
+ echo ""
+ echo -e "${ACCENT}${BOLD}$1${NC}"
}
-error_step() {
- local step_name="$1"
- echo -e "${RED}❌ $step_name - FAILED${NC}"
- exit 1
+# Parse gotestsum JSON events and print summary
+test_summary() {
+ local json_file="$1"
+ local label="$2"
+
+ if [ ! -s "$json_file" ]; then
+ echo -e " ${MUTED}No test events recorded${NC}"
+ return
+ fi
+
+ local total=0 pass=0 fail=0 skip=0
+ read total pass fail skip <<<"$(jq -r \
+ 'select(.Test != null and (.Action == "pass" or .Action == "fail" or .Action == "skip"))
+ | [.Package, .Test, .Action] | @tsv' "$json_file" \
+ | awk -F'\t' 'NF == 3 { key = $1 "\t" $2; status[key] = $3 }
+ END {
+ for (k in status) {
+ t++
+ if (status[k] == "pass") p++
+ else if (status[k] == "fail") f++
+ else if (status[k] == "skip") s++
+ }
+ printf "%d %d %d %d\n", t+0, p+0, f+0, s+0
+ }')"
+
+ echo ""
+ echo -e " ${BOLD}$label${NC}"
+ echo -e " ${MUTED}────────────────────────────${NC}"
+ echo -e " Total: ${BOLD}$total${NC}"
+ [ "$pass" -gt 0 ] && echo -e " Passed: ${SUCCESS}$pass${NC}"
+ [ "$fail" -gt 0 ] && echo -e " Failed: ${ERROR}$fail${NC}"
+ [ "$skip" -gt 0 ] && echo -e " Skipped: ${ACCENT}$skip${NC}"
+
+ # Show failed test names
+ if [ "$fail" -gt 0 ]; then
+ echo ""
+ echo -e " ${ERROR}Failed tests:${NC}"
+ jq -r 'select(.Test != null and .Action == "fail") | " βœ— \(.Test)"' "$json_file" | sort -u
+ fi
}
-check_step "Format Check"
+# ── Start ────────────────────────────────────────────────────────────
+
+echo ""
+echo -e " ${ACCENT}${BOLD}πŸ¦€ Pinchtab Check${NC}"
+echo -e " ${INFO}Running pre-push checks (matches GitHub Actions CI)...${NC}"
+
+# ── Check gotestsum ──────────────────────────────────────────────────
+
+HAS_GOTESTSUM=false
+if command -v gotestsum &>/dev/null; then
+ HAS_GOTESTSUM=true
+fi
+
+# ── Format ───────────────────────────────────────────────────────────
+
+section "Format Check"
+
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
- echo -e "${RED}Files not formatted:${NC}"
- echo "$unformatted"
- echo -e "${YELLOW}Run: gofmt -w .${NC}"
- error_step "Format Check"
+ fail "gofmt" "Files not formatted:"
+ echo "$unformatted" | while read f; do hint " $f"; done
+ hint "Run: gofmt -w ."
+ exit 1
fi
-success_step "Format Check"
+ok "gofmt"
+
+# ── Vet ──────────────────────────────────────────────────────────────
+
+section "Go Vet"
-check_step "Go Vet"
-if ! go vet ./...; then
- error_step "Go Vet"
+if ! go vet ./... 2>&1; then
+ fail "go vet"
+ exit 1
fi
-success_step "Go Vet"
+ok "go vet"
-check_step "Build"
-if ! go build -o pinchtab ./cmd/pinchtab; then
- error_step "Build"
+# ── Build ────────────────────────────────────────────────────────────
+
+section "Build"
+
+if ! go build -o pinchtab ./cmd/pinchtab 2>&1; then
+ fail "go build"
+ exit 1
fi
-success_step "Build"
+ok "go build"
+
+# ── Unit Tests ───────────────────────────────────────────────────────
+
+section "Unit Tests"
+
+UNIT_JSON="$TMPDIR_CHECK/unit-events.json"
-check_step "Tests with Coverage"
-if ! go test ./... -v -count=1 -coverprofile=coverage.out -covermode=atomic; then
- error_step "Tests"
+if $HAS_GOTESTSUM; then
+ if ! gotestsum --format testname --jsonfile "$UNIT_JSON" -- \
+ -v -count=1 -coverprofile=coverage.out -covermode=atomic ./...; then
+ fail "Unit tests"
+ test_summary "$UNIT_JSON" "Unit Test Results"
+ exit 1
+ fi
+ ok "Unit tests"
+ test_summary "$UNIT_JSON" "Unit Test Results"
+else
+ if ! go test ./... -v -count=1 -coverprofile=coverage.out -covermode=atomic; then
+ fail "Unit tests"
+ exit 1
+ fi
+ ok "Unit tests"
+fi
+
+echo ""
+echo -e " ${BOLD}Coverage${NC}"
+echo -e " ${MUTED}────────────────────────────${NC}"
+go tool cover -func=coverage.out | tail -1 | awk '{printf " %s\n", $0}'
+
+# ── Integration Tests (Core) ────────────────────────────────────────
+
+section "Integration Tests (Core)"
+
+CORE_JSON="$TMPDIR_CHECK/core-events.json"
+
+if $HAS_GOTESTSUM; then
+ if ! gotestsum --format testname --jsonfile "$CORE_JSON" -- \
+ -tags integration -v -timeout 10m -count=1 \
+ -run "$CORE_REGEX" ./tests/integration/; then
+ fail "Integration core"
+ test_summary "$CORE_JSON" "Core Test Results"
+ exit 1
+ fi
+ ok "Integration core"
+ test_summary "$CORE_JSON" "Core Test Results"
+else
+ if ! go test -tags integration -v -timeout 10m -count=1 \
+ -run "$CORE_REGEX" ./tests/integration/; then
+ fail "Integration core"
+ exit 1
+ fi
+ ok "Integration core"
fi
-echo -e "\n${YELLOW}πŸ“Š Coverage Summary:${NC}"
-go tool cover -func=coverage.out | tail -1
-success_step "Tests with Coverage"
+# ── Integration Tests (Rest) ────────────────────────────────────────
+
+section "Integration Tests (Rest)"
-check_step "Integration Tests"
-if ! go test -tags integration -v -timeout 10m ./tests/integration/; then
- error_step "Integration Tests"
+REST_JSON="$TMPDIR_CHECK/rest-events.json"
+
+if $HAS_GOTESTSUM; then
+ if ! gotestsum --format testname --jsonfile "$REST_JSON" -- \
+ -tags integration -v -timeout 12m -count=1 \
+ -run '^Test' -skip "$CORE_REGEX" ./tests/integration/; then
+ fail "Integration rest"
+ test_summary "$REST_JSON" "Rest Test Results"
+ exit 1
+ fi
+ ok "Integration rest"
+ test_summary "$REST_JSON" "Rest Test Results"
+else
+ if ! go test -tags integration -v -timeout 12m -count=1 \
+ -run '^Test' -skip "$CORE_REGEX" ./tests/integration/; then
+ fail "Integration rest"
+ exit 1
+ fi
+ ok "Integration rest"
fi
-success_step "Integration Tests"
-check_step "Lint Check"
+# ── Lint ─────────────────────────────────────────────────────────────
+
+section "Lint"
+
LINT_CMD=""
if command -v golangci-lint >/dev/null 2>&1; then
- LINT_CMD="golangci-lint"
+ LINT_CMD="golangci-lint"
elif [ -x "$HOME/bin/golangci-lint" ]; then
- LINT_CMD="$HOME/bin/golangci-lint"
+ LINT_CMD="$HOME/bin/golangci-lint"
elif [ -x "/usr/local/bin/golangci-lint" ]; then
- LINT_CMD="/usr/local/bin/golangci-lint"
+ LINT_CMD="/usr/local/bin/golangci-lint"
fi
if [ -n "$LINT_CMD" ]; then
- if ! $LINT_CMD run ./...; then
- error_step "Lint Check"
- fi
- success_step "Lint Check"
+ if ! $LINT_CMD run ./...; then
+ fail "golangci-lint"
+ exit 1
+ fi
+ ok "golangci-lint"
else
- echo -e "${YELLOW}⚠️ golangci-lint not installed - skipping lint check${NC}"
- echo -e "${YELLOW} Install with: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ~/bin v2.9.0${NC}"
+ echo -e " ${ACCENT}Β·${NC} golangci-lint not installed β€” skipping"
+ hint "Install: brew install golangci-lint"
fi
-rm -f pinchtab coverage.out
+# ── Summary ──────────────────────────────────────────────────────────
-echo -e "\n${GREEN}πŸŽ‰ All checks passed! Ready to push.${NC}"
+section "Summary"
+echo ""
+echo -e " ${SUCCESS}${BOLD}All checks passed!${NC} Ready to push."
+echo ""