gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

Makefile (2516B)


      1 # A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
      2 
      3 OS = $(shell uname | tr A-Z a-z)
      4 export PATH := $(abspath bin/):${PATH}
      5 
      6 # Build variables
      7 BUILD_DIR ?= build
      8 export CGO_ENABLED ?= 0
      9 export GOOS = $(shell go env GOOS)
     10 ifeq (${VERBOSE}, 1)
     11 ifeq ($(filter -v,${GOARGS}),)
     12 	GOARGS += -v
     13 endif
     14 TEST_FORMAT = short-verbose
     15 endif
     16 
     17 # Dependency versions
     18 GOTESTSUM_VERSION = 1.9.0
     19 GOLANGCI_VERSION = 1.52.2
     20 
     21 # Add the ability to override some variables
     22 # Use with care
     23 -include override.mk
     24 
     25 .PHONY: clear
     26 clear: ## Clear the working area and the project
     27 	rm -rf bin/
     28 
     29 .PHONY: check
     30 check: test lint ## Run tests and linters
     31 
     32 bin/gotestsum: bin/gotestsum-${GOTESTSUM_VERSION}
     33 	@ln -sf gotestsum-${GOTESTSUM_VERSION} bin/gotestsum
     34 bin/gotestsum-${GOTESTSUM_VERSION}:
     35 	@mkdir -p bin
     36 	curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_${OS}_amd64.tar.gz | tar -zOxf - gotestsum > ./bin/gotestsum-${GOTESTSUM_VERSION} && chmod +x ./bin/gotestsum-${GOTESTSUM_VERSION}
     37 
     38 TEST_PKGS ?= ./...
     39 .PHONY: test
     40 test: TEST_FORMAT ?= short
     41 test: SHELL = /bin/bash
     42 test: export CGO_ENABLED=1
     43 test: bin/gotestsum ## Run tests
     44 	@mkdir -p ${BUILD_DIR}
     45 	bin/gotestsum --no-summary=skipped --junitfile ${BUILD_DIR}/coverage.xml --format ${TEST_FORMAT} -- -race -coverprofile=${BUILD_DIR}/coverage.txt -covermode=atomic $(filter-out -v,${GOARGS}) $(if ${TEST_PKGS},${TEST_PKGS},./...)
     46 
     47 bin/golangci-lint: bin/golangci-lint-${GOLANGCI_VERSION}
     48 	@ln -sf golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint
     49 bin/golangci-lint-${GOLANGCI_VERSION}:
     50 	@mkdir -p bin
     51 	curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b ./bin/ v${GOLANGCI_VERSION}
     52 	@mv bin/golangci-lint "$@"
     53 
     54 .PHONY: lint
     55 lint: bin/golangci-lint ## Run linter
     56 	bin/golangci-lint run
     57 
     58 .PHONY: fix
     59 fix: bin/golangci-lint ## Fix lint violations
     60 	bin/golangci-lint run --fix
     61 
     62 # Add custom targets here
     63 -include custom.mk
     64 
     65 .PHONY: list
     66 list: ## List all make targets
     67 	@${MAKE} -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sort
     68 
     69 .PHONY: help
     70 .DEFAULT_GOAL := help
     71 help:
     72 	@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
     73 
     74 # Variable outputting/exporting rules
     75 var-%: ; @echo $($*)
     76 varexport-%: ; @echo $*=$($*)