...

Text file src/github.com/spf13/viper/Makefile

Documentation: github.com/spf13/viper

     1# A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
     2
     3OS = $(shell uname | tr A-Z a-z)
     4export PATH := $(abspath bin/):${PATH}
     5
     6# Build variables
     7BUILD_DIR ?= build
     8export CGO_ENABLED ?= 0
     9export GOOS = $(shell go env GOOS)
    10ifeq (${VERBOSE}, 1)
    11ifeq ($(filter -v,${GOARGS}),)
    12	GOARGS += -v
    13endif
    14TEST_FORMAT = short-verbose
    15endif
    16
    17# Dependency versions
    18GOTESTSUM_VERSION = 1.9.0
    19GOLANGCI_VERSION = 1.53.3
    20
    21# Add the ability to override some variables
    22# Use with care
    23-include override.mk
    24
    25.PHONY: clear
    26clear: ## Clear the working area and the project
    27	rm -rf bin/
    28
    29.PHONY: check
    30check: test lint ## Run tests and linters
    31
    32
    33TEST_PKGS ?= ./...
    34.PHONY: test
    35test: TEST_FORMAT ?= short
    36test: SHELL = /bin/bash
    37test: export CGO_ENABLED=1
    38test: bin/gotestsum ## Run tests
    39	@mkdir -p ${BUILD_DIR}
    40	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},./...)
    41
    42.PHONY: lint
    43lint: lint-go lint-yaml
    44lint: ## Run linters
    45
    46.PHONY: lint-go
    47lint-go:
    48	golangci-lint run $(if ${CI},--out-format github-actions,)
    49
    50.PHONY: lint-yaml
    51lint-yaml:
    52	yamllint $(if ${CI},-f github,) --no-warnings .
    53
    54.PHONY: fmt
    55fmt: ## Format code
    56	golangci-lint run --fix
    57
    58deps: bin/golangci-lint bin/gotestsum yamllint
    59deps: ## Install dependencies
    60
    61bin/gotestsum:
    62	@mkdir -p bin
    63	curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_${OS}_amd64.tar.gz | tar -zOxf - gotestsum > ./bin/gotestsum && chmod +x ./bin/gotestsum
    64
    65bin/golangci-lint:
    66	@mkdir -p bin
    67	curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- v${GOLANGCI_VERSION}
    68
    69.PHONY: yamllint
    70yamllint:
    71	pip3 install --user yamllint
    72
    73# Add custom targets here
    74-include custom.mk
    75
    76.PHONY: list
    77list: ## List all make targets
    78	@${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
    79
    80.PHONY: help
    81.DEFAULT_GOAL := help
    82help:
    83	@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
    84
    85# Variable outputting/exporting rules
    86var-%: ; @echo $($*)
    87varexport-%: ; @echo $*=$($*)

View as plain text