gitech

Форк
0
/
Makefile 
984 строки · 37.6 Кб
1
ifeq ($(USE_REPO_TEST_DIR),1)
2

3
# This rule replaces the whole Makefile when we're trying to use /tmp repository temporary files
4
location = $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
5
self := $(location)
6

7
%:
8
	@tmpdir=`mktemp --tmpdir -d` ; \
9
	echo Using temporary directory $$tmpdir for test repositories ; \
10
	USE_REPO_TEST_DIR= $(MAKE) -f $(self) --no-print-directory REPO_TEST_DIR=$$tmpdir/ $@ ; \
11
	STATUS=$$? ; rm -r "$$tmpdir" ; exit $$STATUS
12

13
else
14

15
# This is the "normal" part of the Makefile
16

17
DIST := dist
18
DIST_DIRS := $(DIST)/binaries $(DIST)/release
19
IMPORT := code.gitea.io/gitea
20

21
GO ?= go
22
SHASUM ?= shasum -a 256
23
HAS_GO := $(shell hash $(GO) > /dev/null 2>&1 && echo yes)
24
COMMA := ,
25

26
XGO_VERSION := go-1.22.x
27

28
AIR_PACKAGE ?= github.com/cosmtrek/air@v1
29
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.7.0
30
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.6.0
31
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2
32
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11
33
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.4.1
34
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@db51e79a0e37c572d8b59ae0c58bf2bbbbe53285
35
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
36
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1
37
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1
38
ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1
39

40
DOCKER_IMAGE ?= gitea/gitea
41
DOCKER_TAG ?= latest
42
DOCKER_REF := $(DOCKER_IMAGE):$(DOCKER_TAG)
43

44
ifeq ($(HAS_GO), yes)
45
	CGO_EXTRA_CFLAGS := -DSQLITE_MAX_VARIABLE_NUMBER=32766
46
	CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
47
endif
48

49
ifeq ($(GOOS),windows)
50
	IS_WINDOWS := yes
51
else ifeq ($(patsubst Windows%,Windows,$(OS)),Windows)
52
	ifeq ($(GOOS),)
53
		IS_WINDOWS := yes
54
	endif
55
endif
56
ifeq ($(IS_WINDOWS),yes)
57
	GOFLAGS := -v -buildmode=exe
58
	EXECUTABLE ?= gitea.exe
59
else
60
	GOFLAGS := -v
61
	EXECUTABLE ?= gitea
62
endif
63

64
ifeq ($(shell sed --version 2>/dev/null | grep -q GNU && echo gnu),gnu)
65
	SED_INPLACE := sed -i
66
else
67
	SED_INPLACE := sed -i ''
68
endif
69

70
EXTRA_GOFLAGS ?=
71

72
MAKE_VERSION := $(shell "$(MAKE)" -v | cat | head -n 1)
73
MAKE_EVIDENCE_DIR := .make_evidence
74

75
ifeq ($(RACE_ENABLED),true)
76
	GOFLAGS += -race
77
	GOTESTFLAGS += -race
78
endif
79

80
STORED_VERSION_FILE := VERSION
81
HUGO_VERSION ?= 0.111.3
82

83
GITHUB_REF_TYPE ?= branch
84
GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
85

86
ifneq ($(GITHUB_REF_TYPE),branch)
87
	VERSION ?= $(subst v,,$(GITHUB_REF_NAME))
88
	GITEA_VERSION ?= $(VERSION)
89
else
90
	ifneq ($(GITHUB_REF_NAME),)
91
		VERSION ?= $(subst release/v,,$(GITHUB_REF_NAME))
92
	else
93
		VERSION ?= main
94
	endif
95

96
	STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null)
97
	ifneq ($(STORED_VERSION),)
98
		GITEA_VERSION ?= $(STORED_VERSION)
99
	else
100
		GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
101
	endif
102
endif
103

104
# if version = "main" then update version to "nightly"
105
ifeq ($(VERSION),main)
106
	VERSION := main-nightly
107
endif
108

109
LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
110

111
LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
112

113
GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
114
GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
115
MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.gitea.io/gitea/models/migrations/...)
116

117
FOMANTIC_WORK_DIR := web_src/fomantic
118

119
WEBPACK_SOURCES := $(shell find web_src/js web_src/css -type f)
120
WEBPACK_CONFIGS := webpack.config.js tailwind.config.js
121
WEBPACK_DEST := public/assets/js/index.js public/assets/css/index.css
122
WEBPACK_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts
123

124
BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
125
BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))
126

127
GENERATED_GO_DEST := modules/charset/invisible_gen.go modules/charset/ambiguous_gen.go
128

129
SVG_DEST_DIR := public/assets/img/svg
130

131
AIR_TMP_DIR := .air
132

133
GO_LICENSE_TMP_DIR := .go-licenses
134
GO_LICENSE_FILE := assets/go-licenses.json
135

136
TAGS ?=
137
TAGS_SPLIT := $(subst $(COMMA), ,$(TAGS))
138
TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
139

140
TEST_TAGS ?= sqlite sqlite_unlock_notify
141

142
TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMANTIC_WORK_DIR)/node_modules $(DIST) $(MAKE_EVIDENCE_DIR) $(AIR_TMP_DIR) $(GO_LICENSE_TMP_DIR)
143

144
GO_DIRS := build cmd models modules routers services tests
145
WEB_DIRS := web_src/js web_src/css
146

