VERSION=$(shell git describe --tags --always)

.PHONY: build
# build
build:
	mkdir -p bin/ && go build -ldflags \
    		  "-X github.com/chainloop-dev/chainloop/app/cli/cmd.Version=$(VERSION)" \
    		  -o ./bin/chainloop ./main.go

.PHONY: test
# test
test:
	go test ./...

.PHONY: test-trace-e2e
# run the Chainloop Trace end-to-end suite with real agents and models (uses model tokens)
test-trace-e2e:
	go test -tags e2e -run TestTraceMatrix -timeout 60m -v ./internal/trace/e2e/

.PHONY: lint
# lint
lint:
	golangci-lint run

# show help
help:
	@echo ''
	@echo 'Usage:'
	@echo ' make [target]'
	@echo ''
	@echo 'Targets:'
	@awk '/^[a-zA-Z\-_0-9]+:/ { \
	helpMessage = match(lastLine, /^# (.*)/); \
		if (helpMessage) { \
			helpCommand = substr($$1, 0, index($$1, ":")-1); \
			helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
			printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \
		} \
	} \
	{ lastLine = $$0 }' $(MAKEFILE_LIST)

.DEFAULT_GOAL := help