-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathMakefile
More file actions
294 lines (250 loc) · 10.9 KB
/
Makefile
File metadata and controls
294 lines (250 loc) · 10.9 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
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
CMD_AUTHGEAR ::= authgear
CMD_PORTAL ::= portal
BUILD_CTX ::= .
include ./makefiles/common.mk
include ./makefiles/go-mod-outdated.mk
include ./makefiles/govulncheck.mk
include ./makefiles/check-files-outdated.mk
.PHONY: siteadmin-api-docs
siteadmin-api-docs:
docker run --rm -p 8101:8080 \
-e SWAGGER_JSON=/api/siteadmin-api.yaml \
-e OAUTH_USE_PKCE=true \
-v $(PWD)/docs/api:/api \
swaggerapi/swagger-ui
.PHONY: authgearonce-start
authgearonce-start: GO_RUN_TAGS += authgearonce
authgearonce-start:
$(MAKE) start GO_RUN_TAGS::="$(GO_RUN_TAGS)"
.PHONY: authgearonce-start-portal
authgearonce-start-portal: GO_RUN_TAGS += authgearonce
authgearonce-start-portal:
$(MAKE) start-portal GO_RUN_TAGS::="$(GO_RUN_TAGS)"
.PHONY: vendor
vendor:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $$(go env GOPATH)/bin v2.11.3
go mod download
$(MAKE) build-frondend
.PHONY: build-frondend
build-frondend:
npm --prefix ./scripts/npm ci
npm --prefix ./authui ci
npm --prefix ./portal ci
$(MAKE) authui
$(MAKE) portal
# This makefile target automates running `go mod tidy` in every directory that has a go.mod file.
.PHONY: go-mod-tidy
go-mod-tidy:
find . -name 'go.mod' -exec sh -c 'cd $$(dirname {}); go mod tidy' \;
.PHONY: ensure-important-modules-up-to-date
ensure-important-modules-up-to-date:
./scripts/sh/ensure-important-modules-up-to-date.sh
.PHONY: generate
generate:
go generate ./pkg/... ./cmd/...
cd ./e2e && go generate ./...
.PHONY: test
test:
$(MAKE) -C ./k6 go-test
go test ./devtools/goanalysis/... ./cmd/... ./pkg/... -timeout 1m30s
.PHONY: lint-translation-keys
lint-translation-keys:
-go run ./devtools/gotemplatelinter --ignore-rule indentation --ignore-rule eol-at-eof ./resources/authgear/templates/en/web/authflowv2 >.make-lint-translation-keys-expect 2>&1
git diff --exit-code .make-lint-translation-keys-expect > /dev/null 2>&1
.PHONY: lint
lint:
golangci-lint run ./cmd/... ./pkg/... --timeout 7m
go run ./devtools/translationlinter
-go run ./devtools/importlinter api api >.make-lint-expect 2>&1
-go run ./devtools/importlinter lib api util >> .make-lint-expect 2>&1
-go run ./devtools/importlinter admin api lib util graphqlgo >> .make-lint-expect 2>&1
-go run ./devtools/importlinter auth api lib util >> .make-lint-expect 2>&1
-go run ./devtools/importlinter portal api lib util >> .make-lint-expect 2>&1
-go run ./devtools/importlinter resolver api lib util >> .make-lint-expect 2>&1
-go run ./devtools/importlinter util api util >> .make-lint-expect 2>&1
-go run ./devtools/importlinter version version >> .make-lint-expect 2>&1
-go run ./devtools/importlinter worker api lib util >> .make-lint-expect 2>&1
-go run ./devtools/bandimportlinter ./pkg ./cmd >> .make-lint-expect 2>&1
git diff --exit-code .make-lint-expect > /dev/null 2>&1
go run ./devtools/gotemplatelinter --ignore-rule translation-key ./resources/authgear/templates/en/web/authflowv2
$(MAKE) lint-translation-keys
go run ./devtools/goanalysis ./cmd/... ./pkg/...
.PHONY: sort-translations
sort-translations:
go run ./devtools/translationsorter
.PHONY: sort-vettedpositions
sort-vettedpositions:
./scripts/python/sort_vettedpositions.py ./.vettedpositions
.PHONY: fmt
fmt:
# Ignore generated files, such as wire_gen.go and *_mock_test.go
find ./devtools ./pkg ./cmd ./e2e -name '*.go' -not -name '*_gen.go' -not -name '*_mock_test.go' | sort | xargs go tool goimports -w -format-only -local github.com/authgear/authgear-server
$(MAKE) sort-translations
.PHONY: binary
binary:
rm -rf ./dist
mkdir ./dist
$(MAKE) build AUTHGEARLITE::=1 TARGET::=authgear BIN_NAME::=./dist/authgear-lite-"$(shell go env GOOS)"-"$(shell go env GOARCH)"-${GIT_HASH}
$(MAKE) build AUTHGEARLITE::=1 TARGET::=portal BIN_NAME::=./dist/authgear-portal-lite-"$(shell go env GOOS)"-"$(shell go env GOARCH)"-${GIT_HASH}
.PHONY: check-tidy
check-tidy:
# For some unknown reason, `make generate` will somehow format the files again (but with a different rule).
# So `make fmt` has to be run after `make generate`.
$(MAKE) sort-vettedpositions
$(MAKE) generate
$(MAKE) fmt
$(MAKE) html-email
$(MAKE) export-schemas
$(MAKE) generate-timezones
$(MAKE) generate-rtl
$(MAKE) generate-twemoji-icons
$(MAKE) generate-material-icons
$(MAKE) graphiql
$(MAKE) once/Dockerfile
go mod tidy
# We wanted to run the following, but that requires SSH, which does not work for running CI for PRs.
# (cd custombuild && go mod tidy)
git status --porcelain | grep '.*'; test $$? -eq 1
$(MAKE) -C authui check-tidy
$(MAKE) -C portal check-tidy
.PHONY: html-email
html-email:
# Generate `.mjml` templates from `.mjml.gotemplate` files
go run ./scripts/generatemjml/main.go -i resources/authgear/templates
for t in $$(find resources -name '*.mjml'); do \
./scripts/npm/node_modules/.bin/mjml -l strict "$$t" > "$${t%.mjml}.html"; \
done
.PHONY: authui
authui:
# Build Auth UI
npm run --silent --prefix ./authui typecheck
npm run --silent --prefix ./authui format
npm run --silent --prefix ./authui build
# Vite by default will remove the output directory before the build.
# So we need to touch .gitkeep after the build to avoid git changes.
touch resources/authgear/generated/.gitkeep
.PHONY: authui-dev
authui-dev:
# Make sure that assets are generated before starting dev server
$(MAKE) authui
# Start development server for Auth UI
npm run --silent --prefix ./authui dev
.PHONY: portal
portal:
npm run --silent --prefix ./portal build
cp -R ./portal/dist/. ./resources/portal/static/
# Vite by default will remove the output directory before the build.
# So we need to touch .gitkeep after the build to avoid git changes.
touch ./portal/dist/.gitkeep
# After you run `make clean`, you have to run `make authui` and `make portal`.
.PHONY: clean
clean:
rm -rf ./resources/portal/static
git checkout -- ./resources/portal/static
# It is important NOT to remove the directory.
# Otherwise the watcher is stopped.
rm -rf ./resources/authgear/generated/*
git checkout -- ./resources/authgear/generated/*
rm -rf ./portal/dist
git checkout -- ./portal/dist
rm -rf ./e2e/logs
git checkout -- ./e2e/logs
find . -name '.parcel-cache' -exec rm -rf '{}' \;
find . -name '.stylelintcache' -exec rm -rf '{}' \;
$(MAKE) -C ./e2e clean
$(MAKE) -C ./k6 clean
.PHONY: export-schemas
export-schemas:
go run ./scripts/exportschemas -s app-config -o tmp/app-config.schema.json
go run ./scripts/exportschemas -s secrets-config -o tmp/secrets-config.schema.json
npm run --silent --prefix ./scripts/npm export-graphql-schema admin > portal/src/graphql/adminapi/schema.graphql
npm run --silent --prefix ./scripts/npm export-graphql-schema portal > portal/src/graphql/portal/schema.graphql
cd portal && npm run gentype
.PHONY: export-v2-translations
export-v2-translations:
@npm run --silent --prefix ./scripts/npm export-v2-translations
.PHONY: import-v2-translations
import-v2-translations:
@npm run --silent --prefix ./scripts/npm import-v2-translations
.PHONY: generate-timezones
generate-timezones:
npm run --silent --prefix ./scripts/npm generate-go-timezones > pkg/util/tzutil/names.go
.PHONY: generate-rtl
generate-rtl:
go run ./scripts/characterorder/main.go | gofmt > pkg/util/intl/rtl_map.go
.PHONY: check-spell-translations
check-spell-translations:
@npm run --prefix ./scripts/npm check-spell-translations
.PHONY: generate-material-icons
generate-material-icons:
$(MAKE) -C ./scripts/python generate-material-icons
.PHONY: generate-twemoji-icons
generate-twemoji-icons:
$(MAKE) -C ./scripts/python generate-twemoji-icons
# This make target helps you in updating an existing translation key.
# When you are asked to update an update existing translation key, you do
# 1. Update the value in English.
# 2. `make translation-json-del-key KEY=the-key` to remove the key in other translation JSON files.
# 3. `cd scripts/python; make generate-translations` to re-generate the missing key.
.PHONY: translation-json-del-key
translation-json-del-key: KEY=
translation-json-del-key:
find . -path './resources/authgear/templates/*/translation.json' -not -path './resources/authgear/templates/*/messages/translation.json' -not -path './resources/authgear/templates/en/translation.json' -exec sh -c "jq <\$$1 'del(.[\"$(KEY)\"])' > \$$1.tmp; mv \$$1.tmp \$$1" _ '{}' \;
# This make target take the en translation as reference, cleaup extra translation keys in other languages
.PHONY: translation-json-cleanup-others
translation-json-cleanup-others:
find . -path './resources/authgear/templates/*/translation.json' -not -path './resources/authgear/templates/*/messages/translation.json' -not -path './resources/authgear/templates/en/translation.json' -exec sh -c "jq --slurpfile ref resources/authgear/templates/en/translation.json 'with_entries(select(.key | in(\$$ref[0])))' \$$1 > \$$1.tmp && mv \$$1.tmp \$$1" _ '{}' \;
.PHONY: templates-translation-json-del-key
templates-translation-json-del-key:
@if [ -z "$(KEY)" ]; then echo "Error: KEY is required. Usage: make templates-translation-json-del-key KEY=my.key"; exit 1; fi
find resources/authgear/templates -type f -path "*/messages/translation.json" ! -path "*/en/messages/*" -exec sh -c ' \
if [ -s "$$1" ]; then \
jq "del(.$(KEY))" "$$1" > "$$1.tmp" && mv "$$1.tmp" "$$1"; \
fi \
' _ {} \;
.PHONY: logs-summary
logs-summary:
git log --first-parent --format='%as (%h) %s' $(A)..$(B)
.PHONY: mkcert-ca
mkcert-ca:
cp "$$(mkcert -CAROOT)"/rootCA.pem ./rootCA.pem
.PHONY: mkcert
mkcert:
rm -f tls-cert.pem tls-key.pem
mkcert -cert-file tls-cert.pem -key-file tls-key.pem "::1" "127.0.0.1" postgres16 localhost portal.localhost accounts.localhost accounts.portal.localhost $$(ifconfig | grep 'inet 192' | awk '{print $$2}') $$(ifconfig | grep 'inet 192' | awk '{print $$2}').nip.io
.PHONY: check-dockerignore
check-dockerignore:
./scripts/sh/check-dockerignore.sh
.PHONY: graphiql
graphiql:
npm --prefix portalgraphiql ci
npm --prefix portalgraphiql run build
cp ./portalgraphiql/dist/index.html pkg/util/graphqlutil/graphiql.generated.html
.PHONY: once/Dockerfile
once/Dockerfile:
rm -f $@
touch $@
cat ./once/opening.dockerfile >> $@
printf "\n" >> $@
sed -e '/^# syntax=/d' ./cmd/authgear/Dockerfile >> $@
printf "\n" >> $@
sed -e '/^# syntax=/d' ./cmd/portal/Dockerfile >> $@
printf "\n" >> $@
sed -e '/^# syntax=/d' ./once/partial.dockerfile >> $@
.PHONY: authgearonce-set-git-tag-name
authgearonce-set-git-tag-name:
@./scripts/sh/authgearonce-set-git-tag-name.sh
.PHONY: authgearonce-set-AUTHGEARONCE_LICENSE_SERVER_ENV-by-tag-name
authgearonce-set-AUTHGEARONCE_LICENSE_SERVER_ENV-by-tag-name:
@./scripts/sh/authgearonce-set-AUTHGEARONCE_LICENSE_SERVER_ENV-by-tag-name.sh
.PHONY: authgearonce-binary
ifeq ($(AUTHGEARONCE_LICENSE_SERVER_ENV), local)
GO_BUILD_TAGS += authgearonce_license_server_local
endif
ifeq ($(AUTHGEARONCE_LICENSE_SERVER_ENV), staging)
GO_BUILD_TAGS += authgearonce_license_server_staging
endif
authgearonce-binary:
rm -rf ./dist
mkdir ./dist
$(MAKE) build TARGET::=once BIN_NAME::=./dist/authgear-once-"$(shell go env GOOS)"-"$(shell go env GOARCH)"