147
ESLINT_FILES := web_src/js tools *.config.js tests/e2e
148
STYLELINT_FILES := web_src/css web_src/js/components/*.vue
149
SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) docs/content templates options/locale/locale_en-US.ini .github
150
EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.ini
151

152
GO_SOURCES := $(wildcard *.go)
153
GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" ! -path modules/options/bindata.go ! -path modules/public/bindata.go ! -path modules/templates/bindata.go)
154
GO_SOURCES += $(GENERATED_GO_DEST)
155
GO_SOURCES_NO_BINDATA := $(GO_SOURCES)
156

157
ifeq ($(filter $(TAGS_SPLIT),bindata),bindata)
158
	GO_SOURCES += $(BINDATA_DEST)
159
	GENERATED_GO_DEST += $(BINDATA_DEST)
160
endif
161

162
# Force installation of playwright dependencies by setting this flag
163
ifdef DEPS_PLAYWRIGHT
164
	PLAYWRIGHT_FLAGS += --with-deps
165
endif
166

167
SWAGGER_SPEC := templates/swagger/v1_json.tmpl
168
SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl \| JSEscape}}/api/v1"|g
169
SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl \| JSEscape}}/api/v1"|"basePath": "/api/v1"|g
170
SWAGGER_EXCLUDE := code.gitea.io/sdk
171
SWAGGER_NEWLINE_COMMAND := -e '$$a\'
172

173
TEST_MYSQL_HOST ?= mysql:3306
174
TEST_MYSQL_DBNAME ?= testgitea
175
TEST_MYSQL_USERNAME ?= root
176
TEST_MYSQL_PASSWORD ?=
177
TEST_PGSQL_HOST ?= pgsql:5432
178
TEST_PGSQL_DBNAME ?= testgitea
179
TEST_PGSQL_USERNAME ?= postgres
180
TEST_PGSQL_PASSWORD ?= postgres
181
TEST_PGSQL_SCHEMA ?= gtestschema
182
TEST_MSSQL_HOST ?= mssql:1433
183
TEST_MSSQL_DBNAME ?= gitea
184
TEST_MSSQL_USERNAME ?= sa
185
TEST_MSSQL_PASSWORD ?= MwantsaSecurePassword1
186

187
.PHONY: all
188
all: build
189

190
.PHONY: help
191
help:
192
	@echo "Make Routines:"
193
	@echo " - \"\"                               equivalent to \"build\""
194
	@echo " - build                            build everything"
195
	@echo " - frontend                         build frontend files"
196
	@echo " - backend                          build backend files"
197
	@echo " - watch                            watch everything and continuously rebuild"
198
	@echo " - watch-frontend                   watch frontend files and continuously rebuild"
199
	@echo " - watch-backend                    watch backend files and continuously rebuild"
200
	@echo " - clean                            delete backend and integration files"
201
	@echo " - clean-all                        delete backend, frontend and integration files"
202
	@echo " - deps                             install dependencies"
203
	@echo " - deps-frontend                    install frontend dependencies"
204
	@echo " - deps-backend                     install backend dependencies"
205
	@echo " - deps-tools                       install tool dependencies"
206
	@echo " - deps-py                          install python dependencies"
207
	@echo " - lint                             lint everything"
208
	@echo " - lint-fix                         lint everything and fix issues"
209
	@echo " - lint-actions                     lint action workflow files"
210
	@echo " - lint-frontend                    lint frontend files"
211
	@echo " - lint-frontend-fix                lint frontend files and fix issues"
212
	@echo " - lint-backend                     lint backend files"
213
	@echo " - lint-backend-fix                 lint backend files and fix issues"
214
	@echo " - lint-go                          lint go files"
215
	@echo " - lint-go-fix                      lint go files and fix issues"
216
	@echo " - lint-go-vet                      lint go files with vet"
217
	@echo " - lint-js                          lint js files"
218
	@echo " - lint-js-fix                      lint js files and fix issues"
219
	@echo " - lint-css                         lint css files"
220
	@echo " - lint-css-fix                     lint css files and fix issues"
221
	@echo " - lint-md                          lint markdown files"
222
	@echo " - lint-swagger                     lint swagger files"
223
	@echo " - lint-templates                   lint template files"
224
	@echo " - lint-yaml                        lint yaml files"
225
	@echo " - lint-spell                       lint spelling"
226
	@echo " - lint-spell-fix                   lint spelling and fix issues"
227
	@echo " - checks                           run various consistency checks"
228
	@echo " - checks-frontend                  check frontend files"
229
	@echo " - checks-backend                   check backend files"
230
	@echo " - test                             test everything"
231
	@echo " - test-frontend                    test frontend files"
232
	@echo " - test-backend                     test backend files"
233
	@echo " - test-e2e[\#TestSpecificName]     test end to end using playwright"
234
	@echo " - update                           update js and py dependencies"
235
	@echo " - update-js                        update js dependencies"
236
	@echo " - update-py                        update py dependencies"
237
	@echo " - webpack                          build webpack files"
238
	@echo " - svg                              build svg files"
239
	@echo " - fomantic                         build fomantic files"
240
	@echo " - generate                         run \"go generate\""
241
	@echo " - fmt                              format the Go code"
242
	@echo " - generate-license                 update license files"
243
	@echo " - generate-gitignore               update gitignore files"
244
	@echo " - generate-manpage                 generate manpage"
245
	@echo " - generate-swagger                 generate the swagger spec from code comments"
246
	@echo " - swagger-validate                 check if the swagger spec is valid"
247
	@echo " - go-licenses                      regenerate go licenses"
248
	@echo " - tidy                             run go mod tidy"
249
	@echo " - test[\#TestSpecificName]    	    run unit test"
250
	@echo " - test-sqlite[\#TestSpecificName]  run integration test for sqlite"
251

252
.PHONY: go-check
253
go-check:
254
	$(eval MIN_GO_VERSION_STR := $(shell grep -Eo '^go\s+[0-9]+\.[0-9]+' go.mod | cut -d' ' -f2))
255
	$(eval MIN_GO_VERSION := $(shell printf "%03d%03d" $(shell echo '$(MIN_GO_VERSION_STR)' | tr '.' ' ')))
256
	$(eval GO_VERSION := $(shell printf "%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9]+' | tr '.' ' ');))
257
	@if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \
258
		echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://go.dev/dl/"; \
259
		exit 1; \
260
	fi
261

262
.PHONY: git-check
263
git-check:
264
	@if git lfs >/dev/null 2>&1 ; then : ; else \
265
		echo "Gitea requires git with lfs support to run tests." ; \
266
		exit 1; \
267
	fi
268

269
.PHONY: node-check
270
node-check:
271
	$(eval MIN_NODE_VERSION_STR := $(shell grep -Eo '"node":.*[0-9.]+"' package.json | sed -n 's/.*[^0-9.]\([0-9.]*\)"/\1/p'))
272
	$(eval MIN_NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_NODE_VERSION_STR)' | tr '.' ' ')))
273
	$(eval NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell node -v | cut -c2- | tr '.' ' ');))
274
	$(eval NPM_MISSING := $(shell hash npm > /dev/null 2>&1 || echo 1))
275
	@if [ "$(NODE_VERSION)" -lt "$(MIN_NODE_VERSION)" -o "$(NPM_MISSING)" = "1" ]; then \
276
		echo "Gitea requires Node.js $(MIN_NODE_VERSION_STR) or greater and npm to build. You can get it at https://nodejs.org/en/download/"; \
277
		exit 1; \
278
	fi
279

280
.PHONY: clean-all
281
clean-all: clean
282
	rm -rf $(WEBPACK_DEST_ENTRIES) node_modules
283

284
.PHONY: clean
285
clean:
286
	rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST) $(BINDATA_HASH) \
287
		integrations*.test \
288
		e2e*.test \
289
		tests/integration/gitea-integration-* \
290
		tests/integration/indexers-* \
291
		tests/mysql.ini tests/pgsql.ini tests/mssql.ini man/ \
292
		tests/e2e/gitea-e2e-*/ \
