-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
195 lines (169 loc) · 4.05 KB
/
Makefile
File metadata and controls
195 lines (169 loc) · 4.05 KB
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
186
187
188
189
190
191
192
193
194
BINARY_NAME=dndmachine
PWD=$(shell pwd)
UID=$(shell id -u)
GID=$(shell id -g)
GIT_TAG=$(shell git describe master --tags 2> /dev/null || echo -n "v2.0.0")
GIT_BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
GIT_COMMIT=$(shell git rev-parse --short HEAD)
BUILD_TIME=$(shell date -Iseconds)
update: go-update ui-update
test: opa-test go-test ui-test
coverage: opa-coverage go-coverage ui-coverage
build: opa-build go-build ui-build
opa-build:
mkdir -p ${PWD}/build
docker run \
--rm -it \
--user ${UID}:${GID} \
-v ${PWD}/internal/policy/rego:/rego \
-v ${PWD}/build:/build \
cromrots/opa:0.50.1 \
build \
--target wasm \
--entrypoint authz/auth/allow \
--entrypoint authz/character/allow \
--entrypoint authz/pages/allow \
--entrypoint authz/user/allow \
--entrypoint authz \
--ignore \*_test.rego \
--output /build/bundle.tar.gz \
/rego
tar -xzvf \
build/bundle.tar.gz \
--directory=ui/public \
/policy.wasm
rm build/bundle.tar.gz
cp -v ui/public/policy.wasm ui/src/testdata
opa-test:
opa test --verbose internal/policy/rego
opa test --verbose internal/policy/testdata
opa-coverage:
opa test --coverage --verbose internal/policy/rego
dev: opa-build
USER=${UID}:${GID} \
docker-compose up \
--build \
--renew-anon-volumes \
--force-recreate \
--abort-on-container-exit
go-update:
go get -u all
go mod tidy
go mod vendor
go-coverage:
go test -coverprofile cover.out ./cmd/... ./internal/...
go tool cover -html=cover.out
lint:
golangci-lint run -v
format:
gofmt -s -w cmd
gofmt -s -w internal
go-test:
go test -race -count 10 -v ./cmd/... ./internal/...
go-build:
CGO_ENABLED=0 \
GO111MODULE=on \
GOFLAGS=-mod=vendor \
go build \
-o $(BINARY_NAME) \
-a \
-ldflags "\
-X 'github.com/SebastiaanPasterkamp/dndmachine/internal/build.Version=$(GIT_TAG)' \
-X 'github.com/SebastiaanPasterkamp/dndmachine/internal/build.Commit=$(GIT_COMMIT)' \
-X 'github.com/SebastiaanPasterkamp/dndmachine/internal/build.Branch=$(GIT_BRANCH)' \
-X 'github.com/SebastiaanPasterkamp/dndmachine/internal/build.Timestamp=$(BUILD_TIME)' \
" \
cmd/$(BINARY_NAME)/main.go
docker:
docker build \
--build-arg GIT_BRANCH="$(GIT_BRANCH)" \
--build-arg GIT_COMMIT="$(GIT_COMMIT)" \
--build-arg GIT_TAG="$(GIT_TAG)" \
--tag $(BINARY_NAME) \
.
docker-run: docker
docker volume create $(BINARY_NAME)
docker run \
-v $(BINARY_NAME):/database \
-e DNDMACHINE_DSN=sqlite:///database/machine.db \
$(BINARY_NAME) \
storage upgrade
docker run \
-v $(BINARY_NAME):/database \
-e DNDMACHINE_DSN=sqlite:///database/machine.db \
-p 8080:8080 \
$(BINARY_NAME)
clean:
rm \
$(BINARY_NAME) \
cover.out \
ui/build \
ui/public/policy.wasm
docker volume rm $(BINARY_NAME)
npm-install:
docker run \
--rm -it \
-u ${UID}:${GID} \
-v ${PWD}/ui:/project \
-w /project \
node:17.9-stretch \
npm install --no-save npm-check-updates
serve-ui: npm-install
docker run \
--rm -it \
-p 3000:3000 \
-u ${UID}:${GID} \
-v ${PWD}/ui:/project \
-w /project \
node:17.9-stretch \
npm start
ui-test-watch: opa-build npm-install
docker run \
--rm -it \
-u ${UID}:${GID} \
-v ${PWD}/ui:/project \
-w /project \
node:17.9-stretch \
npm test
ui-test: opa-build npm-install
docker run \
--rm -it \
-u ${UID}:${GID} \
-v ${PWD}/ui:/project \
-w /project \
node:17.9-stretch \
npm test -- --all --watchAll=false
ui-coverage: npm-install
docker run \
--rm -it \
-u ${UID}:${GID} \
-v ${PWD}/ui:/project \
-w /project \
node:17.9-stretch \
npm test -- --all --watchAll=false --coverage
ui-build: npm-install
docker run \
--rm -it \
-u ${UID}:${GID} \
-v ${PWD}/ui:/project \
-w /project \
node:17.9-stretch \
npm run build
ui-shell: npm-install
docker run \
--rm -it \
-u ${UID}:${GID} \
-v ${PWD}/ui:/project \
-w /project \
node:17.9-stretch \
/bin/bash
ui-update: npm-install
docker run \
--rm -it \
-u ${UID}:${GID} \
-v ${PWD}/ui:/project \
-w /project \
node:17.9-stretch /bin/bash -c '\
./node_modules/.bin/ncu -u ; \
npm update ; \
'