.PHONY: dev run build test test-integration lint tidy clean

export PATH := /opt/homebrew/bin:/usr/local/go/bin:$(HOME)/go/bin:/usr/local/bin:$(PATH)

SERVICE_NAME := code-parser-service
BINARY := bin/$(SERVICE_NAME)
MAIN := ./cmd/server

dev:
	ENVIRONMENT=local LOG_LEVEL=debug PORT=6002 go run $(MAIN)

run: build
	PORT=6002 ./$(BINARY)

build:
	@mkdir -p bin
	go build -o $(BINARY) $(MAIN)

test:
	go test ./...

test-integration:
	go test -tags=integration ./...

lint:
	@if command -v golangci-lint >/dev/null 2>&1; then \
		golangci-lint run ./...; \
	else \
		echo "golangci-lint not installed; skipping"; \
	fi

tidy:
	go mod tidy

clean:
	rm -rf bin