293
		tests/e2e/indexers-*/ \
294
		tests/e2e/reports/ tests/e2e/test-artifacts/ tests/e2e/test-snapshots/
295

296
.PHONY: fmt
297
fmt:
298
	@GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}'
299
	$(eval TEMPLATES := $(shell find templates -type f -name '*.tmpl'))
300
	@# strip whitespace after '{{' or '(' and before '}}' or ')' unless there is only
301
	@# whitespace before it
302
	@$(SED_INPLACE) \
303
		-e 's/{{[ 	]\{1,\}/{{/g' -e '/^[ 	]\{1,\}}}/! s/[ 	]\{1,\}}}/}}/g' \
304
	  -e 's/([ 	]\{1,\}/(/g' -e '/^[ 	]\{1,\})/! s/[ 	]\{1,\})/)/g' \
305
	  $(TEMPLATES)
306

307
.PHONY: fmt-check
308
fmt-check: fmt
309
	@diff=$$(git diff --color=always $(GO_SOURCES) templates $(WEB_DIRS)); \
310
	if [ -n "$$diff" ]; then \
311
	  echo "Please run 'make fmt' and commit the result:"; \
312
	  echo "$${diff}"; \
313
	  exit 1; \
314
	fi
315

316
.PHONY: $(TAGS_EVIDENCE)
317
$(TAGS_EVIDENCE):
318
	@mkdir -p $(MAKE_EVIDENCE_DIR)
319
	@echo "$(TAGS)" > $(TAGS_EVIDENCE)
320

321
ifneq "$(TAGS)" "$(shell cat $(TAGS_EVIDENCE) 2>/dev/null)"
322
TAGS_PREREQ := $(TAGS_EVIDENCE)
323
endif
324

325
.PHONY: generate-swagger
326
generate-swagger: $(SWAGGER_SPEC)
327

328
$(SWAGGER_SPEC): $(GO_SOURCES_NO_BINDATA)
329
	$(GO) run $(SWAGGER_PACKAGE) generate spec -x "$(SWAGGER_EXCLUDE)" -o './$(SWAGGER_SPEC)'
