#!/bin/sh
# The build gate from CLAUDE.md — "go build ./..., go vet ./..., go test
# ./... -count=1 — all clean, every package, before any commit lands" —
# as amadan CI runs it.
#
# THIS IS THE GATE. Not a second home for one, not a copy kept beside a
# more authoritative run somewhere else: the definition of green for this
# repo is what these three steps say it is.
#
# It did not start that way, and the change is recent enough to be worth
# writing down. Until 2026-08-24 the authority was
# .github/workflows/ci.yml, and this file said so in as many words —
# where the two disagreed, the workflow won and the difference was a bug
# here. That workflow has been deleted. Two things made it safe to
# delete, and they arrived together:
#
#   1. This directory caught up, and then went past it. `10-gate`,
#      `20-cross@5` and `30-minio-contract` cover every job the workflow
#      ran — build/vet/test, all five cross-compile targets, the live
#      MinIO contract — and the gofmt check here is STRICTER: `make
#      test` runs `gofmt -l .` over the whole tree, where the workflow
#      only ever checked the files a PR happened to touch. There is no
#      direction in which the deleted file was the tighter gate.
#
#   2. It had stopped running anyway. GitHub Actions on the
#      carlosframework account has been refusing to start jobs over
#      billing, so the "required check" was gating nothing well before
#      anyone removed it — which is the worse of the two failure modes,
#      because a gate that is merely absent is at least honest about it.
#
# So: a red step here is not a discrepancy to reconcile against a more
# official run. It is the answer, and nothing behind it is going to catch
# what it misses. Keep it true.
#
# One definition, not two. Everything past the build is `make test` — the
# same target a maintainer runs on a laptop — so CI and the local gate
# cannot drift apart, and a check added to one is a check added to both.
# That is how the gofmt check gets here at all: `make test` runs vet, a
# repo-wide `gofmt -l .` and the tests (side by side, through
# .amadan/test-gate.sh), and this file no longer restates any of it.
#
# `go build ./...` stays spelled out because `make test` does not do it.
#
# -count=1 and -timeout 30m live in .amadan/test-gate.sh, on each go test
# line, with the Makefile's note on why; they are still in force here,
# just not written down twice.
set -eu

# The build runs beside the tests rather than before them: neither needs
# the other, and the gate's wall clock is whichever finishes last.
go build ./... &
build=$!
status=0
make test || status=$?
wait "$build" || status=1
exit "$status"
