gitea
Зеркало из https://github.com/go-gitea/gitea
/
Makefile
995 строк · 38.0 Кб
1ifeq ($(USE_REPO_TEST_DIR),1)
2
3# This rule replaces the whole Makefile when we're trying to use /tmp repository temporary files
4location = $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
5self := $(location)
6
7%:
8@tmpdir=`mktemp --tmpdir -d` ; \
9echo Using temporary directory $$tmpdir for test repositories ; \
10USE_REPO_TEST_DIR= $(MAKE) -f $(self) --no-print-directory REPO_TEST_DIR=$$tmpdir/ $@ ; \
11STATUS=$$? ; rm -r "$$tmpdir" ; exit $$STATUS
12
13else
14
15# This is the "normal" part of the Makefile
16
17DIST := dist
18DIST_DIRS := $(DIST)/binaries $(DIST)/release
19IMPORT := code.gitea.io/gitea
20
21GO ?= go
22SHASUM ?= shasum -a 256
23HAS_GO := $(shell hash $(GO) > /dev/null 2>&1 && echo yes)
24COMMA := ,
25
26XGO_VERSION := go-1.23.x
27
28AIR_PACKAGE ?= github.com/air-verse/air@v1
29EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.7.0
30GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.7.0
31GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.3
32GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11
33MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.5.1
34SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.31.0
35XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
36GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1
37GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1
38ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1
39GOPLS_PACKAGE ?= golang.org/x/tools/gopls@v0.15.3
40
41DOCKER_IMAGE ?= gitea/gitea
42DOCKER_TAG ?= latest
43DOCKER_REF := $(DOCKER_IMAGE):$(DOCKER_TAG)
44
45ifeq ($(HAS_GO), yes)
46CGO_EXTRA_CFLAGS := -DSQLITE_MAX_VARIABLE_NUMBER=32766
47CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
48endif
49
50ifeq ($(GOOS),windows)
51IS_WINDOWS := yes
52else ifeq ($(patsubst Windows%,Windows,$(OS)),Windows)
53ifeq ($(GOOS),)
54IS_WINDOWS := yes
55endif
56endif
57ifeq ($(IS_WINDOWS),yes)
58GOFLAGS := -v -buildmode=exe
59EXECUTABLE ?= gitea.exe
60else
61GOFLAGS := -v
62EXECUTABLE ?= gitea
63endif
64
65ifeq ($(shell sed --version 2>/dev/null | grep -q GNU && echo gnu),gnu)
66SED_INPLACE := sed -i
67else
68SED_INPLACE := sed -i ''
69endif
70
71EXTRA_GOFLAGS ?=
72
73MAKE_VERSION := $(shell "$(MAKE)" -v | cat | head -n 1)
74MAKE_EVIDENCE_DIR := .make_evidence
75
76ifeq ($(RACE_ENABLED),true)
77GOFLAGS += -race
78GOTESTFLAGS += -race
79endif
80
81STORED_VERSION_FILE := VERSION
82HUGO_VERSION ?= 0.111.3
83
84GITHUB_REF_TYPE ?= branch
85GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
86
87ifneq ($(GITHUB_REF_TYPE),branch)
88VERSION ?= $(subst v,,$(GITHUB_REF_NAME))
89GITEA_VERSION ?= $(VERSION)
90else
91ifneq ($(GITHUB_REF_NAME),)
92VERSION ?= $(subst release/v,,$(GITHUB_REF_NAME))-nightly
93else
94VERSION ?= main
95endif
96
97STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null)
98ifneq ($(STORED_VERSION),)
99GITEA_VERSION ?= $(STORED_VERSION)
100else
101GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
102endif
103endif
104
105# if version = "main" then update version to "nightly"
106ifeq ($(VERSION),main)
107VERSION := main-nightly
108endif
109
110LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
111
112LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
113
114GO_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/))
115MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.gitea.io/gitea/models/migrations/...)
116
117FOMANTIC_WORK_DIR := web_src/fomantic
118
119WEBPACK_SOURCES := $(shell find web_src/js web_src/css -type f)
120WEBPACK_CONFIGS := webpack.config.js tailwind.config.js
121WEBPACK_DEST := public/assets/js/index.js public/assets/css/index.css
122WEBPACK_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts
123
124BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
125BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))
126
127GENERATED_GO_DEST := modules/charset/invisible_gen.go modules/charset/ambiguous_gen.go
128
129SVG_DEST_DIR := public/assets/img/svg
130
131AIR_TMP_DIR := .air
132
133GO_LICENSE_TMP_DIR := .go-licenses
134GO_LICENSE_FILE := assets/go-licenses.json
135
136TAGS ?=
137TAGS_SPLIT := $(subst $(COMMA), ,$(TAGS))
138TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
139
140TEST_TAGS ?= $(TAGS_SPLIT) sqlite sqlite_unlock_notify
141
142TAR_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
144GO_DIRS := build cmd models modules routers services tests
145WEB_DIRS := web_src/js web_src/css
146
147ESLINT_FILES := web_src/js tools *.js *.ts tests/e2e
148STYLELINT_FILES := web_src/css web_src/js/components/*.vue
149SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) templates options/locale/locale_en-US.ini .github $(filter-out CHANGELOG.md, $(wildcard *.go *.js *.md *.yml *.yaml *.toml))
150EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.ini
151
152GO_SOURCES := $(wildcard *.go)
153GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" ! -path modules/options/bindata.go ! -path modules/public/bindata.go ! -path modules/templates/bindata.go)
154GO_SOURCES += $(GENERATED_GO_DEST)
155GO_SOURCES_NO_BINDATA := $(GO_SOURCES)
156
157ifeq ($(filter $(TAGS_SPLIT),bindata),bindata)
158GO_SOURCES += $(BINDATA_DEST)
159GENERATED_GO_DEST += $(BINDATA_DEST)
160endif
161
162# Force installation of playwright dependencies by setting this flag
163ifdef DEPS_PLAYWRIGHT
164PLAYWRIGHT_FLAGS += --with-deps
165endif
166
167SWAGGER_SPEC := templates/swagger/v1_json.tmpl
168SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl \| JSEscape}}/api/v1"|g
169SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl \| JSEscape}}/api/v1"|"basePath": "/api/v1"|g
170SWAGGER_EXCLUDE := code.gitea.io/sdk
171SWAGGER_NEWLINE_COMMAND := -e '$$a\'
172
173TEST_MYSQL_HOST ?= mysql:3306
174TEST_MYSQL_DBNAME ?= testgitea
175TEST_MYSQL_USERNAME ?= root
176TEST_MYSQL_PASSWORD ?=
177TEST_PGSQL_HOST ?= pgsql:5432
178TEST_PGSQL_DBNAME ?= testgitea
179TEST_PGSQL_USERNAME ?= postgres
180TEST_PGSQL_PASSWORD ?= postgres
181TEST_PGSQL_SCHEMA ?= gtestschema
182TEST_MINIO_ENDPOINT ?= minio:9000
183TEST_MSSQL_HOST ?= mssql:1433
184TEST_MSSQL_DBNAME ?= gitea
185TEST_MSSQL_USERNAME ?= sa
186TEST_MSSQL_PASSWORD ?= MwantsaSecurePassword1
187
188.PHONY: all
189all: build
190
191.PHONY: help
192help:
193@echo "Make Routines:"
194@echo " - \"\" equivalent to \"build\""
195@echo " - build build everything"
196@echo " - frontend build frontend files"
197@echo " - backend build backend files"
198@echo " - watch watch everything and continuously rebuild"
199@echo " - watch-frontend watch frontend files and continuously rebuild"
200@echo " - watch-backend watch backend files and continuously rebuild"
201@echo " - clean delete backend and integration files"
202@echo " - clean-all delete backend, frontend and integration files"
203@echo " - deps install dependencies"
204@echo " - deps-frontend install frontend dependencies"
205@echo " - deps-backend install backend dependencies"
206@echo " - deps-tools install tool dependencies"
207@echo " - deps-py install python dependencies"
208@echo " - lint lint everything"
209@echo " - lint-fix lint everything and fix issues"
210@echo " - lint-actions lint action workflow files"
211@echo " - lint-frontend lint frontend files"
212@echo " - lint-frontend-fix lint frontend files and fix issues"
213@echo " - lint-backend lint backend files"
214@echo " - lint-backend-fix lint backend files and fix issues"
215@echo " - lint-go lint go files"
216@echo " - lint-go-fix lint go files and fix issues"
217@echo " - lint-go-vet lint go files with vet"
218@echo " - lint-go-gopls lint go files with gopls"
219@echo " - lint-js lint js files"
220@echo " - lint-js-fix lint js files and fix issues"
221@echo " - lint-css lint css files"
222@echo " - lint-css-fix lint css files and fix issues"
223@echo " - lint-md lint markdown files"
224@echo " - lint-swagger lint swagger files"
225@echo " - lint-templates lint template files"
226@echo " - lint-yaml lint yaml files"
227@echo " - lint-spell lint spelling"
228@echo " - lint-spell-fix lint spelling and fix issues"
229@echo " - checks run various consistency checks"
230@echo " - checks-frontend check frontend files"
231@echo " - checks-backend check backend files"
232@echo " - test test everything"
233@echo " - test-frontend test frontend files"
234@echo " - test-backend test backend files"
235@echo " - test-e2e[\#TestSpecificName] test end to end using playwright"
236@echo " - update update js and py dependencies"
237@echo " - update-js update js dependencies"
238@echo " - update-py update py dependencies"
239@echo " - webpack build webpack files"
240@echo " - svg build svg files"
241@echo " - fomantic build fomantic files"
242@echo " - generate run \"go generate\""
243@echo " - fmt format the Go code"
244@echo " - generate-license update license files"
245@echo " - generate-gitignore update gitignore files"
246@echo " - generate-manpage generate manpage"
247@echo " - generate-swagger generate the swagger spec from code comments"
248@echo " - swagger-validate check if the swagger spec is valid"
249@echo " - go-licenses regenerate go licenses"
250@echo " - tidy run go mod tidy"
251@echo " - test[\#TestSpecificName] run unit test"
252@echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite"
253
254.PHONY: go-check
255go-check:
256$(eval MIN_GO_VERSION_STR := $(shell grep -Eo '^go\s+[0-9]+\.[0-9]+' go.mod | cut -d' ' -f2))
257$(eval MIN_GO_VERSION := $(shell printf "%03d%03d" $(shell echo '$(MIN_GO_VERSION_STR)' | tr '.' ' ')))
258$(eval GO_VERSION := $(shell printf "%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9]+' | tr '.' ' ');))
259@if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \
260echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://go.dev/dl/"; \
261exit 1; \
262fi
263
264.PHONY: git-check
265git-check:
266@if git lfs >/dev/null 2>&1 ; then : ; else \
267echo "Gitea requires git with lfs support to run tests." ; \
268exit 1; \
269fi
270
271.PHONY: node-check
272node-check:
273$(eval MIN_NODE_VERSION_STR := $(shell grep -Eo '"node":.*[0-9.]+"' package.json | sed -n 's/.*[^0-9.]\([0-9.]*\)"/\1/p'))
274$(eval MIN_NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_NODE_VERSION_STR)' | tr '.' ' ')))
275$(eval NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell node -v | cut -c2- | tr '.' ' ');))
276$(eval NPM_MISSING := $(shell hash npm > /dev/null 2>&1 || echo 1))
277@if [ "$(NODE_VERSION)" -lt "$(MIN_NODE_VERSION)" -o "$(NPM_MISSING)" = "1" ]; then \
278echo "Gitea requires Node.js $(MIN_NODE_VERSION_STR) or greater and npm to build. You can get it at https://nodejs.org/en/download/"; \
279exit 1; \
280fi
281
282.PHONY: clean-all
283clean-all: clean
284rm -rf $(WEBPACK_DEST_ENTRIES) node_modules
285
286.PHONY: clean
287clean:
288rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST) $(BINDATA_HASH) \
289integrations*.test \
290e2e*.test \
291tests/integration/gitea-integration-* \
292tests/integration/indexers-* \
293tests/mysql.ini tests/pgsql.ini tests/mssql.ini man/ \
294tests/e2e/gitea-e2e-*/ \
295tests/e2e/indexers-*/ \
296tests/e2e/reports/ tests/e2e/test-artifacts/ tests/e2e/test-snapshots/
297
298.PHONY: fmt
299fmt:
300@GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}'
301$(eval TEMPLATES := $(shell find templates -type f -name '*.tmpl'))
302@# strip whitespace after '{{' or '(' and before '}}' or ')' unless there is only
303@# whitespace before it
304@$(SED_INPLACE) \
305-e 's/{{[ ]\{1,\}/{{/g' -e '/^[ ]\{1,\}}}/! s/[ ]\{1,\}}}/}}/g' \
306-e 's/([ ]\{1,\}/(/g' -e '/^[ ]\{1,\})/! s/[ ]\{1,\})/)/g' \
307$(TEMPLATES)
308
309.PHONY: fmt-check
310fmt-check: fmt
311@diff=$$(git diff --color=always $(GO_SOURCES) templates $(WEB_DIRS)); \
312if [ -n "$$diff" ]; then \
313echo "Please run 'make fmt' and commit the result:"; \
314echo "$${diff}"; \
315exit 1; \
316fi
317
318.PHONY: $(TAGS_EVIDENCE)
319$(TAGS_EVIDENCE):
320@mkdir -p $(MAKE_EVIDENCE_DIR)
321@echo "$(TAGS)" > $(TAGS_EVIDENCE)
322
323ifneq "$(TAGS)" "$(shell cat $(TAGS_EVIDENCE) 2>/dev/null)"
324TAGS_PREREQ := $(TAGS_EVIDENCE)
325endif
326
327.PHONY: generate-swagger
328generate-swagger: $(SWAGGER_SPEC)
329
330$(SWAGGER_SPEC): $(GO_SOURCES_NO_BINDATA)
331$(GO) run $(SWAGGER_PACKAGE) generate spec -x "$(SWAGGER_EXCLUDE)" -o './$(SWAGGER_SPEC)'
332$(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
333$(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)'
334
335.PHONY: swagger-check
336swagger-check: generate-swagger
337@diff=$$(git diff --color=always '$(SWAGGER_SPEC)'); \
338if [ -n "$$diff" ]; then \
339echo "Please run 'make generate-swagger' and commit the result:"; \
340echo "$${diff}"; \
341exit 1; \
342fi
343
344.PHONY: swagger-validate
345swagger-validate:
346$(SED_INPLACE) '$(SWAGGER_SPEC_S_JSON)' './$(SWAGGER_SPEC)'
347$(GO) run $(SWAGGER_PACKAGE) validate './$(SWAGGER_SPEC)'
348$(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
349
350.PHONY: checks
351checks: checks-frontend checks-backend
352
353.PHONY: checks-frontend
354checks-frontend: lockfile-check svg-check
355
356.PHONY: checks-backend
357checks-backend: tidy-check swagger-check fmt-check swagger-validate security-check
358
359.PHONY: lint
360lint: lint-frontend lint-backend lint-spell
361
362.PHONY: lint-fix
363lint-fix: lint-frontend-fix lint-backend-fix lint-spell-fix
364
365.PHONY: lint-frontend
366lint-frontend: lint-js lint-css
367
368.PHONY: lint-frontend-fix
369lint-frontend-fix: lint-js-fix lint-css-fix
370
371.PHONY: lint-backend
372lint-backend: lint-go lint-go-vet lint-go-gopls lint-editorconfig
373
374.PHONY: lint-backend-fix
375lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig
376
377.PHONY: lint-js
378lint-js: node_modules
379npx eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES)
380# npx tsc
381
382.PHONY: lint-js-fix
383lint-js-fix: node_modules
384npx eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES) --fix
385# npx tsc
386
387.PHONY: lint-css
388lint-css: node_modules
389npx stylelint --color --max-warnings=0 $(STYLELINT_FILES)
390
391.PHONY: lint-css-fix
392lint-css-fix: node_modules
393npx stylelint --color --max-warnings=0 $(STYLELINT_FILES) --fix
394
395.PHONY: lint-swagger
396lint-swagger: node_modules
397npx spectral lint -q -F hint $(SWAGGER_SPEC)
398
399.PHONY: lint-md
400lint-md: node_modules
401npx markdownlint *.md
402
403.PHONY: lint-spell
404lint-spell:
405@go run $(MISSPELL_PACKAGE) -dict tools/misspellings.csv -error $(SPELLCHECK_FILES)
406
407.PHONY: lint-spell-fix
408lint-spell-fix:
409@go run $(MISSPELL_PACKAGE) -dict tools/misspellings.csv -w $(SPELLCHECK_FILES)
410
411.PHONY: lint-go
412lint-go:
413$(GO) run $(GOLANGCI_LINT_PACKAGE) run
414
415.PHONY: lint-go-fix
416lint-go-fix:
417$(GO) run $(GOLANGCI_LINT_PACKAGE) run --fix
418
419# workaround step for the lint-go-windows CI task because 'go run' can not
420# have distinct GOOS/GOARCH for its build and run steps
421.PHONY: lint-go-windows
422lint-go-windows:
423@GOOS= GOARCH= $(GO) install $(GOLANGCI_LINT_PACKAGE)
424golangci-lint run
425
426.PHONY: lint-go-vet
427lint-go-vet:
428@echo "Running go vet..."
429@GOOS= GOARCH= $(GO) build code.gitea.io/gitea-vet
430@$(GO) vet -vettool=gitea-vet ./...
431
432.PHONY: lint-go-gopls
433lint-go-gopls:
434@echo "Running gopls check..."
435@GO=$(GO) GOPLS_PACKAGE=$(GOPLS_PACKAGE) tools/lint-go-gopls.sh $(GO_SOURCES_NO_BINDATA)
436
437.PHONY: lint-editorconfig
438lint-editorconfig:
439@$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) $(EDITORCONFIG_FILES)
440
441.PHONY: lint-actions
442lint-actions:
443$(GO) run $(ACTIONLINT_PACKAGE)
444
445.PHONY: lint-templates
446lint-templates: .venv node_modules
447@node tools/lint-templates-svg.js
448@poetry run djlint $(shell find templates -type f -iname '*.tmpl')
449
450.PHONY: lint-yaml
451lint-yaml: .venv
452@poetry run yamllint .
453
454.PHONY: watch
455watch:
456@bash tools/watch.sh
457
458.PHONY: watch-frontend
459watch-frontend: node-check node_modules
460@rm -rf $(WEBPACK_DEST_ENTRIES)
461NODE_ENV=development npx webpack --watch --progress
462
463.PHONY: watch-backend
464watch-backend: go-check
465GITEA_RUN_MODE=dev $(GO) run $(AIR_PACKAGE) -c .air.toml
466
467.PHONY: test
468test: test-frontend test-backend
469
470.PHONY: test-backend
471test-backend:
472@echo "Running go test with $(GOTESTFLAGS) -tags '$(TEST_TAGS)'..."
473@$(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' $(GO_TEST_PACKAGES)
474
475.PHONY: test-frontend
476test-frontend: node_modules
477npx vitest
478
479.PHONY: test-check
480test-check:
481@echo "Running test-check...";
482@diff=$$(git status -s); \
483if [ -n "$$diff" ]; then \
484echo "make test-backend has changed files in the source tree:"; \
485echo "$${diff}"; \
486echo "You should change the tests to create these files in a temporary directory."; \
487echo "Do not simply add these files to .gitignore"; \
488exit 1; \
489fi
490
491.PHONY: test\#%
492test\#%:
493@echo "Running go test with -tags '$(TEST_TAGS)'..."
494@$(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -run $(subst .,/,$*) $(GO_TEST_PACKAGES)
495
496.PHONY: coverage
497coverage:
498grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' coverage.out > coverage-bodged.out
499grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' integration.coverage.out > integration.coverage-bodged.out
500$(GO) run build/gocovmerge.go integration.coverage-bodged.out coverage-bodged.out > coverage.all
501
502.PHONY: unit-test-coverage
503unit-test-coverage:
504@echo "Running unit-test-coverage $(GOTESTFLAGS) -tags '$(TEST_TAGS)'..."
505@$(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
506
507.PHONY: tidy
508tidy:
509$(eval MIN_GO_VERSION := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2))
510$(GO) mod tidy -compat=$(MIN_GO_VERSION)
511@$(MAKE) --no-print-directory $(GO_LICENSE_FILE)
512
513vendor: go.mod go.sum
514$(GO) mod vendor
515@touch vendor
516
517.PHONY: tidy-check
518tidy-check: tidy
519@diff=$$(git diff --color=always go.mod go.sum $(GO_LICENSE_FILE)); \
520if [ -n "$$diff" ]; then \
521echo "Please run 'make tidy' and commit the result:"; \
522echo "$${diff}"; \
523exit 1; \
524fi
525
526.PHONY: go-licenses
527go-licenses: $(GO_LICENSE_FILE)
528
529$(GO_LICENSE_FILE): go.mod go.sum
530-$(GO) run $(GO_LICENSES_PACKAGE) save . --force --save_path=$(GO_LICENSE_TMP_DIR) 2>/dev/null
531$(GO) run build/generate-go-licenses.go $(GO_LICENSE_TMP_DIR) $(GO_LICENSE_FILE)
532@rm -rf $(GO_LICENSE_TMP_DIR)
533
534generate-ini-sqlite:
535sed -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
536-e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
537-e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \
538tests/sqlite.ini.tmpl > tests/sqlite.ini
539
540.PHONY: test-sqlite
541test-sqlite: integrations.sqlite.test generate-ini-sqlite
542GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test
543
544.PHONY: test-sqlite\#%
545test-sqlite\#%: integrations.sqlite.test generate-ini-sqlite
546GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test -test.run $(subst .,/,$*)
547
548.PHONY: test-sqlite-migration
549test-sqlite-migration: migrations.sqlite.test migrations.individual.sqlite.test
550
551generate-ini-mysql:
552sed -e 's|{{TEST_MYSQL_HOST}}|${TEST_MYSQL_HOST}|g' \
553-e 's|{{TEST_MYSQL_DBNAME}}|${TEST_MYSQL_DBNAME}|g' \
554-e 's|{{TEST_MYSQL_USERNAME}}|${TEST_MYSQL_USERNAME}|g' \
555-e 's|{{TEST_MYSQL_PASSWORD}}|${TEST_MYSQL_PASSWORD}|g' \
556-e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
557-e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
558-e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \
559tests/mysql.ini.tmpl > tests/mysql.ini
560
561.PHONY: test-mysql
562test-mysql: integrations.mysql.test generate-ini-mysql
563GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test
564
565.PHONY: test-mysql\#%
566test-mysql\#%: integrations.mysql.test generate-ini-mysql
567GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test -test.run $(subst .,/,$*)
568
569.PHONY: test-mysql-migration
570test-mysql-migration: migrations.mysql.test migrations.individual.mysql.test
571
572generate-ini-pgsql:
573sed -e 's|{{TEST_PGSQL_HOST}}|${TEST_PGSQL_HOST}|g' \
574-e 's|{{TEST_PGSQL_DBNAME}}|${TEST_PGSQL_DBNAME}|g' \
575-e 's|{{TEST_PGSQL_USERNAME}}|${TEST_PGSQL_USERNAME}|g' \
576-e 's|{{TEST_PGSQL_PASSWORD}}|${TEST_PGSQL_PASSWORD}|g' \
577-e 's|{{TEST_PGSQL_SCHEMA}}|${TEST_PGSQL_SCHEMA}|g' \
578-e 's|{{TEST_MINIO_ENDPOINT}}|${TEST_MINIO_ENDPOINT}|g' \
579-e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
580-e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
581-e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \
582tests/pgsql.ini.tmpl > tests/pgsql.ini
583
584.PHONY: test-pgsql
585test-pgsql: integrations.pgsql.test generate-ini-pgsql
586GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test
587
588.PHONY: test-pgsql\#%
589test-pgsql\#%: integrations.pgsql.test generate-ini-pgsql
590GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test -test.run $(subst .,/,$*)
591
592.PHONY: test-pgsql-migration
593test-pgsql-migration: migrations.pgsql.test migrations.individual.pgsql.test
594
595generate-ini-mssql:
596sed -e 's|{{TEST_MSSQL_HOST}}|${TEST_MSSQL_HOST}|g' \
597-e 's|{{TEST_MSSQL_DBNAME}}|${TEST_MSSQL_DBNAME}|g' \
598-e 's|{{TEST_MSSQL_USERNAME}}|${TEST_MSSQL_USERNAME}|g' \
599-e 's|{{TEST_MSSQL_PASSWORD}}|${TEST_MSSQL_PASSWORD}|g' \
600-e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
601-e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
602-e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \
603tests/mssql.ini.tmpl > tests/mssql.ini
604
605.PHONY: test-mssql
606test-mssql: integrations.mssql.test generate-ini-mssql
607GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test
608
609.PHONY: test-mssql\#%
610test-mssql\#%: integrations.mssql.test generate-ini-mssql
611GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test -test.run $(subst .,/,$*)
612
613.PHONY: test-mssql-migration
614test-mssql-migration: migrations.mssql.test migrations.individual.mssql.test
615
616.PHONY: playwright
617playwright: deps-frontend
618npx playwright install $(PLAYWRIGHT_FLAGS)
619
620.PHONY: test-e2e%
621test-e2e%: TEST_TYPE ?= e2e
622# Clear display env variable. Otherwise, chromium tests can fail.
623DISPLAY=
624
625.PHONY: test-e2e
626test-e2e: test-e2e-sqlite
627
628.PHONY: test-e2e-sqlite
629test-e2e-sqlite: playwright e2e.sqlite.test generate-ini-sqlite
630GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./e2e.sqlite.test
631
632.PHONY: test-e2e-sqlite\#%
633test-e2e-sqlite\#%: playwright e2e.sqlite.test generate-ini-sqlite
634GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./e2e.sqlite.test -test.run TestE2e/$*
635
636.PHONY: test-e2e-mysql
637test-e2e-mysql: playwright e2e.mysql.test generate-ini-mysql
638GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./e2e.mysql.test
639
640.PHONY: test-e2e-mysql\#%
641test-e2e-mysql\#%: playwright e2e.mysql.test generate-ini-mysql
642GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./e2e.mysql.test -test.run TestE2e/$*
643
644.PHONY: test-e2e-pgsql
645test-e2e-pgsql: playwright e2e.pgsql.test generate-ini-pgsql
646GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./e2e.pgsql.test
647
648.PHONY: test-e2e-pgsql\#%
649test-e2e-pgsql\#%: playwright e2e.pgsql.test generate-ini-pgsql
650GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./e2e.pgsql.test -test.run TestE2e/$*
651
652.PHONY: test-e2e-mssql
653test-e2e-mssql: playwright e2e.mssql.test generate-ini-mssql
654GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test
655
656.PHONY: test-e2e-mssql\#%
657test-e2e-mssql\#%: playwright e2e.mssql.test generate-ini-mssql
658GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test -test.run TestE2e/$*
659
660.PHONY: bench-sqlite
661bench-sqlite: integrations.sqlite.test generate-ini-sqlite
662GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
663
664.PHONY: bench-mysql
665bench-mysql: integrations.mysql.test generate-ini-mysql
666GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
667
668.PHONY: bench-mssql
669bench-mssql: integrations.mssql.test generate-ini-mssql
670GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
671
672.PHONY: bench-pgsql
673bench-pgsql: integrations.pgsql.test generate-ini-pgsql
674GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
675
676.PHONY: integration-test-coverage
677integration-test-coverage: integrations.cover.test generate-ini-mysql
678GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
679
680.PHONY: integration-test-coverage-sqlite
681integration-test-coverage-sqlite: integrations.cover.sqlite.test generate-ini-sqlite
682GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.cover.sqlite.test -test.coverprofile=integration.coverage.out
683
684integrations.mysql.test: git-check $(GO_SOURCES)
685$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.mysql.test
686
687integrations.pgsql.test: git-check $(GO_SOURCES)
688$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.pgsql.test
689
690integrations.mssql.test: git-check $(GO_SOURCES)
691$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.mssql.test
692
693integrations.sqlite.test: git-check $(GO_SOURCES)
694$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.sqlite.test -tags '$(TEST_TAGS)'
695
696integrations.cover.test: git-check $(GO_SOURCES)
697$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -coverpkg $(shell echo $(GO_TEST_PACKAGES) | tr ' ' ',') -o integrations.cover.test
698
699integrations.cover.sqlite.test: git-check $(GO_SOURCES)
700$(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)'
701
702.PHONY: migrations.mysql.test
703migrations.mysql.test: $(GO_SOURCES) generate-ini-mysql
704$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.mysql.test
705GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./migrations.mysql.test
706
707.PHONY: migrations.pgsql.test
708migrations.pgsql.test: $(GO_SOURCES) generate-ini-pgsql
709$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.pgsql.test
710GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./migrations.pgsql.test
711
712.PHONY: migrations.mssql.test
713migrations.mssql.test: $(GO_SOURCES) generate-ini-mssql
714$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.mssql.test
715GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./migrations.mssql.test
716
717.PHONY: migrations.sqlite.test
718migrations.sqlite.test: $(GO_SOURCES) generate-ini-sqlite
719$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.sqlite.test -tags '$(TEST_TAGS)'
720GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./migrations.sqlite.test
721
722.PHONY: migrations.individual.mysql.test
723migrations.individual.mysql.test: $(GO_SOURCES)
724GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
725
726.PHONY: migrations.individual.sqlite.test\#%
727migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite
728GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
729
730.PHONY: migrations.individual.pgsql.test
731migrations.individual.pgsql.test: $(GO_SOURCES)
732GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
733
734.PHONY: migrations.individual.pgsql.test\#%
735migrations.individual.pgsql.test\#%: $(GO_SOURCES) generate-ini-pgsql
736GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
737
738.PHONY: migrations.individual.mssql.test
739migrations.individual.mssql.test: $(GO_SOURCES) generate-ini-mssql
740GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
741
742.PHONY: migrations.individual.mssql.test\#%
743migrations.individual.mssql.test\#%: $(GO_SOURCES) generate-ini-mssql
744GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
745
746.PHONY: migrations.individual.sqlite.test
747migrations.individual.sqlite.test: $(GO_SOURCES) generate-ini-sqlite
748GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
749
750.PHONY: migrations.individual.sqlite.test\#%
751migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite
752GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
753
754e2e.mysql.test: $(GO_SOURCES)
755$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mysql.test
756
757e2e.pgsql.test: $(GO_SOURCES)
758$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.pgsql.test
759
760e2e.mssql.test: $(GO_SOURCES)
761$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mssql.test
762
763e2e.sqlite.test: $(GO_SOURCES)
764$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.sqlite.test -tags '$(TEST_TAGS)'
765
766.PHONY: check
767check: test
768
769.PHONY: install $(TAGS_PREREQ)
770install: $(wildcard *.go)
771CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
772
773.PHONY: build
774build: frontend backend
775
776.PHONY: frontend
777frontend: $(WEBPACK_DEST)
778
779.PHONY: backend
780backend: go-check generate-backend $(EXECUTABLE)
781
782# 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
783.PHONY: generate
784generate: generate-backend
785
786.PHONY: generate-backend
787generate-backend: $(TAGS_PREREQ) generate-go
788
789.PHONY: generate-go
790generate-go: $(TAGS_PREREQ)
791@echo "Running go generate..."
792@CC= GOOS= GOARCH= CGO_ENABLED=0 $(GO) generate -tags '$(TAGS)' ./...
793
794.PHONY: security-check
795security-check:
796go run $(GOVULNCHECK_PACKAGE) ./...
797
798$(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
799CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
800
801.PHONY: release
802release: frontend generate release-windows release-linux release-darwin release-freebsd release-copy release-compress vendor release-sources release-check
803
804$(DIST_DIRS):
805mkdir -p $(DIST_DIRS)
806
807.PHONY: release-windows
808release-windows: | $(DIST_DIRS)
809CGO_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) .
810ifeq (,$(findstring gogit,$(TAGS)))
811CGO_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 .
812endif
813
814.PHONY: release-linux
815release-linux: | $(DIST_DIRS)
816CGO_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) .
817
818.PHONY: release-darwin
819release-darwin: | $(DIST_DIRS)
820CGO_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) .
821
822.PHONY: release-freebsd
823release-freebsd: | $(DIST_DIRS)
824CGO_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) .
825
826.PHONY: release-copy
827release-copy: | $(DIST_DIRS)
828cd $(DIST); for file in `find . -type f -name "*"`; do cp $${file} ./release/; done;
829
830.PHONY: release-check
831release-check: | $(DIST_DIRS)
832cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done;
833
834.PHONY: release-compress
835release-compress: | $(DIST_DIRS)
836cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && $(GO) run $(GXZ_PACKAGE) -k -9 $${file}; done;
837
838.PHONY: release-sources
839release-sources: | $(DIST_DIRS)
840echo $(VERSION) > $(STORED_VERSION_FILE)
841# bsdtar needs a ^ to prevent matching subdirectories
842$(eval EXCL := --exclude=$(shell tar --help | grep -q bsdtar && echo "^")./)
843# use transform to a add a release-folder prefix; in bsdtar the transform parameter equivalent is -s
844$(eval TRANSFORM := $(shell tar --help | grep -q bsdtar && echo "-s '/^./gitea-src-$(VERSION)/'" || echo "--transform 's|^./|gitea-src-$(VERSION)/|'"))
845tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) $(TRANSFORM) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
846rm -f $(STORED_VERSION_FILE)
847
848.PHONY: deps
849deps: deps-frontend deps-backend deps-tools deps-py
850
851.PHONY: deps-py
852deps-py: .venv
853
854.PHONY: deps-frontend
855deps-frontend: node_modules
856
857.PHONY: deps-backend
858deps-backend:
859$(GO) mod download
860
861.PHONY: deps-tools
862deps-tools:
863$(GO) install $(AIR_PACKAGE) & \
864$(GO) install $(EDITORCONFIG_CHECKER_PACKAGE) & \
865$(GO) install $(GOFUMPT_PACKAGE) & \
866$(GO) install $(GOLANGCI_LINT_PACKAGE) & \
867$(GO) install $(GXZ_PACKAGE) & \
868$(GO) install $(MISSPELL_PACKAGE) & \
869$(GO) install $(SWAGGER_PACKAGE) & \
870$(GO) install $(XGO_PACKAGE) & \
871$(GO) install $(GO_LICENSES_PACKAGE) & \
872$(GO) install $(GOVULNCHECK_PACKAGE) & \
873$(GO) install $(ACTIONLINT_PACKAGE) & \
874$(GO) install $(GOPLS_PACKAGE) & \
875wait
876
877node_modules: package-lock.json
878npm install --no-save
879@touch node_modules
880
881.venv: poetry.lock
882poetry install
883@touch .venv
884
885.PHONY: update
886update: update-js update-py
887
888.PHONY: update-js
889update-js: node-check | node_modules
890npx updates -u -f package.json
891rm -rf node_modules package-lock.json
892npm install --package-lock
893npx nolyfill install
894npm install --package-lock
895@touch node_modules
896
897.PHONY: update-py
898update-py: node-check | node_modules
899npx updates -u -f pyproject.toml
900rm -rf .venv poetry.lock
901poetry install
902@touch .venv
903
904.PHONY: fomantic
905fomantic:
906rm -rf $(FOMANTIC_WORK_DIR)/build
907cd $(FOMANTIC_WORK_DIR) && npm install --no-save
908cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config
909cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/
910$(SED_INPLACE) -e 's/ overrideBrowserslist\r/ overrideBrowserslist: ["defaults"]\r/g' $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/tasks/config/tasks.js
911cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build
912# fomantic uses "touchstart" as click event for some browsers, it's not ideal, so we force fomantic to always use "click" as click event
913$(SED_INPLACE) -e 's/clickEvent[ \t]*=/clickEvent = "click", unstableClickEvent =/g' $(FOMANTIC_WORK_DIR)/build/semantic.js
914$(SED_INPLACE) -e 's/\r//g' $(FOMANTIC_WORK_DIR)/build/semantic.css $(FOMANTIC_WORK_DIR)/build/semantic.js
915rm -f $(FOMANTIC_WORK_DIR)/build/*.min.*
916
917.PHONY: webpack
918webpack: $(WEBPACK_DEST)
919
920$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json
921@$(MAKE) -s node-check node_modules
922@rm -rf $(WEBPACK_DEST_ENTRIES)
923@echo "Running webpack..."
924@BROWSERSLIST_IGNORE_OLD_DATA=true npx webpack
925@touch $(WEBPACK_DEST)
926
927.PHONY: svg
928svg: node-check | node_modules
929rm -rf $(SVG_DEST_DIR)
930node tools/generate-svg.js
931
932.PHONY: svg-check
933svg-check: svg
934@git add $(SVG_DEST_DIR)
935@diff=$$(git diff --color=always --cached $(SVG_DEST_DIR)); \
936if [ -n "$$diff" ]; then \
937echo "Please run 'make svg' and 'git add $(SVG_DEST_DIR)' and commit the result:"; \
938echo "$${diff}"; \
939exit 1; \
940fi
941
942.PHONY: lockfile-check
943lockfile-check:
944npm install --package-lock-only
945@diff=$$(git diff --color=always package-lock.json); \
946if [ -n "$$diff" ]; then \
947echo "package-lock.json is inconsistent with package.json"; \
948echo "Please run 'npm install --package-lock-only' and commit the result:"; \
949echo "$${diff}"; \
950exit 1; \
951fi
952
953.PHONY: update-translations
954update-translations:
955mkdir -p ./translations
956cd ./translations && curl -L https://crowdin.com/download/project/gitea.zip > gitea.zip && unzip gitea.zip
957rm ./translations/gitea.zip
958$(SED_INPLACE) -e 's/="/=/g' -e 's/"$$//g' ./translations/*.ini
959$(SED_INPLACE) -e 's/\\"/"/g' ./translations/*.ini
960mv ./translations/*.ini ./options/locale/
961rmdir ./translations
962
963.PHONY: generate-license
964generate-license:
965$(GO) run build/generate-licenses.go
966
967.PHONY: generate-gitignore
968generate-gitignore:
969$(GO) run build/generate-gitignores.go
970
971.PHONY: generate-images
972generate-images: | node_modules
973npm install --no-save fabric@6 imagemin-zopfli@7
974node tools/generate-images.js $(TAGS)
975
976.PHONY: generate-manpage
977generate-manpage:
978@[ -f gitea ] || make backend
979@mkdir -p man/man1/ man/man5
980@./gitea docs --man > man/man1/gitea.1
981@gzip -9 man/man1/gitea.1 && echo man/man1/gitea.1.gz created
982@#TODO A small script that formats config-cheat-sheet.en-us.md nicely for use as a config man page
983
984.PHONY: docker
985docker:
986docker build --disable-content-trust=false -t $(DOCKER_REF) .
987# support also build args docker build --build-arg GITEA_VERSION=v1.2.3 --build-arg TAGS="bindata sqlite sqlite_unlock_notify" .
988
989# This endif closes the if at the top of the file
990endif
991
992# Disable parallel execution because it would break some targets that don't
993# specify exact dependencies like 'backend' which does currently not depend
994# on 'frontend' to enable Node.js-less builds from source tarballs.
995.NOTPARALLEL:
996