Skip to content
Snippets Groups Projects
Makefile 2.15 KiB
Newer Older
  • Learn to ignore specific revisions
  • MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
    MAKEFILE_DIR  := $(dir $(MAKEFILE_PATH))
    
    GOSDN_PRG := $(MAKEFILE_DIR)$(TOOLS_DIR)
    GOBIN := $(GOSDN_PRG)
    
    GOCMD=go
    GOBUILD=$(GOCMD) build
    GOCLEAN=$(GOCMD) clean
    BINARY_NAME=gosdn
    
    all: build
    
    install-tools:
    	@echo Install development tooling
    	mkdir -p $(GOSDN_PRG)
    	go install gotest.tools/gotestsum@v1.7.0
    
    	go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2
    
    	go install github.com/vektra/mockery/v2@v2.14.0
    
    	@echo Finished installing development tooling
    
    ci-install-tools:
    	go install gotest.tools/gotestsum@v1.7.0
    
    	go install github.com/boumenot/gocover-cobertura@v1.2.0
    
    
    build:
    	$(GOBUILD) -o $(BINARY_NAME) ./cmd/gosdn
    
    clean:
    	$(GOCLEAN)
    	rm -f $(BINARY_NAME)
    
    start: clean build
    
    	ENVIRONMENT=development ./$(BINARY_NAME) -l debug
    
    start-insecure: clean build
    
    	ENVIRONMENT=development ./$(BINARY_NAME) -l debug -s insecure
    
    unit-test: install-tools
    
    	ENVIRONMENT=testing ./$(TOOLS_DIR)/gotestsum --junitfile report.xml --format testname -- -short -race $$( go list ./... | grep -v /forks/ | grep -v /mocks ) -v -trimpath -coverprofile=coverage.out
    
    
    controller-test: install-tools
    
    	ENVIRONMENT=testing ./$(TOOLS_DIR)/gotestsum --junitfile report.xml --format testname -- -race -v -run TestRun
    
    
    ci-unit-test: ci-install-tools
    
    	ENVIRONMENT=testing gotestsum --junitfile report.xml --format testname -- -short -race $$( go list ./... | grep -v /forks/ | grep -v /mocks ) -v -trimpath -coverprofile=coverage.out -covermode atomic -timeout 30m
    
    
    ci-controller-test: ci-install-tools
    
    	ENVIRONMENT=testing gotestsum --junitfile report.xml --format testname -- -race -v -run TestRun -trimpath -coverprofile=coverage.out
    
    
    integration-test-nucleus:
    
    	ENVIRONMENT=testing  &&\
    
    	cd ./test/integration &&\
    	go test -race -v -run TestGnmi_SetIntegration &&\
    	go test -race -v -run TestGnmi_GetIntegration &&\
    	go test -race -v -run TestGnmi_SubscribeIntegration &&\
    	go test -race -v -run TestGnmi_CapabilitiesIntegration
    
    integration-test-api:
    
    	ENVIRONMENT=testing  &&\
    
    	cd ./api &&\
    	go test -race -v -run TestApiIntegration
    
    
    generate-mocks: install-tools
    	./$(TOOLS_DIR)/mockery --all --dir "./interfaces/"