forked from greenpau/caddy-security
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
138 lines (124 loc) · 5.05 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
PLUGIN_NAME="caddy-security"
PLUGIN_VERSION:=$(shell cat VERSION | head -1)
GIT_COMMIT:=$(shell git describe --dirty --always)
GIT_BRANCH:=$(shell git rev-parse --abbrev-ref HEAD -- | head -1)
LATEST_GIT_COMMIT:=$(shell git log --format="%H" -n 1 | head -1)
BUILD_USER:=$(shell whoami)
BUILD_DATE:=$(shell date +"%Y-%m-%d")
BUILD_DIR:=$(shell pwd)
CADDY_VERSION="v2.7.4"
all: info
@mkdir -p bin/
@rm -rf ./bin/authp
@#rm -rf ../xcaddy-$(PLUGIN_NAME)/*
@#mkdir -p ../xcaddy-$(PLUGIN_NAME) && cd ../xcaddy-$(PLUGIN_NAME) &&
@# xcaddy build $(CADDY_VERSION) --output ../$(PLUGIN_NAME)/bin/caddy
@# --with github.com/greenpau/caddy-security@$(LATEST_GIT_COMMIT)=$(BUILD_DIR)
@# --with github.com/greenpau/caddy-trace@latest
@#--with github.com/greenpau/[email protected]=/home/greenpau/dev/go/src/github.com/greenpau/go-authcrunch
@go build -v -o ./bin/authp cmd/authp/main.go
@./bin/authp version
@#bin/caddy run -config assets/config/Caddyfile
@for f in `find ./assets -type f -name 'Caddyfile'`; do bin/authp fmt --overwrite $$f; done
.PHONY: info
info:
@echo "DEBUG: Version: $(PLUGIN_VERSION), Branch: $(GIT_BRANCH), Revision: $(GIT_COMMIT)"
@echo "DEBUG: Build on $(BUILD_DATE) by $(BUILD_USER)"
.PHONY: linter
linter:
@echo "DEBUG: started $@"
@#golint -set_exit_status ./...
@echo "DEBUG: completed $@"
.PHONY: test
test: covdir linter
@echo "DEBUG: started $@"
@go test -v -coverprofile=.coverage/coverage.out ./...
@echo "DEBUG: completed $@"
.PHONY: ctest
ctest: covdir linter
@echo "DEBUG: started $@"
@#time richgo test -v -coverprofile=.coverage/coverage.out ./...
@time richgo test -v -coverprofile=.coverage/coverage.out ./*.go
@echo "DEBUG: completed $@"
.PHONY: covdir
covdir:
@echo "DEBUG: started $@"
@mkdir -p .coverage
@echo "DEBUG: completed $@"
.PHONY: bindir
bindir:
@echo "DEBUG: started $@"
@mkdir -p bin/
@echo "DEBUG: completed $@"
.PHONY: coverage
coverage: covdir
@echo "DEBUG: started $@"
@go tool cover -html=.coverage/coverage.out -o .coverage/coverage.html
@go test -covermode=count -coverprofile=.coverage/coverage.out ./...
@go tool cover -func=.coverage/coverage.out | grep -v "100.0"
@echo "DEBUG: completed $@"
.PHONY: clean
clean:
@echo "DEBUG: started $@"
@rm -rf .coverage/
@rm -rf bin/
@echo "DEBUG: completed $@"
.PHONY: qtest
qtest: covdir
@echo "DEBUG: started $@"
@#time richgo test -v -coverprofile=.coverage/coverage.out -run TestApp ./*.go
@#time richgo test -v -coverprofile=.coverage/coverage.out -run TestParseCaddyfileAppConfig ./*.go
@#time richgo test -v -coverprofile=.coverage/coverage.out -run TestParseCaddyfileIdentity ./*.go
@time richgo test -v -coverprofile=.coverage/coverage.out -run TestParseCaddyfileSingleSignOnProvider ./*.go
@#time richgo test -v -coverprofile=.coverage/coverage.out -run TestParseCaddyfileCredentials ./*.go
@#time richgo test -v -coverprofile=.coverage/coverage.out -run TestParseCaddyfileMessaging ./*.go
@#time richgo test -v -coverprofile=.coverage/coverage.out -run TestParseCaddyfileIdentit* ./*.go
@#time richgo test -v -coverprofile=.coverage/coverage.out -run TestParseCaddyfileAuthentication ./*.go
@#time richgo test -v -coverprofile=.coverage/coverage.out -run TestParseCaddyfileAuthorization ./*.go
@#go test -v -coverprofile=.coverage/coverage.out -run TestParseCaddyfile ./*.go
@#go test -v -coverprofile=.coverage/coverage.out -run Test* ./pkg/services/...
@go tool cover -html=.coverage/coverage.out -o .coverage/coverage.html
@go tool cover -func=.coverage/coverage.out | grep -v "100.0"
@echo "DEBUG: completed $@"
.PHONY: dep
dep:
@echo "DEBUG: started $@"
@go install golang.org/x/lint/golint@latest
@go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
@go install github.com/goreleaser/goreleaser@latest
@go install github.com/greenpau/versioned/cmd/versioned@latest
@go install github.com/kyoh86/richgo@latest
@echo "DEBUG: completed $@"
.PHONY: release
release:
@echo "Making release"
@go mod tidy
@go mod verify
@if [ $(GIT_BRANCH) != "main" ]; then echo "cannot release to non-main branch $(GIT_BRANCH)" && false; fi
@git diff-index --quiet HEAD -- || ( echo "git directory is dirty, commit changes first" && false )
@versioned -patch
@echo "Patched version"
@assets/scripts/generate_downloads.sh
@git add VERSION README.md
@git commit -m "released v`cat VERSION | head -1`"
@git tag -a v`cat VERSION | head -1` -m "v`cat VERSION | head -1`"
@git push
@git push --tags
@@echo "If necessary, run the following commands:"
@echo " git push --delete origin v$(PLUGIN_VERSION)"
@echo " git tag --delete v$(PLUGIN_VERSION)"
@echo "DEBUG: completed $@"
.PHONY: logo
logo:
@mkdir -p assets/docs/images
@gm convert -background black -font Bookman-Demi \
-size 640x320 "xc:black" \
-pointsize 72 \
-draw "fill white gravity center text 0,0 'caddy\nsecurity'" \
assets/docs/images/logo.png
@echo "DEBUG: completed $@"
.PHONY: license
license:
@for f in `find ./ -type f -name '*.go'`; do versioned -addlicense -copyright="Paul Greenberg [email protected]" -year=2022 -filepath=$$f; done
@assets/scripts/generate_downloads.sh
@echo "DEBUG: completed $@"