github.com/oNaiPs/go-generate-fast@v0.3.0/Makefile (about)

     1  # Variables
     2  GO := go
     3  SRC_DIR := src
     4  OUT_DIR := bin
     5  TARGET := $(OUT_DIR)/go-generate-fast
     6  
     7  # List of all Go source files
     8  SOURCES := main.go $(shell find $(SRC_DIR) -name "*.go")
     9  
    10  BUILD_TAGS :=
    11  TEST_TAGS := test
    12  
    13  # By default, commands are not printed, unless you pass V=1
    14  ifndef V
    15  .SILENT:
    16  endif
    17  
    18  GO_DEPS=$(shell go list -e -f '{{join .Imports " "}}' tools.go)
    19  
    20  install-deps: ## Installs dependencies
    21  	echo "Installing dependencies"
    22  	go install $(GO_DEPS)
    23  
    24  build: $(TARGET) ## Build project
    25  
    26  $(TARGET): $(SOURCES)
    27  	mkdir -p $(OUT_DIR)
    28  	echo "Building..."
    29  	$(GO) build -o $(TARGET) --tags=$(BUILD_TAGS)
    30  	echo "Build complete. Output: $(TARGET)"
    31  
    32  test: ## Run tests
    33  	echo "Running unit tests..."
    34  	gotestsum --raw-command -- $(GO) -C $(SRC_DIR) test --tags=$(TEST_TAGS) -json -cover ./...
    35  
    36  lint: ## Lints files
    37  	echo "Linting..."
    38  	golangci-lint run
    39  lint-fix: ## Lints files, and fixes ones that are fixable 
    40  	echo "Linting and fixing..."
    41  	golangci-lint run --fix
    42  
    43  e2e: $(if $(CI),,build) ## Runs e2e tests
    44  	echo "Running e2e tests..."
    45  	e2e/run.sh
    46  
    47  clean: ## Cleans build files
    48  	rm -rfv $(OUT_DIR)
    49  	echo Done.
    50  
    51  .PHONY: build clean test e2e help
    52  
    53  .DEFAULT_GOAL := help
    54  
    55  help:
    56  	@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
    57