-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
279 lines (186 loc) · 5.63 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
.PHONY: *
#*------------VARS------------
#*______URL______
server = http://127.0.0.1:8080
github = https://github.com/bastean/dsgo
#*______Go______
go-tidy = go mod tidy -e
#*______Node______
npx = npx --no --
npm-ci = npm ci --legacy-peer-deps
release-it = ${npx} release-it -V
release-it-dry = ${npx} release-it -V -d --no-git.requireCleanWorkingDir
#*______Bash______
bash = bash -o pipefail -c
#*______Git______
git-reset-hard = git reset --hard HEAD
#*______Docker______
compose = cd deployments/ && docker compose
compose-env = ${compose} --env-file
#*------------RULES------------
#*______Upgrades______
upgrade-managers:
#? sudo apt update && sudo apt upgrade -y
npm upgrade -g
upgrade-go:
go get -t -u ./...
upgrade-node:
${npx} ncu --root -ws -u
rm -f package-lock.json
npm i --legacy-peer-deps
upgrade-reset:
${git-reset-hard}
${npm-ci}
upgrade:
go run ./scripts/upgrade
#*______Tools______
scan-tools:
curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sudo sh -s -- -b /usr/local/bin v3.63.11
curl -sSfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sudo sh -s -- -b /usr/local/bin v0.52.2
go install github.com/google/osv-scanner/cmd/osv-scanner@latest
lint-tools:
go install honnef.co/go/tools/cmd/staticcheck@latest
dev-tools:
go install github.com/air-verse/air@latest
go install github.com/a-h/templ/cmd/templ@latest
npm i -g prettier
test-tools:
go run github.com/playwright-community/playwright-go/cmd/playwright@latest install chromium --with-deps
npm i -g concurrently wait-on
install-tools: scan-tools lint-tools dev-tools test-tools
#*______Dependencies______
install-deps:
go mod download
${npm-ci}
copy-deps:
go run ./scripts/copydeps
#*______Generators______
generate-required:
go generate ./...
find . -name "*_templ.go" -type f -delete
templ generate
#*______Initializations______
init: upgrade-managers install-tools install-deps copy-deps generate-required
init-zero:
git init
$(MAKE) init
${npx} husky install
#*______Linters/Formatters______
lint: generate-required
go mod tidy
gofmt -l -s -w .
${npx} prettier --ignore-unknown --write .
templ fmt .
lint-check:
staticcheck ./...
${npx} prettier --check .
#*______Scanners______
leak-check:
sudo trufflehog git file://. --only-verified
trivy repo --scanners secret .
leak-remote-check:
sudo trufflehog git ${github} --only-verified
trivy repo --scanners secret ${github}
vuln-check:
osv-scanner --call-analysis=all -r .
trivy repo --scanners vuln .
misconfig-check:
trivy repo --scanners misconfig .
scan-leaks: leak-check leak-remote-check
scan-vulns: vuln-check
scan-misconfigs: misconfig-check
scans: scan-leaks scan-vulns scan-misconfigs
#*______Tests______
test-sut:
air
test-clean: generate-required
go clean -testcache
cd test/ && mkdir -p report
test-codegen:
${npx} playwright codegen ${server}
test-sync:
${npx} concurrently -s first -k --names 'SUT,TEST' '$(MAKE) test-sut' '${npx} wait-on -l ${server} && $(TEST_SYNC)'
test-unit: test-clean
${bash} 'go test -v -cover ./pkg/context/... -run TestUnit.* |& tee test/report/unit.report.log'
test-integration: test-clean
${bash} 'go test -v -cover ./pkg/context/... -run TestIntegration.* |& tee test/report/integration.report.log'
test-acceptance-sync:
${bash} 'TEST_URL="${server}" go test -v -cover ./internal/app/... -run TestAcceptance.* |& tee test/report/acceptance.report.log'
test-acceptance: test-clean
TEST_SYNC="$(MAKE) test-acceptance-sync" $(MAKE) test-sync
tests-sync:
${bash} 'TEST_URL="${server}" go test -v -cover ./... |& tee test/report/report.log'
tests: test-clean
TEST_SYNC="$(MAKE) tests-sync" $(MAKE) test-sync
#*______Releases______
release:
${release-it}
release-alpha:
${release-it} --preRelease=alpha
release-beta:
${release-it} --preRelease=beta
release-ci:
${release-it} --ci --no-git.requireCleanWorkingDir $(OPTIONS)
release-dry:
${release-it-dry}
release-dry-version:
${release-it-dry} --release-version
release-dry-changelog:
${release-it-dry} --changelog
#*______Builds______
build: generate-required lint
rm -rf build/
go build -ldflags="-s -w" -o build/dsgo ./cmd/dsgo
#*______ENVs______
sync-env-reset:
${git-reset-hard}
sync-env:
cd deployments && go run ../scripts/syncenv
#*______Git______
commit:
${npx} cz
WARNING-git-forget:
git rm -r --cached .
git add .
WARNING-git-genesis:
git clean -e .env* -fdx
${git-reset-hard}
$(MAKE) init
#*______Docker______
docker-usage:
docker system df
docker-it:
docker exec -it $(ID) bash
compose-dev-down:
${compose-env} .env.dev down
docker volume rm -f dsgo-database-mysql-dev
compose-dev: compose-dev-down
${compose-env} .env.dev up
compose-test-down:
${compose-env} .env.test down
docker volume rm -f dsgo-database-mysql-test
compose-test-integration: compose-test-down
${compose-env} .env.test --env-file .env.test.integration up --exit-code-from dsgo
compose-test-acceptance: compose-test-down
${compose-env} .env.test --env-file .env.test.acceptance up --exit-code-from dsgo
compose-tests: compose-test-down
${compose-env} .env.test up --exit-code-from dsgo
compose-prod-down:
${compose-env} .env.prod down
compose-prod: compose-prod-down
${compose-env} .env.prod up
demo-down:
${compose-env} .env.demo down
demo: demo-down
${compose-env} .env.demo up
compose-down: compose-dev-down compose-test-down compose-prod-down demo-down
WARNING-docker-prune-soft:
docker system prune
$(MAKE) compose-down
$(MAKE) docker-usage
WARNING-docker-prune-hard:
docker system prune --volumes -a
$(MAKE) compose-down
$(MAKE) docker-usage
#*______Fixes______
fix-playwright: upgrade-go tools-test