.PHONY: fmt test test-race vet build security release mq-integration-local proto-lint proto-generate proto-check contract-check acceptance-local check

GO ?= go
BINARY ?= dist/sip-go-agent

fmt:
	find contracts internal cmd -name '*.go' -print0 | xargs -0 gofmt -w

test:
	$(GO) test ./...

test-race:
	$(GO) test -race ./...

vet:
	$(GO) vet ./...

security:
	@command -v govulncheck >/dev/null || { echo "govulncheck is required for the security target" >&2; exit 1; }
	govulncheck ./...

build:
	mkdir -p $(dir $(BINARY))
	$(GO) build -trimpath -buildvcs=false -o $(BINARY) ./cmd/sip-go-agent

release:
	./scripts/build-release.sh $(RELEASE_DIR)

mq-integration-local:
	./scripts/mq-integration-local.sh

proto-lint:
	buf lint

proto-generate:
	buf generate

proto-check:
	./scripts/check-proto.sh

contract-check:
	./scripts/check-contracts.sh

acceptance-local:
	./scripts/acceptance-local.sh

check: fmt proto-check acceptance-local
