forked from jkroepke/openvpn-auth-oauth2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (67 loc) · 1.96 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
##
# Console Colors
##
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
##
# Targets
##
.PHONY: help
help: ## show this help.
@echo 'Usage:'
@echo ' ${GREEN}make${RESET} ${YELLOW}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${GREEN}%-21s${YELLOW}%s${RESET}\n", $$1, $$2} \
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
}' $(MAKEFILE_LIST) | sort
.PHONY: clean
clean: ## clean builds dir
@rm -rf openvpn-auth-oauth2 openvpn-auth-oauth2.exe dist/
.PHONY: check
check: test lint golangci ## Run all checks locally
.PHONY: build
ifeq ($(OS),Windows_NT)
build: clean openvpn-auth-oauth2.exe ## Build openvpn-auth-oauth2
else
build: clean openvpn-auth-oauth2
endif
openvpn-auth-oauth2:
@go build -o openvpn-auth-oauth2 .
openvpn-auth-oauth2.exe:
@go build -o openvpn-auth-oauth2.exe .
.Phony: build-debug
build-debug: ## Build openvpn-auth-oauth2 with debug flags
@go build -gcflags="-l=4 -m=2" -o openvpn-auth-oauth2 .
.PHONY: test
test: ## Test openvpn-auth-oauth2
@go test -race ./...
.PHONY: lint
lint: golangci ## Run linter
.PHONY: format
format: fmt goimports gofumpt gowsl goperfsprint golangci-fix ## Format source code
.PHONY: fmt
fmt:
@go fmt ./...
.PHONY: gofumpt
gofumpt:
@go run mvdan.cc/gofumpt@latest -l -w .
.PHONY: goimports
goimports:
@go run golang.org/x/tools/cmd/goimports@latest -l -w .
.PHONY: gowsl
gowsl:
@go run github.com/bombsimon/wsl/v4/cmd...@latest -test=false -fix ./...
.PHONY: goperfsprint
goperfsprint:
@go run github.com/catenacyber/perfsprint@latest -fix ./...
.PHONY: golangci
golangci:
@go run github.com/golangci/golangci-lint/cmd/[email protected] run ./...
.PHONY: golangci-fix
golangci-fix:
@go run github.com/golangci/golangci-lint/cmd/[email protected] run ./... --fix