-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
104 lines (81 loc) · 2.4 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
##
# 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)
# renovate: github=golangci/golangci-lint
GO_LINT_CI_VERSION := v1.59.0
##
# 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: update
update: ## Run dependency updates
@go get -u ./...
@go mod tidy
@cd pkg/plugin && go mod tidy
@go work sync
.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 gogci gofumpt gowsl goperfsprint golangci-fix ## Format source code
.PHONY: fmt
fmt:
@go fmt ./...
.PHONY: gogci
gogci:
@-go run github.com/daixiang0/gci@latest write .
.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 -strict-append -test=true -fix ./...
.PHONY: goperfsprint
goperfsprint:
@-go run github.com/catenacyber/perfsprint@latest -fix ./...
.PHONY: golangci
golangci:
@go run github.com/golangci/golangci-lint/cmd/golangci-lint@${GO_LINT_CI_VERSION} run ./...
.PHONY: golangci-fix
golangci-fix:
@go run github.com/golangci/golangci-lint/cmd/golangci-lint@${GO_LINT_CI_VERSION} run ./... --fix
.PHONY: 3rdpartylicenses
3rdpartylicenses:
@go run github.com/google/go-licenses@latest save . --save_path=3rdpartylicenses