Files
urutau/scripts/check.sh
T
Lucas RayanandClaude Opus 5.5 8546d14cef
CI / Format and vet (pull_request) Failing after 53s
CI / Dependency audit (pull_request) Successful in 33s
CI / Tests (Linux, race detector) (pull_request) Successful in 2m1s
CI / Docker images (build and smoke test) (pull_request) Failing after 47s
feat!: Urutau 2.0.0, ultralight probes and a single analysis hub
Each server runs an ultralight probe (scratch image, ~7 MiB RSS) that
tails the logs, ships raw lines to the hub over HTTPS with an on-disk
spool, and applies enforce decisions locally. The hub keeps one node per
probe (primary node = the 1.x data dir, unchanged), does all analysis and
serves the UI. Peer federation is removed. 'urutau import' brings 1.x
data dirs in with hash and count verification. UI: probes page, host
qualified incidents, IPs never wrap, egress heatmap labels, live and
replay globes no longer auto-rotate, replay repeat, live traffic metrics.

BREAKING CHANGE: URUTAU_PEERS, URUTAU_PEER_* and /api/v1/peer/* are gone;
log path variables move from the hub to the probe. See docs/migration-2.0.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 22:14:50 -03:00

92 lines
3.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Local verification: runs the same checks as CI before pushing. Anything the
# machine lacks (go, node, docker, govulncheck) is skipped with a warning.
#
# scripts/check.sh fast: gofmt, go vet, i18n, scripts, workflows, compose
# scripts/check.sh --full also runs go test -race and govulncheck
# scripts/check.sh --ui also renders every route and fails on horizontal overflow
# (needs Chrome and puppeteer-core; skipped when missing)
#
# CI takes minutes per run; almost everything that breaks it is caught here
# in seconds.
set -uo pipefail
cd "$(dirname "$0")/.."
full=0
ui=0
for a in "$@"; do
[ "$a" = "--full" ] && full=1
[ "$a" = "--ui" ] && ui=1
done
failures=()
step() { # step "name" command...
local name="$1"; shift
printf '\n\033[1m== %s\033[0m\n' "$name"
if "$@"; then printf '\033[32mok\033[0m %s\n' "$name"; else printf '\033[31mFAILED\033[0m %s\n' "$name"; failures+=("$name"); fi
}
skip() { printf '\n\033[33mskipped\033[0m %s (%s)\n' "$1" "$2"; }
if command -v go >/dev/null; then
step "formatting (gofmt)" bash -c 'out=$(gofmt -l .); [ -z "$out" ] || { echo "$out"; exit 1; }'
step "go vet" go vet ./...
else
skip "gofmt and go vet" "go not installed"
fi
if command -v node >/dev/null; then
step "UI translation coverage" node scripts/check-ui-i18n.mjs
else
skip "UI translation coverage" "node not installed"
fi
if [ "$ui" = 1 ]; then
if command -v go >/dev/null && command -v node >/dev/null; then
bin="$(mktemp -d)/urutau"
if go build -o "$bin" ./cmd/urutau; then step "UI layout (no horizontal overflow)" node scripts/ui-overflow.mjs "$bin"; else skip "UI layout" "build failed"; fi
else
skip "UI layout" "go or node not installed"
fi
fi
step "bash script syntax" bash -c 'for f in scripts/*.sh .githooks/*; do bash -n "$f" || exit 1; done'
if python3 -c 'import yaml' 2>/dev/null; then
step "workflows and templates (valid YAML)" python3 -c "
import glob, yaml
for f in glob.glob('.gitea/**/*.yml', recursive=True):
yaml.safe_load(open(f))
"
else
skip "workflows and templates (valid YAML)" "PyYAML missing: pip install pyyaml"
fi
step "docs links" python3 scripts/check-docs-links.py
step "brand assets" test -s logo.png
if command -v docker >/dev/null && docker compose version >/dev/null 2>&1; then
step "docker compose config (hub)" docker compose config --quiet
step "docker compose config (probe)" env URUTAU_HUB=https://hub.example.org URUTAU_PROBE_NAME=check docker compose -f deploy/probe/docker-compose.yml config --quiet
else
skip "docker compose config" "docker compose not available"
fi
if [ "$full" = 1 ]; then
if command -v go >/dev/null; then
step "tests (go test -race)" go test -race ./...
if command -v govulncheck >/dev/null; then
step "dependency audit (govulncheck)" govulncheck ./...
else
skip "govulncheck" "install: go install golang.org/x/vuln/cmd/govulncheck@latest"
fi
else
skip "tests and govulncheck" "go not installed"
fi
fi
printf '\n'
if [ ${#failures[@]} -eq 0 ]; then
printf '\033[32mall checks passed\033[0m: ready to push.\n'
else
printf '\033[31mfailed:\033[0m %s\n' "${failures[*]}"
exit 1
fi