<commit_before>include vpp.env

VERSION	?= $(shell git describe --always --tags --dirty)
COMMIT	?= $(shell git rev-parse HEAD)
DATE	:= $(shell date +'%Y-%m-%dT%H:%M%:z')

CNINFRA_CORE := github.com/ligato/vpp-agent/vendor/github.com/ligato/cn-infra/core
LDFLAGS	= -X $(CNINFRA_CORE).BuildVersion=$(VERSION) -X $(CNINFRA_CORE).CommitHash=$(COMMIT) -X $(CNINFRA_CORE).BuildDate=$(DATE)

ifeq ($(NOSTRIP),)
LDFLAGS += -w -s
endif

COVER_DIR ?= /tmp

# Build all
build: cmd examples

# Clean all
clean: clean-cmd clean-examples

# Install commands
install:
	@echo "=> installing commands"
	go install -v -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ./cmd/vpp-agent
	go install -v -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ./cmd/vpp-agent-ctl
	go install -v -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ./cmd/agentctl

# Build commands
cmd:
	@echo "=> building commands"
	cd cmd/vpp-agent 		&& go build -v -i -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}"
	cd cmd/vpp-agent-ctl	&& go build -v -i -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}"
	cd cmd/agentctl 		&& go build -v -i -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}"

# Clean commands
clean-cmd:
	@echo "=> cleaning binaries"
	rm -f ./cmd/vpp-agent/vpp-agent
	rm -f ./cmd/vpp-agent-ctl/vpp-agent-ctl
	rm -f ./cmd/agentctl/agentctl

# Build examples
examples:
	@echo "=> building examples"
	cd examples/govpp_call 		    	&& go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/idx_bd_cache 	    	&& go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/idx_iface_cache     	&& go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/idx_mapping_lookup  	&& go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/idx_mapping_watcher     && go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/localclient_linux/veth 	&& go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/localclient_linux/tap 	&& go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/localclient_vpp/plugins && go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/localclient_vpp/nat     && go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/grpc_vpp/remote_client  && go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/grpc_vpp/notifications  && go build -v -i -tags="${GO_BUILD_TAGS}"

# Clean examples
clean-examples:
	@echo "=> cleaning examples"
	rm -f examples/govpp_call/govpp_call
	rm -f examples/idx_bd_cache/idx_bd_cache
	rm -f examples/idx_iface_cache/idx_iface_cache
	rm -f examples/idx_mapping_lookup/idx_mapping_lookup
	rm -f examples/idx_mapping_watcher/idx_mapping_watcher
	rm -f examples/localclient_linux/veth/veth
	rm -f examples/localclient_linux/tap/tap
	rm -r examples/localclient_vpp/localclient_vpp

# Run tests
test:
	@echo "=> running unit tests"
	go test -tags="${GO_BUILD_TAGS}" ./...

# Get coverage report tools
get-covtools:
	go get -v github.com/wadey/gocovmerge

# Run coverage report
test-cover: get-covtools
	@echo "=> running unit tests with coverage"
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/scenario.cov 				./tests/go/itest
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/agentctl_utils.cov 		./cmd/agentctl/utils
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/govpp_vppcalls.cov			./plugins/govppmux/vppcalls
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/idxvpp_nametoidx.cov 		./idxvpp/nametoidx
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/vpp_aclplugin.cov			./plugins/vpp/aclplugin
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/vpp_aclplugin_vppcalls.cov	./plugins/vpp/aclplugin/vppcalls
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/vpp_aclplugin_vppdump.cov	./plugins/vpp/aclplugin/vppdump
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/vpp_ifplugin.cov 			./plugins/vpp/ifplugin
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/vpp_ifplugin_ifaceidx.cov 	./plugins/vpp/ifplugin/ifaceidx
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/vpp_ifplugin_vppcalls.cov 	./plugins/vpp/ifplugin/vppcalls
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/vpp_ifplugin_vppdump.cov 	./plugins/vpp/ifplugin/vppdump
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/vpp_l2plugin.cov 			./plugins/vpp/l2plugin
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/vpp_l2plugin_l2idx.cov 	./plugins/vpp/l2plugin/l2idx
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/vpp_l2plugin_vppcalls.cov 	./plugins/vpp/l2plugin/vppcalls
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/vpp_l2plugin_vppdump.cov 	./plugins/vpp/l2plugin/vppdump
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/vpp_rpc.cov 				./plugins/vpp/rpc
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/vpp_srplugin.cov 			./plugins/vpp/srplugin
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/vpp_srplugin_vppcalls.cov	./plugins/vpp/srplugin/vppcalls
	@echo "=> merging coverage results"
	gocovmerge \
			${COVER_DIR}/scenario.cov \
			${COVER_DIR}/agentctl_utils.cov \
			${COVER_DIR}/idxvpp_nametoidx.cov \
			${COVER_DIR}/govpp_vppcalls.cov \
			${COVER_DIR}/vpp_aclplugin.cov \
			${COVER_DIR}/vpp_aclplugin_vppcalls.cov \
			${COVER_DIR}/vpp_aclplugin_vppdump.cov \
			${COVER_DIR}/vpp_ifplugin.cov \
			${COVER_DIR}/vpp_ifplugin_ifaceidx.cov \
			${COVER_DIR}/vpp_ifplugin_vppcalls.cov \
			${COVER_DIR}/vpp_ifplugin_vppdump.cov \
			${COVER_DIR}/vpp_l2plugin.cov \
			${COVER_DIR}/vpp_l2plugin_l2idx.cov \
			${COVER_DIR}/vpp_l2plugin_vppcalls.cov \
			${COVER_DIR}/vpp_l2plugin_vppdump.cov \
			${COVER_DIR}/vpp_rpc.cov \
			${COVER_DIR}/vpp_srplugin.cov \
			${COVER_DIR}/vpp_srplugin_vppcalls.cov \
		> ${COVER_DIR}/coverage.out
	@echo "=> coverage data generated into ${COVER_DIR}/coverage.out"<commit_msg>Test all packages recursively with test-cover target<commit_after>include vpp.env