330
	$(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
331
	$(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)'
332

333
.PHONY: swagger-check
334
swagger-check: generate-swagger
335
	@diff=$$(git diff --color=always '$(SWAGGER_SPEC)'); \
336
	if [ -n "$$diff" ]; then \
337
		echo "Please run 'make generate-swagger' and commit the result:"; \
338
		echo "$${diff}"; \
339
		exit 1; \
340
	fi
341

342
.PHONY: swagger-validate
343
swagger-validate:
344
	$(SED_INPLACE) '$(SWAGGER_SPEC_S_JSON)' './$(SWAGGER_SPEC)'
345
	$(GO) run $(SWAGGER_PACKAGE) validate './$(SWAGGER_SPEC)'
346
	$(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
347

348
.PHONY: checks
349
checks: checks-frontend checks-backend
350

351
.PHONY: checks-frontend
352
checks-frontend: lockfile-check svg-check
353

354
.PHONY: checks-backend
355
checks-backend: tidy-check swagger-check fmt-check swagger-validate security-check
356

357
.PHONY: lint
358
lint: lint-frontend lint-backend lint-spell
359

360
.PHONY: lint-fix
361
lint-fix: lint-frontend-fix lint-backend-fix lint-spell-fix
362

363
.PHONY: lint-frontend
364
lint-frontend: lint-js lint-css
365

366
.PHONY: lint-frontend-fix
367
lint-frontend-fix: lint-js-fix lint-css-fix
368

369
.PHONY: lint-backend
370
lint-backend: lint-go lint-go-vet lint-editorconfig
371

372
.PHONY: lint-backend-fix
373
lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig
374

375
.PHONY: lint-js
376
lint-js: node_modules
377
	npx eslint --color --max-warnings=0 --ext js,vue $(ESLINT_FILES)
378

379
.PHONY: lint-js-fix
380
lint-js-fix: node_modules
381
	npx eslint --color --max-warnings=0 --ext js,vue $(ESLINT_FILES) --fix
382

383
.PHONY: lint-css
384
lint-css: node_modules
385
	npx stylelint --color --max-warnings=0 $(STYLELINT_FILES)
386

387
.PHONY: lint-css-fix
388
lint-css-fix: node_modules
389
	npx stylelint --color --max-warnings=0 $(STYLELINT_FILES) --fix
390

391
.PHONY: lint-swagger
392
lint-swagger: node_modules
393
	npx spectral lint -q -F hint $(SWAGGER_SPEC)
394

395
.PHONY: lint-md
396
lint-md: node_modules
397
	npx markdownlint docs *.md
398

399
.PHONY: lint-spell
400
lint-spell:
401
	@go run $(MISSPELL_PACKAGE) -error $(SPELLCHECK_FILES)
402

403
.PHONY: lint-spell-fix
404
lint-spell-fix:
405
	@go run $(MISSPELL_PACKAGE) -w $(SPELLCHECK_FILES)
406

407
.PHONY: lint-go
408
lint-go:
409
	$(GO) run $(GOLANGCI_LINT_PACKAGE) run
410

411
.PHONY: lint-go-fix
412
lint-go-fix:
413
	$(GO) run $(GOLANGCI_LINT_PACKAGE) run --fix
414

415
# workaround step for the lint-go-windows CI task because 'go run' can not
416
# have distinct GOOS/GOARCH for its build and run steps
417
.PHONY: lint-go-windows
418
lint-go-windows:
419
	@GOOS= GOARCH= $(GO) install $(GOLANGCI_LINT_PACKAGE)
420
	golangci-lint run
421

422
.PHONY: lint-go-vet
423
lint-go-vet:
424
	@echo "Running go vet..."
425
	@GOOS= GOARCH= $(GO) build code.gitea.io/gitea-vet
426
	@$(GO) vet -vettool=gitea-vet $(GO_PACKAGES)
427

428
.PHONY: lint-editorconfig
429
lint-editorconfig:
430
	@$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) $(EDITORCONFIG_FILES)
431

432
.PHONY: lint-actions
433
lint-actions:
434
	$(GO) run $(ACTIONLINT_PACKAGE)
435

436
.PHONY: lint-templates
437
lint-templates: .venv node_modules
438
	@node tools/lint-templates-svg.js
439
	@poetry run djlint $(shell find templates -type f -iname '*.tmpl')
440

441
.PHONY: lint-yaml
442
lint-yaml: .venv
443
	@poetry run yamllint .
444

445
.PHONY: watch
446
watch:
447
	@bash tools/watch.sh
448

449
.PHONY: watch-frontend
450
watch-frontend: node-check node_modules
451
	@rm -rf $(WEBPACK_DEST_ENTRIES)
452
	NODE_ENV=development npx webpack --watch --progress
453

454
.PHONY: watch-backend
455
watch-backend: go-check
456
	GITEA_RUN_MODE=dev $(GO) run $(AIR_PACKAGE) -c .air.toml
457

458
.PHONY: test
459
test: test-frontend test-backend
460

461
.PHONY: test-backend
462
test-backend:
463
	@echo "Running go test with $(GOTESTFLAGS) -tags '$(TEST_TAGS)'..."
464
	@$(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' $(GO_TEST_PACKAGES)
465

466
.PHONY: test-frontend
467
test-frontend: node_modules
468
	npx vitest
469

470
.PHONY: test-check
471
test-check:
472
	@echo "Running test-check...";
473
	@diff=$$(git status -s); \
474
	if [ -n "$$diff" ]; then \
475
		echo "make test-backend has changed files in the source tree:"; \
476
		echo "$${diff}"; \
477
		echo "You should change the tests to create these files in a temporary directory."; \
478
		echo "Do not simply add these files to .gitignore"; \
479
		exit 1; \
480
	fi
481

482
.PHONY: test\#%
483
test\#%:
484
	@echo "Running go test with -tags '$(TEST_TAGS)'..."
485
	@$(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -run $(subst .,/,$*) $(GO_TEST_PACKAGES)
486

487
.PHONY: coverage
488
coverage:
489
	grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' coverage.out > coverage-bodged.out
490
	grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' integration.coverage.out > integration.coverage-bodged.out
491
	$(GO) run build/gocovmerge.go integration.coverage-bodged.out coverage-bodged.out > coverage.all
492

493
.PHONY: unit-test-coverage
494
unit-test-coverage:
495
	@echo "Running unit-test-coverage $(GOTESTFLAGS) -tags '$(TEST_TAGS)'..."
496
	@$(GO) test $(GOTESTFLAGS) -timeout=20m -tags='$(TEST_TAGS)' -cover -coverprofile coverage.out $(GO_TEST_PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
497

498
.PHONY: tidy
499
tidy:
500
	$(eval MIN_GO_VERSION := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2))
501
	$(GO) mod tidy -compat=$(MIN_GO_VERSION)
502
	@$(MAKE) --no-print-directory $(GO_LICENSE_FILE)
503

504
vendor: go.mod go.sum
505
	$(GO) mod vendor
506
	@touch vendor
507

508
.PHONY: tidy-check
509
tidy-check: tidy
510
	@diff=$$(git diff --color=always go.mod go.sum $(GO_LICENSE_FILE)); \
511
	if [ -n "$$diff" ]; then \
512
		echo "Please run 'make tidy' and commit the result:"; \
513
		echo "$${diff}"; \
514
		exit 1; \
515
	fi
516

517
.PHONY: go-licenses
518
go-licenses: $(GO_LICENSE_FILE)
519

520
$(GO_LICENSE_FILE): go.mod go.sum
521
	-$(GO) run $(GO_LICENSES_PACKAGE) save . --force --save_path=$(GO_LICENSE_TMP_DIR) 2>/dev/null
522
	$(GO) run build/generate-go-licenses.go $(GO_LICENSE_TMP_DIR) $(GO_LICENSE_FILE)
523
	@rm -rf $(GO_LICENSE_TMP_DIR)
524

525
generate-ini-sqlite:
526
	sed -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
527
		-e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
528
		-e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \
529
			tests/sqlite.ini.tmpl > tests/sqlite.ini
530

531
.PHONY: test-sqlite
532
test-sqlite: integrations.sqlite.test generate-ini-sqlite
533
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test
534

535
.PHONY: test-sqlite\#%
536
test-sqlite\#%: integrations.sqlite.test generate-ini-sqlite
537
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test -test.run $(subst .,/,$*)
538

539
.PHONY: test-sqlite-migration
540
test-sqlite-migration:  migrations.sqlite.test migrations.individual.sqlite.test
541

542
generate-ini-mysql:
543
	sed -e 's|{{TEST_MYSQL_HOST}}|${TEST_MYSQL_HOST}|g' \
544
		-e 's|{{TEST_MYSQL_DBNAME}}|${TEST_MYSQL_DBNAME}|g' \
545
		-e 's|{{TEST_MYSQL_USERNAME}}|${TEST_MYSQL_USERNAME}|g' \
546
		-e 's|{{TEST_MYSQL_PASSWORD}}|${TEST_MYSQL_PASSWORD}|g' \
547
		-e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
548
		-e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
549
		-e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \
550
			tests/mysql.ini.tmpl > tests/mysql.ini
551

552
.PHONY: test-mysql
553
test-mysql: integrations.mysql.test generate-ini-mysql
554
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test
555

556
.PHONY: test-mysql\#%
557
test-mysql\#%: integrations.mysql.test generate-ini-mysql
558
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test -test.run $(subst .,/,$*)
559

560
.PHONY: test-mysql-migration
561
test-mysql-migration: migrations.mysql.test migrations.individual.mysql.test
562

563
generate-ini-pgsql:
564
	sed -e 's|{{TEST_PGSQL_HOST}}|${TEST_PGSQL_HOST}|g' \
565
		-e 's|{{TEST_PGSQL_DBNAME}}|${TEST_PGSQL_DBNAME}|g' \
566
		-e 's|{{TEST_PGSQL_USERNAME}}|${TEST_PGSQL_USERNAME}|g' \
567
		-e 's|{{TEST_PGSQL_PASSWORD}}|${TEST_PGSQL_PASSWORD}|g' \
568
		-e 's|{{TEST_PGSQL_SCHEMA}}|${TEST_PGSQL_SCHEMA}|g' \
569
		-e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
570
		-e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
571
		-e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \
572
			tests/pgsql.ini.tmpl > tests/pgsql.ini
573

574
.PHONY: test-pgsql
575
test-pgsql: integrations.pgsql.test generate-ini-pgsql
576
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test
577

578
.PHONY: test-pgsql\#%
579
test-pgsql\#%: integrations.pgsql.test generate-ini-pgsql
580
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test -test.run $(subst .,/,$*)
581

582
.PHONY: test-pgsql-migration
583
test-pgsql-migration: migrations.pgsql.test migrations.individual.pgsql.test
584

585
generate-ini-mssql:
586
	sed -e 's|{{TEST_MSSQL_HOST}}|${TEST_MSSQL_HOST}|g' \
587
		-e 's|{{TEST_MSSQL_DBNAME}}|${TEST_MSSQL_DBNAME}|g' \
588
		-e 's|{{TEST_MSSQL_USERNAME}}|${TEST_MSSQL_USERNAME}|g' \
589
		-e 's|{{TEST_MSSQL_PASSWORD}}|${TEST_MSSQL_PASSWORD}|g' \
590
		-e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
591
		-e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
592
		-e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \
593
			tests/mssql.ini.tmpl > tests/mssql.ini
594

595
.PHONY: test-mssql
596
test-mssql: integrations.mssql.test generate-ini-mssql
597
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test
598

599
.PHONY: test-mssql\#%
600
test-mssql\#%: integrations.mssql.test generate-ini-mssql
601
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test -test.run $(subst .,/,$*)
602

603
.PHONY: test-mssql-migration
604
test-mssql-migration: migrations.mssql.test migrations.individual.mssql.test
605

606
.PHONY: playwright
607
playwright: deps-frontend
608
	npx playwright install $(PLAYWRIGHT_FLAGS)
609

610
.PHONY: test-e2e%
611
test-e2e%: TEST_TYPE ?= e2e
612
	# Clear display env variable. Otherwise, chromium tests can fail.
613
	DISPLAY=
614

615
.PHONY: test-e2e
616
test-e2e: test-e2e-sqlite
617

618
.PHONY: test-e2e-sqlite
619
test-e2e-sqlite: playwright e2e.sqlite.test generate-ini-sqlite
620
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./e2e.sqlite.test
621

622
.PHONY: test-e2e-sqlite\#%
623
test-e2e-sqlite\#%: playwright e2e.sqlite.test generate-ini-sqlite
624
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./e2e.sqlite.test -test.run TestE2e/$*
625

626
.PHONY: test-e2e-mysql
627
test-e2e-mysql: playwright e2e.mysql.test generate-ini-mysql
628
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./e2e.mysql.test
629

630
.PHONY: test-e2e-mysql\#%
631
test-e2e-mysql\#%: playwright e2e.mysql.test generate-ini-mysql
632
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./e2e.mysql.test -test.run TestE2e/$*
633

634
.PHONY: test-e2e-pgsql
635
test-e2e-pgsql: playwright e2e.pgsql.test generate-ini-pgsql
636
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./e2e.pgsql.test
637

638
.PHONY: test-e2e-pgsql\#%
639
test-e2e-pgsql\#%: playwright e2e.pgsql.test generate-ini-pgsql
640
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./e2e.pgsql.test -test.run TestE2e/$*
641

642
.PHONY: test-e2e-mssql
643
test-e2e-mssql: playwright e2e.mssql.test generate-ini-mssql
644
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test
645

646
.PHONY: test-e2e-mssql\#%
647
test-e2e-mssql\#%: playwright e2e.mssql.test generate-ini-mssql
648
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test -test.run TestE2e/$*
649

650
.PHONY: bench-sqlite
651
bench-sqlite: integrations.sqlite.test generate-ini-sqlite
652
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
653

654
.PHONY: bench-mysql
655
bench-mysql: integrations.mysql.test generate-ini-mysql
656
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
657

658
.PHONY: bench-mssql
659
bench-mssql: integrations.mssql.test generate-ini-mssql
660
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
661

662
.PHONY: bench-pgsql
663
bench-pgsql: integrations.pgsql.test generate-ini-pgsql
664
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
665

666
.PHONY: integration-test-coverage
667
integration-test-coverage: integrations.cover.test generate-ini-mysql
668
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
669

670
.PHONY: integration-test-coverage-sqlite
671
integration-test-coverage-sqlite: integrations.cover.sqlite.test generate-ini-sqlite
672
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.cover.sqlite.test -test.coverprofile=integration.coverage.out
673

674
integrations.mysql.test: git-check $(GO_SOURCES)
675
	$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.mysql.test
676

677
integrations.pgsql.test: git-check $(GO_SOURCES)
678
	$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.pgsql.test
679

680
integrations.mssql.test: git-check $(GO_SOURCES)
681
	$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.mssql.test
682

683
integrations.sqlite.test: git-check $(GO_SOURCES)
684
	$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.sqlite.test -tags '$(TEST_TAGS)'
685

686
integrations.cover.test: git-check $(GO_SOURCES)
687
	$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -coverpkg $(shell echo $(GO_TEST_PACKAGES) | tr ' ' ',') -o integrations.cover.test
688

689
integrations.cover.sqlite.test: git-check $(GO_SOURCES)
690
	$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -coverpkg $(shell echo $(GO_TEST_PACKAGES) | tr ' ' ',') -o integrations.cover.sqlite.test -tags '$(TEST_TAGS)'
691

692
.PHONY: migrations.mysql.test
693
migrations.mysql.test: $(GO_SOURCES) generate-ini-mysql
694
	$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.mysql.test
695
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./migrations.mysql.test
696

697
.PHONY: migrations.pgsql.test
698
migrations.pgsql.test: $(GO_SOURCES) generate-ini-pgsql
699
	$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.pgsql.test
700
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./migrations.pgsql.test
701

702
.PHONY: migrations.mssql.test
703
migrations.mssql.test: $(GO_SOURCES) generate-ini-mssql
704
	$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.mssql.test
705
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./migrations.mssql.test
706

707
.PHONY: migrations.sqlite.test
708
migrations.sqlite.test: $(GO_SOURCES) generate-ini-sqlite
709
	$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.sqlite.test -tags '$(TEST_TAGS)'
710
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./migrations.sqlite.test
711

712
.PHONY: migrations.individual.mysql.test
713
migrations.individual.mysql.test: $(GO_SOURCES)
714
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
715

716
.PHONY: migrations.individual.sqlite.test\#%
717
migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite
718
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
719

720
.PHONY: migrations.individual.pgsql.test
721
migrations.individual.pgsql.test: $(GO_SOURCES)
722
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
723

724
.PHONY: migrations.individual.pgsql.test\#%
725
migrations.individual.pgsql.test\#%: $(GO_SOURCES) generate-ini-pgsql
726
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
727

728
.PHONY: migrations.individual.mssql.test
729
migrations.individual.mssql.test: $(GO_SOURCES) generate-ini-mssql
730
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
731

732
.PHONY: migrations.individual.mssql.test\#%
733
migrations.individual.mssql.test\#%: $(GO_SOURCES) generate-ini-mssql
734
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
735

736
.PHONY: migrations.individual.sqlite.test
737
migrations.individual.sqlite.test: $(GO_SOURCES) generate-ini-sqlite
738
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
739

740
.PHONY: migrations.individual.sqlite.test\#%
741
migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite
742
	GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
743

744
e2e.mysql.test: $(GO_SOURCES)
745
	$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mysql.test
746

747
e2e.pgsql.test: $(GO_SOURCES)
748
	$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.pgsql.test
749

750
e2e.mssql.test: $(GO_SOURCES)
751
	$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mssql.test
752

753
e2e.sqlite.test: $(GO_SOURCES)
754
	$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.sqlite.test -tags '$(TEST_TAGS)'
755

756
.PHONY: check
757
check: test
758

759
.PHONY: install $(TAGS_PREREQ)
760
install: $(wildcard *.go)
761
	CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
762

763
.PHONY: build
764
build: frontend backend
765

766
.PHONY: frontend
767
frontend: $(WEBPACK_DEST)
768

769
.PHONY: backend
770
backend: go-check generate-backend $(EXECUTABLE)
771

772
# We generate the backend before the frontend in case we in future we want to generate things in the frontend from generated files in backend
773
.PHONY: generate
774
generate: generate-backend
775

776
.PHONY: generate-backend
777
generate-backend: $(TAGS_PREREQ) generate-go
778

779
.PHONY: generate-go
780
generate-go: $(TAGS_PREREQ)
781
	@echo "Running go generate..."
782
	@CC= GOOS= GOARCH= $(GO) generate -tags '$(TAGS)' $(GO_PACKAGES)
783

784
.PHONY: security-check
785
security-check:
786
	go run $(GOVULNCHECK_PACKAGE) ./...
787

788
$(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
789
	CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
790

791
.PHONY: release
792
release: frontend generate release-windows release-linux release-darwin release-freebsd release-copy release-compress vendor release-sources release-docs release-check
793

794
$(DIST_DIRS):
795
	mkdir -p $(DIST_DIRS)
796

797
.PHONY: release-windows
798
release-windows: | $(DIST_DIRS)
799
	CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
800
ifeq (,$(findstring gogit,$(TAGS)))
801
	CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'osusergo gogit $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION)-gogit .
802
endif
803

804
.PHONY: release-linux
805
release-linux: | $(DIST_DIRS)
806
	CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(LINUX_ARCHS)' -out gitea-$(VERSION) .
807

808
.PHONY: release-darwin
809
release-darwin: | $(DIST_DIRS)
810
	CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin-10.12/amd64,darwin-10.12/arm64' -out gitea-$(VERSION) .
811

812
.PHONY: release-freebsd
813
release-freebsd: | $(DIST_DIRS)
814
	CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'freebsd/amd64' -out gitea-$(VERSION) .
815

816
.PHONY: release-copy
817
release-copy: | $(DIST_DIRS)
818
	cd $(DIST); for file in `find . -type f -name "*"`; do cp $${file} ./release/; done;
819

820
.PHONY: release-check
821
release-check: | $(DIST_DIRS)
822
	cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done;
823

824
.PHONY: release-compress
825
release-compress: | $(DIST_DIRS)
826
	cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && $(GO) run $(GXZ_PACKAGE) -k -9 $${file}; done;
827

828
.PHONY: release-sources
829
release-sources: | $(DIST_DIRS)
830
	echo $(VERSION) > $(STORED_VERSION_FILE)
831
# bsdtar needs a ^ to prevent matching subdirectories
832
	$(eval EXCL := --exclude=$(shell tar --help | grep -q bsdtar && echo "^")./)
833
# use transform to a add a release-folder prefix; in bsdtar the transform parameter equivalent is -s
834
	$(eval TRANSFORM := $(shell tar --help | grep -q bsdtar && echo "-s '/^./gitea-src-$(VERSION)/'" || echo "--transform 's|^./|gitea-src-$(VERSION)/|'"))
835
	tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) $(TRANSFORM) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
836
	rm -f $(STORED_VERSION_FILE)
837

838
.PHONY: release-docs
839
release-docs: | $(DIST_DIRS) docs
840
	tar -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs .
841

842
.PHONY: deps
843
deps: deps-frontend deps-backend deps-tools deps-py
844

845
.PHONY: deps-py
846
deps-py: .venv
847

848
.PHONY: deps-frontend
849
deps-frontend: node_modules
850

851
.PHONY: deps-backend
852
deps-backend:
853
	$(GO) mod download
854

855
.PHONY: deps-tools
856
deps-tools:
857
	$(GO) install $(AIR_PACKAGE)
858
	$(GO) install $(EDITORCONFIG_CHECKER_PACKAGE)
859
	$(GO) install $(GOFUMPT_PACKAGE)
860
	$(GO) install $(GOLANGCI_LINT_PACKAGE)
861
	$(GO) install $(GXZ_PACKAGE)
862
	$(GO) install $(MISSPELL_PACKAGE)
863
	$(GO) install $(SWAGGER_PACKAGE)
864
	$(GO) install $(XGO_PACKAGE)
865
	$(GO) install $(GO_LICENSES_PACKAGE)
866
	$(GO) install $(GOVULNCHECK_PACKAGE)
867
	$(GO) install $(ACTIONLINT_PACKAGE)
868

869
node_modules: package-lock.json
870
	npm install --no-save
871
	@touch node_modules
872

873
.venv: poetry.lock
874
	poetry install --no-root
875
	@touch .venv
876

877
.PHONY: update
878
update: update-js update-py
879

880
.PHONY: update-js
881
update-js: node-check | node_modules
882
	npx updates -u -f package.json
883
	rm -rf node_modules package-lock.json
884
	npm install --package-lock
885
	@touch node_modules
886

887
.PHONY: update-py
888
update-py: node-check | node_modules
889
	npx updates -u -f pyproject.toml
890
	rm -rf .venv poetry.lock
891
	poetry install --no-root
892
	@touch .venv
893

894
.PHONY: fomantic
895
fomantic:
896
	rm -rf $(FOMANTIC_WORK_DIR)/build
897
	cd $(FOMANTIC_WORK_DIR) && npm install --no-save
898
	cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config
899
	cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/
900
	$(SED_INPLACE) -e 's/  overrideBrowserslist\r/  overrideBrowserslist: ["defaults"]\r/g' $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/tasks/config/tasks.js
901
	cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build
902
	# fomantic uses "touchstart" as click event for some browsers, it's not ideal, so we force fomantic to always use "click" as click event
903
	$(SED_INPLACE) -e 's/clickEvent[ \t]*=/clickEvent = "click", unstableClickEvent =/g' $(FOMANTIC_WORK_DIR)/build/semantic.js
904
	$(SED_INPLACE) -e 's/\r//g' $(FOMANTIC_WORK_DIR)/build/semantic.css $(FOMANTIC_WORK_DIR)/build/semantic.js
905
	rm -f $(FOMANTIC_WORK_DIR)/build/*.min.*
906

907
.PHONY: webpack
908
webpack: $(WEBPACK_DEST)
909

910
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json
911
	@$(MAKE) -s node-check node_modules
912
	rm -rf $(WEBPACK_DEST_ENTRIES)
913
	npx webpack
914
	@touch $(WEBPACK_DEST)
915

916
.PHONY: svg
917
svg: node-check | node_modules
918
	rm -rf $(SVG_DEST_DIR)
919
	node tools/generate-svg.js
920

921
.PHONY: svg-check
922
svg-check: svg
923
	@git add $(SVG_DEST_DIR)
924
	@diff=$$(git diff --color=always --cached $(SVG_DEST_DIR)); \
925
	if [ -n "$$diff" ]; then \
926
		echo "Please run 'make svg' and 'git add $(SVG_DEST_DIR)' and commit the result:"; \
927
		echo "$${diff}"; \
928
		exit 1; \
929
	fi
930

931
.PHONY: lockfile-check
932
lockfile-check:
933
	npm install --package-lock-only
934
	@diff=$$(git diff --color=always package-lock.json); \
935
	if [ -n "$$diff" ]; then \
936
		echo "package-lock.json is inconsistent with package.json"; \
937
		echo "Please run 'npm install --package-lock-only' and commit the result:"; \
938
		echo "$${diff}"; \
939
		exit 1; \
940
	fi
941

942
.PHONY: update-translations
943
update-translations:
944
	mkdir -p ./translations
945
	cd ./translations && curl -L https://crowdin.com/download/project/gitea.zip > gitea.zip && unzip gitea.zip
946
	rm ./translations/gitea.zip
947
	$(SED_INPLACE) -e 's/="/=/g' -e 's/"$$//g' ./translations/*.ini
948
	$(SED_INPLACE) -e 's/\\"/"/g' ./translations/*.ini
949
	mv ./translations/*.ini ./options/locale/
950
	rmdir ./translations
951

952
.PHONY: generate-license
953
generate-license:
954
	$(GO) run build/generate-licenses.go
955

956
.PHONY: generate-gitignore
957
generate-gitignore:
958
	$(GO) run build/generate-gitignores.go
959

960
.PHONY: generate-images
961
generate-images: | node_modules
962
	npm install --no-save fabric@6.0.0-beta20 imagemin-zopfli@7
963
	node tools/generate-images.js $(TAGS)
964

965
.PHONY: generate-manpage
966
generate-manpage:
967
	@[ -f gitea ] || make backend
968
	@mkdir -p man/man1/ man/man5
969
	@./gitea docs --man > man/man1/gitea.1
970
	@gzip -9 man/man1/gitea.1 && echo man/man1/gitea.1.gz created
971
	@#TODO A small script that formats config-cheat-sheet.en-us.md nicely for use as a config man page
972

973
.PHONY: docker
974
docker:
975
	docker build --disable-content-trust=false -t $(DOCKER_REF) .
976
# support also build args docker build --build-arg GITEA_VERSION=v1.2.3 --build-arg TAGS="bindata sqlite sqlite_unlock_notify"  .
977

978
# This endif closes the if at the top of the file
979
endif
980

981
# Disable parallel execution because it would break some targets that don't
982
# specify exact dependencies like 'backend' which does currently not depend
983
# on 'frontend' to enable Node.js-less builds from source tarballs.
984
.NOTPARALLEL:
985

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.