...

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

Documentation: github.com/ory/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 = 0.4.0
    19GOLANGCI_VERSION = 1.21.0
    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
    32bin/gotestsum: bin/gotestsum-${GOTESTSUM_VERSION}
    33	@ln -sf gotestsum-${GOTESTSUM_VERSION} bin/gotestsum
    34bin/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
    38TEST_PKGS ?= ./...
    39.PHONY: test
    40test: TEST_FORMAT ?= short
    41test: SHELL = /bin/bash
    42test: export CGO_ENABLED=1
    43test: 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
    47bin/golangci-lint: bin/golangci-lint-${GOLANGCI_VERSION}
    48	@ln -sf golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint
    49bin/golangci-lint-${GOLANGCI_VERSION}:
    50	@mkdir -p bin
    51	curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ./bin/ v${GOLANGCI_VERSION}
    52	@mv bin/golangci-lint $@
    53
    54.PHONY: lint
    55lint: bin/golangci-lint ## Run linter
    56	bin/golangci-lint run
    57
    58.PHONY: fix
    59fix: 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
    66list: ## 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
    71help:
    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
    75var-%: ; @echo $($*)
    76varexport-%: ; @echo $*=$($*)

View as plain text