VERSION	?= $(shell git describe --always --tags --dirty)
COMMIT	?= $(shell git rev-parse HEAD)
DATE	:= $(shell date +'%Y-%m-%dT%H:%M%:z')

CNINFRA_CORE := github.com/ligato/vpp-agent/vendor/github.com/ligato/cn-infra/core
LDFLAGS	= -X $(CNINFRA_CORE).BuildVersion=$(VERSION) -X $(CNINFRA_CORE).CommitHash=$(COMMIT) -X $(CNINFRA_CORE).BuildDate=$(DATE)

ifeq ($(NOSTRIP),)
LDFLAGS += -w -s
endif

COVER_DIR ?= /tmp

# Build all
build: cmd examples

# Clean all
clean: clean-cmd clean-examples

# Install commands
install:
	@echo "=> installing commands"
	go install -v -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ./cmd/vpp-agent
	go install -v -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ./cmd/vpp-agent-ctl
	go install -v -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ./cmd/agentctl

# Build commands
cmd:
	@echo "=> building commands"
	cd cmd/vpp-agent 		&& go build -v -i -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}"
	cd cmd/vpp-agent-ctl	&& go build -v -i -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}"
	cd cmd/agentctl 		&& go build -v -i -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}"

# Clean commands
clean-cmd:
	@echo "=> cleaning binaries"
	rm -f ./cmd/vpp-agent/vpp-agent
	rm -f ./cmd/vpp-agent-ctl/vpp-agent-ctl
	rm -f ./cmd/agentctl/agentctl

# Build examples
examples:
	@echo "=> building examples"
	cd examples/govpp_call 		    	&& go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/idx_bd_cache 	    	&& go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/idx_iface_cache     	&& go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/idx_mapping_lookup  	&& go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/idx_mapping_watcher     && go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/localclient_linux/veth 	&& go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/localclient_linux/tap 	&& go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/localclient_vpp/plugins && go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/localclient_vpp/nat     && go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/grpc_vpp/remote_client  && go build -v -i -tags="${GO_BUILD_TAGS}"
	cd examples/grpc_vpp/notifications  && go build -v -i -tags="${GO_BUILD_TAGS}"

# Clean examples
clean-examples:
	@echo "=> cleaning examples"
	rm -f examples/govpp_call/govpp_call
	rm -f examples/idx_bd_cache/idx_bd_cache
	rm -f examples/idx_iface_cache/idx_iface_cache
	rm -f examples/idx_mapping_lookup/idx_mapping_lookup
	rm -f examples/idx_mapping_watcher/idx_mapping_watcher
	rm -f examples/localclient_linux/veth/veth
	rm -f examples/localclient_linux/tap/tap
	rm -r examples/localclient_vpp/localclient_vpp

# Run tests
test:
	@echo "=> running unit tests"
	go test -tags="${GO_BUILD_TAGS}" ./...

# Get coverage report tools
get-covtools:
	go get -v github.com/wadey/gocovmerge

# Run coverage report
test-cover: get-covtools
	@echo "=> running unit tests with coverage"
	go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/coverage.out ./...
	@echo "=> coverage data generated into ${COVER_DIR}/coverage.out"
{'fraction_non_alphanumeric': 0.15895765472312703, 'fraction_numerical': 0.0016286644951140066, 'mean_word_length': 4.502389486260454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3531515', 'n_tokens_mistral': 3612, 'n_tokens_neox': 3556, 'n_words': 680}