Skip to content
Snippets Groups Projects
Makefile 1.62 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
    
    
    # Tool Versions
    
    GOTESTSUM_VERSION=v1.8.1
    MOCKERY_VERSION=v2.20.0
    GOCOVER_COBERTURA=v1.2.0
    
    
    all: build
    
    install-tools:
    	@echo Install development tooling
    	mkdir -p $(GOSDN_PRG)
    
    	go install gotest.tools/gotestsum@$(GOTESTSUM_VERSION)
    	go install github.com/vektra/mockery/v2@$(MOCKERY_VERSION)
    
    	@echo Finished installing development tooling
    
    ci-install-tools:
    
    	go install gotest.tools/gotestsum@$(GOTESTSUM_VERSION)
    	go install github.com/boumenot/gocover-cobertura@$(GOCOVER_COBERTURA)
    
    
    build:
    	$(GOBUILD) -o $(BINARY_NAME) ./cmd/gosdn
    
    clean:
    	$(GOCLEAN)
    	rm -f $(BINARY_NAME)
    
    start: clean build
    
    	GOSDN_ADMIN_PASSWORD="admin" 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
    
    show-unit-test-coverage: unit-test
    	go tool cover -html=coverage.out
    
    
    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
    
    generate-mocks: install-tools
    	./$(TOOLS_DIR)/mockery --all --dir "./interfaces/"