download-third-party:
	rm -rf ./grpc/third_party
	mkdir -p ./grpc/third_party
	cd ./grpc/third_party && git clone https://github.com/googleapis/googleapis.git
	mv ./grpc/third_party/googleapis/google ./grpc
	mv ./grpc/third_party/googleapis/grafeas ./grpc
	rm -rf ./grpc/third_party

gen-proto:
	mkdir -p ./grpc

	@protoc -I ./grpc \
			--go_out=grpc --go_opt paths=source_relative \
			--go-grpc_out=grpc --go-grpc_opt paths=source_relative \
			--grpc-gateway_out=grpc --grpc-gateway_opt paths=source_relative \
			./grpc/snapshot.proto

# Запуск всех тестов
test:
	go test -v ./...

# Запуск модульных тестов
test-unit:
	go test -v ./store/... ./hash/... ./archive/...

# Запуск интеграционных тестов
test-integration:
	go test -v -tags=integration ./...

# Запуск функциональных тестов
test-functional:
	go test -v -run TestFull ./...

# Запуск тестов производительности
test-performance:
	go test -v -run TestPerformanceMetrics ./...
	go test -v -bench=. ./...

# Запуск тестов с покрытием кода
test-coverage:
	go test -v -coverprofile=coverage.out ./...
	go tool cover -html=coverage.out -o coverage.html

# Запуск линтера
lint:
	golangci-lint run

# Запуск всех проверок (тесты + линтер)
check: test lint

.PHONY: download-third-party gen-proto test test-unit test-integration test-functional test-performance test-coverage lint check