-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
187 lines (147 loc) · 7.16 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
DIST ?= development
CLI = ./bin/uhppoted-app-wild-apricot
WORKDIR = ../runtime/wild-apricot
CREDENTIALS = $(WORKDIR)/.credentials.json
RULES = $(WORKDIR)/debug.grl
# RULES = $(WORKDIR)/wild-apricot.grl
RULES_WITH_PIN = $(WORKDIR)/wild-apricot-with-pin.grl
DATETIME = $(shell date "+%Y-%m-%d %H:%M:%S")
DEBUG ?= --debug
.PHONY: clean
.PHONY: bump
.PHONY: bump-release
all: test \
benchmark \
coverage
clean:
go clean
rm -rf bin
update:
go get -u github.com/uhppoted/uhppote-core@main
go get -u github.com/uhppoted/uhppoted-lib@main
go get -u github.com/hyperjumptech/grule-rule-engine
go get -u golang.org/x/sys
go mod tidy
update-release:
go get -u github.com/uhppoted/uhppote-core
go get -u github.com/uhppoted/uhppoted-lib
go mod tidy
update-all:
go get -u github.com/uhppoted/uhppote-core
go get -u github.com/uhppoted/uhppoted-lib
go get -u github.com/hyperjumptech/grule-rule-engine
go get -u golang.org/x/sys
go mod tidy
format:
go fmt ./...
build: format
mkdir -p bin
go build -trimpath -o bin ./...
test: build
go test ./...
benchmark: build
go test -bench ./...
coverage: build
go test -cover ./...
vet: build
go vet ./...
lint: build
env GOOS=darwin GOARCH=amd64 staticcheck ./...
env GOOS=linux GOARCH=amd64 staticcheck ./...
env GOOS=windows GOARCH=amd64 staticcheck ./...
vuln:
govulncheck ./...
build-all: build test vet lint
mkdir -p dist/$(DIST)/linux
mkdir -p dist/$(DIST)/arm
mkdir -p dist/$(DIST)/arm7
mkdir -p dist/$(DIST)/darwin-x64
mkdir -p dist/$(DIST)/darwin-arm64
mkdir -p dist/$(DIST)/windows
env GOOS=linux GOARCH=amd64 GOWORK=off go build -trimpath -o dist/$(DIST)/linux ./...
env GOOS=linux GOARCH=arm64 GOWORK=off go build -trimpath -o dist/$(DIST)/arm ./...
env GOOS=linux GOARCH=arm GOARM=7 GOWORK=off go build -trimpath -o dist/$(DIST)/arm7 ./...
env GOOS=darwin GOARCH=amd64 GOWORK=off go build -trimpath -o dist/$(DIST)/darwin-x64 ./...
env GOOS=darwin GOARCH=arm64 GOWORK=off go build -trimpath -o dist/$(DIST)/darwin-arm64 ./...
env GOOS=windows GOARCH=amd64 GOWORK=off go build -trimpath -o dist/$(DIST)/windows ./...
release: update-release build-all
find . -name ".DS_Store" -delete
tar --directory=dist/$(DIST)/linux --exclude=".DS_Store" -cvzf dist/$(DIST)-linux-x64.tar.gz .
tar --directory=dist/$(DIST)/arm --exclude=".DS_Store" -cvzf dist/$(DIST)-arm-x64.tar.gz .
tar --directory=dist/$(DIST)/arm7 --exclude=".DS_Store" -cvzf dist/$(DIST)-arm7.tar.gz .
tar --directory=dist/$(DIST)/darwin-x64 --exclude=".DS_Store" -cvzf dist/$(DIST)-darwin-x64.tar.gz .
tar --directory=dist/$(DIST)/darwin-arm64 --exclude=".DS_Store" -cvzf dist/$(DIST)-darwin-arm64.tar.gz .
cd dist/$(DIST)/windows && zip --recurse-paths ../../$(DIST)-windows-x64.zip . -x ".DS_Store"
publish: release
echo "Releasing version $(VERSION)"
gh release create "$(VERSION)" "./dist/$(DIST)-arm-x64.tar.gz" \
"./dist/$(DIST)-arm7.tar.gz" \
"./dist/$(DIST)-darwin-arm64.tar.gz" \
"./dist/$(DIST)-darwin-x64.tar.gz" \
"./dist/$(DIST)-linux-x64.tar.gz" \
"./dist/$(DIST)-windows-x64.zip" \
--draft --prerelease --title "$(VERSION)-beta" --notes-file release-notes.md
debug: build
$(CLI) load-acl --credentials $(CREDENTIALS) --rules $(RULES) --dry-run --lockfile ".lock.me"
# $(CLI) load-acl --credentials $(CREDENTIALS) --rules $(RULES) --force --dry-run
# $(CLI) load-acl --credentials $(CREDENTIALS) --rules $(RULES) --force
godoc:
godoc -http=:80 -index_interval=60s
# GENERAL COMMANDS
usage: build
$(CLI)
help: build
$(CLI) help
version: build
$(CLI) version
# ACL COMMANDS
get-members: build
$(CLI) --debug --config ../runtime/wild-apricot/uhppoted.conf get-members --credentials $(CREDENTIALS)
# $(CLI) --debug get-members --credentials $(CREDENTIALS) --file "$(WORKDIR)/members.tsv"
# cat "$(WORKDIR)/members.tsv"
get-members-with-pin: build
$(CLI) get-members --credentials $(CREDENTIALS) --with-pin
$(CLI) get-members --credentials $(CREDENTIALS) --with-pin --file "$(WORKDIR)/members.tsv"
cat "$(WORKDIR)/members.tsv"
get-groups: build
$(CLI) --debug --config ../runtime/wild-apricot/uhppoted.conf get-groups --credentials $(CREDENTIALS)
# $(CLI) --debug get-groups --credentials $(CREDENTIALS) --file "$(WORKDIR)/groups.tsv"
# cat "$(WORKDIR)/groups.tsv"
get-doors: build
$(CLI) --debug --config ../runtime/wild-apricot/uhppoted.conf get-doors
# $(CLI) --debug get-doors --file "$(WORKDIR)/doors.tsv"
# cat "$(WORKDIR)/doors.tsv"
get-acl: build
$(CLI) --debug --config ../runtime/wild-apricot/uhppoted.conf get-acl --credentials $(CREDENTIALS) --rules $(RULES)
get-acl-with-pin: build
$(CLI) get-acl --credentials $(CREDENTIALS) --rules $(RULES_WITH_PIN) --with-pin
# $(CLI) --debug get-acl --credentials $(CREDENTIALS) --rules $(RULES_WITH_PIN) --with-pin
# $(CLI) get-acl --credentials $(CREDENTIALS) --rules $(RULES_WITH_PIN) --with-pin --file "$(WORKDIR)/ACL.tsv"
# cat "$(WORKDIR)/ACL.tsv"
get-acl-file: build
$(CLI) get-acl --credentials $(CREDENTIALS) --rules "file://../runtime/wild-apricot/wild-apricot.grl" --file "$(WORKDIR)/ACL.tsv"
get-acl-drive: build
$(CLI) get-acl --credentials $(CREDENTIALS) --rules "https://drive.google.com/uc?export=download&id=1dwc9HFCbjCf4YB2siexk--coI_xOAtul"
compare-acl: build
$(CLI) --debug --config ../runtime/wild-apricot/uhppoted.conf compare-acl --credentials $(CREDENTIALS) --rules $(RULES)
# $(CLI) compare-acl --credentials $(CREDENTIALS) --rules $(RULES) --report "$(WORKDIR)/ACL.rpt"
# cat "$(WORKDIR)/ACL.rpt"
compare-acl-with-pin: build
# $(CLI) --debug compare-acl --credentials $(CREDENTIALS) --rules $(RULES) --with-pin
$(CLI) compare-acl --credentials $(CREDENTIALS) --rules $(RULES) --with-pin
$(CLI) compare-acl --credentials $(CREDENTIALS) --rules $(RULES) --with-pin --report "$(WORKDIR)/ACL.rpt"
cat "$(WORKDIR)/ACL.rpt"
$(CLI) compare-acl --credentials $(CREDENTIALS) --rules $(RULES) --with-pin --summary
$(CLI) compare-acl --credentials $(CREDENTIALS) --rules $(RULES) --with-pin --summary --report "$(WORKDIR)/ACL.rpt"
cat "$(WORKDIR)/ACL.rpt"
compare-acl-summary: build
$(CLI) compare-acl --credentials $(CREDENTIALS) --rules $(RULES) --summary
$(CLI) compare-acl --credentials $(CREDENTIALS) --rules $(RULES) --summary --report "$(WORKDIR)/ACL.rpt"
cat "$(WORKDIR)/ACL.rpt"
load-acl: build
# $(CLI) load-acl --credentials $(CREDENTIALS) --rules $(RULES) --dry-run --force --log ../runtime/wild-apricot/ACL.log --report ../runtime/wild-apricot/ACL.report
# $(CLI) load-acl --credentials $(CREDENTIALS) --rules $(RULES) --dry-run --force --log ../runtime/wild-apricot/ACL.log --report ../runtime/wild-apricot/ACL.report.tsv
$(CLI) --debug --config ../runtime/wild-apricot/uhppoted.conf load-acl --credentials $(CREDENTIALS) --rules $(RULES)
load-acl-with-pin: build
# $(CLI) --debug load-acl --credentials $(CREDENTIALS) --rules $(RULES) --with-pin
$(CLI) load-acl --credentials $(CREDENTIALS) --rules $(RULES) --with-pin