gitech
/
Makefile
984 строки · 37.6 Кб
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.22.x
27
28AIR_PACKAGE ?= github.com/cosmtrek/air@v1
29EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.7.0
30GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.6.0
31GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2
32GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11
33MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.4.1
34SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@db51e79a0e37c572d8b59ae0c58bf2bbbbe53285
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
39
40DOCKER_IMAGE ?= gitea/gitea
41DOCKER_TAG ?= latest
42DOCKER_REF := $(DOCKER_IMAGE):$(DOCKER_TAG)
43
44ifeq ($(HAS_GO), yes)
45CGO_EXTRA_CFLAGS := -DSQLITE_MAX_VARIABLE_NUMBER=32766
46CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
47endif
48
49ifeq ($(GOOS),windows)
50IS_WINDOWS := yes
51else ifeq ($(patsubst Windows%,Windows,$(OS)),Windows)
52ifeq ($(GOOS),)
53IS_WINDOWS := yes
54endif
55endif
56ifeq ($(IS_WINDOWS),yes)
57GOFLAGS := -v -buildmode=exe
58EXECUTABLE ?= gitea.exe
59else
60GOFLAGS := -v
61EXECUTABLE ?= gitea
62endif
63
64ifeq ($(shell sed --version 2>/dev/null | grep -q GNU && echo gnu),gnu)
65SED_INPLACE := sed -i
66else
67SED_INPLACE := sed -i ''
68endif
69
70EXTRA_GOFLAGS ?=
71
72MAKE_VERSION := $(shell "$(MAKE)" -v | cat | head -n 1)
73MAKE_EVIDENCE_DIR := .make_evidence
74
75ifeq ($(RACE_ENABLED),true)
76GOFLAGS += -race
77GOTESTFLAGS += -race
78endif
79
80STORED_VERSION_FILE := VERSION
81HUGO_VERSION ?= 0.111.3
82
83GITHUB_REF_TYPE ?= branch
84GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
85
86ifneq ($(GITHUB_REF_TYPE),branch)
87VERSION ?= $(subst v,,$(GITHUB_REF_NAME))
88GITEA_VERSION ?= $(VERSION)
89else
90ifneq ($(GITHUB_REF_NAME),)
91VERSION ?= $(subst release/v,,$(GITHUB_REF_NAME))
92else
93VERSION ?= main
94endif
95
96STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null)
97ifneq ($(STORED_VERSION),)
98GITEA_VERSION ?= $(STORED_VERSION)
99else
100GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
101endif
102endif
103
104# if version = "main" then update version to "nightly"
105ifeq ($(VERSION),main)
106VERSION := main-nightly
107endif
108
109LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
110
111LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
112
113GO_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/))
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 ?= 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 *.config.js tests/e2e
148STYLELINT_FILES := web_src/css web_src/js/components/*.vue
149SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) docs/content templates options/locale/locale_en-US.ini .github
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_MSSQL_HOST ?= mssql:1433
183TEST_MSSQL_DBNAME ?= gitea
184TEST_MSSQL_USERNAME ?= sa
185TEST_MSSQL_PASSWORD ?= MwantsaSecurePassword1
186
187.PHONY: all
188all: build
189
190.PHONY: help
191help:
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
253go-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 \
258echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://go.dev/dl/"; \
259exit 1; \
260fi
261
262.PHONY: git-check
263git-check:
264@if git lfs >/dev/null 2>&1 ; then : ; else \
265echo "Gitea requires git with lfs support to run tests." ; \
266exit 1; \
267fi
268
269.PHONY: node-check
270node-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 \
276echo "Gitea requires Node.js $(MIN_NODE_VERSION_STR) or greater and npm to build. You can get it at https://nodejs.org/en/download/"; \
277exit 1; \
278fi
279
280.PHONY: clean-all
281clean-all: clean
282rm -rf $(WEBPACK_DEST_ENTRIES) node_modules
283
284.PHONY: clean
285clean:
286rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST) $(BINDATA_HASH) \
287integrations*.test \
288e2e*.test \
289tests/integration/gitea-integration-* \
290tests/integration/indexers-* \
291tests/mysql.ini tests/pgsql.ini tests/mssql.ini man/ \
292tests/e2e/gitea-e2e-*/ \
293tests/e2e/indexers-*/ \
294tests/e2e/reports/ tests/e2e/test-artifacts/ tests/e2e/test-snapshots/
295
296.PHONY: fmt
297fmt:
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
308fmt-check: fmt
309@diff=$$(git diff --color=always $(GO_SOURCES) templates $(WEB_DIRS)); \
310if [ -n "$$diff" ]; then \
311echo "Please run 'make fmt' and commit the result:"; \
312echo "$${diff}"; \
313exit 1; \
314fi
315
316.PHONY: $(TAGS_EVIDENCE)
317$(TAGS_EVIDENCE):
318@mkdir -p $(MAKE_EVIDENCE_DIR)
319@echo "$(TAGS)" > $(TAGS_EVIDENCE)
320
321ifneq "$(TAGS)" "$(shell cat $(TAGS_EVIDENCE) 2>/dev/null)"
322TAGS_PREREQ := $(TAGS_EVIDENCE)
323endif
324
325.PHONY: generate-swagger
326generate-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
334swagger-check: generate-swagger
335@diff=$$(git diff --color=always '$(SWAGGER_SPEC)'); \
336if [ -n "$$diff" ]; then \
337echo "Please run 'make generate-swagger' and commit the result:"; \
338echo "$${diff}"; \
339exit 1; \
340fi
341
342.PHONY: swagger-validate
343swagger-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
349checks: checks-frontend checks-backend
350
351.PHONY: checks-frontend
352checks-frontend: lockfile-check svg-check
353
354.PHONY: checks-backend
355checks-backend: tidy-check swagger-check fmt-check swagger-validate security-check
356
357.PHONY: lint
358lint: lint-frontend lint-backend lint-spell
359
360.PHONY: lint-fix
361lint-fix: lint-frontend-fix lint-backend-fix lint-spell-fix
362
363.PHONY: lint-frontend
364lint-frontend: lint-js lint-css
365
366.PHONY: lint-frontend-fix
367lint-frontend-fix: lint-js-fix lint-css-fix
368
369.PHONY: lint-backend
370lint-backend: lint-go lint-go-vet lint-editorconfig
371
372.PHONY: lint-backend-fix
373lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig
374
375.PHONY: lint-js
376lint-js: node_modules
377npx eslint --color --max-warnings=0 --ext js,vue $(ESLINT_FILES)
378
379.PHONY: lint-js-fix
380lint-js-fix: node_modules
381npx eslint --color --max-warnings=0 --ext js,vue $(ESLINT_FILES) --fix
382
383.PHONY: lint-css
384lint-css: node_modules
385npx stylelint --color --max-warnings=0 $(STYLELINT_FILES)
386
387.PHONY: lint-css-fix
388lint-css-fix: node_modules
389npx stylelint --color --max-warnings=0 $(STYLELINT_FILES) --fix
390
391.PHONY: lint-swagger
392lint-swagger: node_modules
393npx spectral lint -q -F hint $(SWAGGER_SPEC)
394
395.PHONY: lint-md
396lint-md: node_modules
397npx markdownlint docs *.md
398
399.PHONY: lint-spell
400lint-spell:
401@go run $(MISSPELL_PACKAGE) -error $(SPELLCHECK_FILES)
402
403.PHONY: lint-spell-fix
404lint-spell-fix:
405@go run $(MISSPELL_PACKAGE) -w $(SPELLCHECK_FILES)
406
407.PHONY: lint-go
408lint-go:
409$(GO) run $(GOLANGCI_LINT_PACKAGE) run
410
411.PHONY: lint-go-fix
412lint-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
418lint-go-windows:
419@GOOS= GOARCH= $(GO) install $(GOLANGCI_LINT_PACKAGE)
420golangci-lint run
421
422.PHONY: lint-go-vet
423lint-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
429lint-editorconfig:
430@$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) $(EDITORCONFIG_FILES)
431
432.PHONY: lint-actions
433lint-actions:
434$(GO) run $(ACTIONLINT_PACKAGE)
435
436.PHONY: lint-templates
437lint-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
442lint-yaml: .venv
443@poetry run yamllint .
444
445.PHONY: watch
446watch:
447@bash tools/watch.sh
448
449.PHONY: watch-frontend
450watch-frontend: node-check node_modules
451@rm -rf $(WEBPACK_DEST_ENTRIES)
452NODE_ENV=development npx webpack --watch --progress
453
454.PHONY: watch-backend
455watch-backend: go-check
456GITEA_RUN_MODE=dev $(GO) run $(AIR_PACKAGE) -c .air.toml
457
458.PHONY: test
459test: test-frontend test-backend
460
461.PHONY: test-backend
462test-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
467test-frontend: node_modules
468npx vitest
469
470.PHONY: test-check
471test-check:
472@echo "Running test-check...";
473@diff=$$(git status -s); \
474if [ -n "$$diff" ]; then \
475echo "make test-backend has changed files in the source tree:"; \
476echo "$${diff}"; \
477echo "You should change the tests to create these files in a temporary directory."; \
478echo "Do not simply add these files to .gitignore"; \
479exit 1; \
480fi
481
482.PHONY: test\#%
483test\#%:
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
488coverage:
489grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' coverage.out > coverage-bodged.out
490grep '^\(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
494unit-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
499tidy:
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
504vendor: go.mod go.sum
505$(GO) mod vendor
506@touch vendor
507
508.PHONY: tidy-check
509tidy-check: tidy
510@diff=$$(git diff --color=always go.mod go.sum $(GO_LICENSE_FILE)); \
511if [ -n "$$diff" ]; then \
512echo "Please run 'make tidy' and commit the result:"; \
513echo "$${diff}"; \
514exit 1; \
515fi
516
517.PHONY: go-licenses
518go-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
525generate-ini-sqlite:
526sed -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' \
529tests/sqlite.ini.tmpl > tests/sqlite.ini
530
531.PHONY: test-sqlite
532test-sqlite: integrations.sqlite.test generate-ini-sqlite
533GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test
534
535.PHONY: test-sqlite\#%
536test-sqlite\#%: integrations.sqlite.test generate-ini-sqlite
537GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test -test.run $(subst .,/,$*)
538
539.PHONY: test-sqlite-migration
540test-sqlite-migration: migrations.sqlite.test migrations.individual.sqlite.test
541
542generate-ini-mysql:
543sed -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' \
550tests/mysql.ini.tmpl > tests/mysql.ini
551
552.PHONY: test-mysql
553test-mysql: integrations.mysql.test generate-ini-mysql
554GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test
555
556.PHONY: test-mysql\#%
557test-mysql\#%: integrations.mysql.test generate-ini-mysql
558GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test -test.run $(subst .,/,$*)
559
560.PHONY: test-mysql-migration
561test-mysql-migration: migrations.mysql.test migrations.individual.mysql.test
562
563generate-ini-pgsql:
564sed -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' \
572tests/pgsql.ini.tmpl > tests/pgsql.ini
573
574.PHONY: test-pgsql
575test-pgsql: integrations.pgsql.test generate-ini-pgsql
576GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test
577
578.PHONY: test-pgsql\#%
579test-pgsql\#%: integrations.pgsql.test generate-ini-pgsql
580GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test -test.run $(subst .,/,$*)
581
582.PHONY: test-pgsql-migration
583test-pgsql-migration: migrations.pgsql.test migrations.individual.pgsql.test
584
585generate-ini-mssql:
586sed -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' \
593tests/mssql.ini.tmpl > tests/mssql.ini
594
595.PHONY: test-mssql
596test-mssql: integrations.mssql.test generate-ini-mssql
597GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test
598
599.PHONY: test-mssql\#%
600test-mssql\#%: integrations.mssql.test generate-ini-mssql
601GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test -test.run $(subst .,/,$*)
602
603.PHONY: test-mssql-migration
604test-mssql-migration: migrations.mssql.test migrations.individual.mssql.test
605
606.PHONY: playwright
607playwright: deps-frontend
608npx playwright install $(PLAYWRIGHT_FLAGS)
609
610.PHONY: test-e2e%
611test-e2e%: TEST_TYPE ?= e2e
612# Clear display env variable. Otherwise, chromium tests can fail.
613DISPLAY=
614
615.PHONY: test-e2e
616test-e2e: test-e2e-sqlite
617
618.PHONY: test-e2e-sqlite
619test-e2e-sqlite: playwright e2e.sqlite.test generate-ini-sqlite
620GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./e2e.sqlite.test
621
622.PHONY: test-e2e-sqlite\#%
623test-e2e-sqlite\#%: playwright e2e.sqlite.test generate-ini-sqlite
624GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./e2e.sqlite.test -test.run TestE2e/$*
625
626.PHONY: test-e2e-mysql
627test-e2e-mysql: playwright e2e.mysql.test generate-ini-mysql
628GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./e2e.mysql.test
629
630.PHONY: test-e2e-mysql\#%
631test-e2e-mysql\#%: playwright e2e.mysql.test generate-ini-mysql
632GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./e2e.mysql.test -test.run TestE2e/$*
633
634.PHONY: test-e2e-pgsql
635test-e2e-pgsql: playwright e2e.pgsql.test generate-ini-pgsql
636GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./e2e.pgsql.test
637
638.PHONY: test-e2e-pgsql\#%
639test-e2e-pgsql\#%: playwright e2e.pgsql.test generate-ini-pgsql
640GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./e2e.pgsql.test -test.run TestE2e/$*
641
642.PHONY: test-e2e-mssql
643test-e2e-mssql: playwright e2e.mssql.test generate-ini-mssql
644GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test
645
646.PHONY: test-e2e-mssql\#%
647test-e2e-mssql\#%: playwright e2e.mssql.test generate-ini-mssql
648GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test -test.run TestE2e/$*
649
650.PHONY: bench-sqlite
651bench-sqlite: integrations.sqlite.test generate-ini-sqlite
652GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
653
654.PHONY: bench-mysql
655bench-mysql: integrations.mysql.test generate-ini-mysql
656GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
657
658.PHONY: bench-mssql
659bench-mssql: integrations.mssql.test generate-ini-mssql
660GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
661
662.PHONY: bench-pgsql
663bench-pgsql: integrations.pgsql.test generate-ini-pgsql
664GITEA_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
667integration-test-coverage: integrations.cover.test generate-ini-mysql
668GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
669
670.PHONY: integration-test-coverage-sqlite
671integration-test-coverage-sqlite: integrations.cover.sqlite.test generate-ini-sqlite
672GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.cover.sqlite.test -test.coverprofile=integration.coverage.out
673
674integrations.mysql.test: git-check $(GO_SOURCES)
675$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.mysql.test
676
677integrations.pgsql.test: git-check $(GO_SOURCES)
678$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.pgsql.test
679
680integrations.mssql.test: git-check $(GO_SOURCES)
681$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.mssql.test
682
683integrations.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
686integrations.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
689integrations.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
693migrations.mysql.test: $(GO_SOURCES) generate-ini-mysql
694$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.mysql.test
695GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./migrations.mysql.test
696
697.PHONY: migrations.pgsql.test
698migrations.pgsql.test: $(GO_SOURCES) generate-ini-pgsql
699$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.pgsql.test
700GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./migrations.pgsql.test
701
702.PHONY: migrations.mssql.test
703migrations.mssql.test: $(GO_SOURCES) generate-ini-mssql
704$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.mssql.test
705GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./migrations.mssql.test
706
707.PHONY: migrations.sqlite.test
708migrations.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)'
710GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./migrations.sqlite.test
711
712.PHONY: migrations.individual.mysql.test
713migrations.individual.mysql.test: $(GO_SOURCES)
714GITEA_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\#%
717migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite
718GITEA_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
721migrations.individual.pgsql.test: $(GO_SOURCES)
722GITEA_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\#%
725migrations.individual.pgsql.test\#%: $(GO_SOURCES) generate-ini-pgsql
726GITEA_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
729migrations.individual.mssql.test: $(GO_SOURCES) generate-ini-mssql
730GITEA_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\#%
733migrations.individual.mssql.test\#%: $(GO_SOURCES) generate-ini-mssql
734GITEA_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
737migrations.individual.sqlite.test: $(GO_SOURCES) generate-ini-sqlite
738GITEA_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\#%
741migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite
742GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
743
744e2e.mysql.test: $(GO_SOURCES)
745$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mysql.test
746
747e2e.pgsql.test: $(GO_SOURCES)
748$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.pgsql.test
749
750e2e.mssql.test: $(GO_SOURCES)
751$(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mssql.test
752
753e2e.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
757check: test
758
759.PHONY: install $(TAGS_PREREQ)
760install: $(wildcard *.go)
761CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
762
763.PHONY: build
764build: frontend backend
765
766.PHONY: frontend
767frontend: $(WEBPACK_DEST)
768
769.PHONY: backend
770backend: 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
774generate: generate-backend
775
776.PHONY: generate-backend
777generate-backend: $(TAGS_PREREQ) generate-go
778
779.PHONY: generate-go
780generate-go: $(TAGS_PREREQ)
781@echo "Running go generate..."
782@CC= GOOS= GOARCH= $(GO) generate -tags '$(TAGS)' $(GO_PACKAGES)
783
784.PHONY: security-check
785security-check:
786go run $(GOVULNCHECK_PACKAGE) ./...
787
788$(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
789CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
790
791.PHONY: release
792release: 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):
795mkdir -p $(DIST_DIRS)
796
797.PHONY: release-windows
798release-windows: | $(DIST_DIRS)
799CGO_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) .
800ifeq (,$(findstring gogit,$(TAGS)))
801CGO_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 .
802endif
803
804.PHONY: release-linux
805release-linux: | $(DIST_DIRS)
806CGO_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
809release-darwin: | $(DIST_DIRS)
810CGO_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
813release-freebsd: | $(DIST_DIRS)
814CGO_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
817release-copy: | $(DIST_DIRS)
818cd $(DIST); for file in `find . -type f -name "*"`; do cp $${file} ./release/; done;
819
820.PHONY: release-check
821release-check: | $(DIST_DIRS)
822cd $(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
825release-compress: | $(DIST_DIRS)
826cd $(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
829release-sources: | $(DIST_DIRS)
830echo $(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)/|'"))
835tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) $(TRANSFORM) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
836rm -f $(STORED_VERSION_FILE)
837
838.PHONY: release-docs
839release-docs: | $(DIST_DIRS) docs
840tar -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs .
841
842.PHONY: deps
843deps: deps-frontend deps-backend deps-tools deps-py
844
845.PHONY: deps-py
846deps-py: .venv
847
848.PHONY: deps-frontend
849deps-frontend: node_modules
850
851.PHONY: deps-backend
852deps-backend:
853$(GO) mod download
854
855.PHONY: deps-tools
856deps-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
869node_modules: package-lock.json
870npm install --no-save
871@touch node_modules
872
873.venv: poetry.lock
874poetry install --no-root
875@touch .venv
876
877.PHONY: update
878update: update-js update-py
879
880.PHONY: update-js
881update-js: node-check | node_modules
882npx updates -u -f package.json
883rm -rf node_modules package-lock.json
884npm install --package-lock
885@touch node_modules
886
887.PHONY: update-py
888update-py: node-check | node_modules
889npx updates -u -f pyproject.toml
890rm -rf .venv poetry.lock
891poetry install --no-root
892@touch .venv
893
894.PHONY: fomantic
895fomantic:
896rm -rf $(FOMANTIC_WORK_DIR)/build
897cd $(FOMANTIC_WORK_DIR) && npm install --no-save
898cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config
899cp -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
901cd $(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
905rm -f $(FOMANTIC_WORK_DIR)/build/*.min.*
906
907.PHONY: webpack
908webpack: $(WEBPACK_DEST)
909
910$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json
911@$(MAKE) -s node-check node_modules
912rm -rf $(WEBPACK_DEST_ENTRIES)
913npx webpack
914@touch $(WEBPACK_DEST)
915
916.PHONY: svg
917svg: node-check | node_modules
918rm -rf $(SVG_DEST_DIR)
919node tools/generate-svg.js
920
921.PHONY: svg-check
922svg-check: svg
923@git add $(SVG_DEST_DIR)
924@diff=$$(git diff --color=always --cached $(SVG_DEST_DIR)); \
925if [ -n "$$diff" ]; then \
926echo "Please run 'make svg' and 'git add $(SVG_DEST_DIR)' and commit the result:"; \
927echo "$${diff}"; \
928exit 1; \
929fi
930
931.PHONY: lockfile-check
932lockfile-check:
933npm install --package-lock-only
934@diff=$$(git diff --color=always package-lock.json); \
935if [ -n "$$diff" ]; then \
936echo "package-lock.json is inconsistent with package.json"; \
937echo "Please run 'npm install --package-lock-only' and commit the result:"; \
938echo "$${diff}"; \
939exit 1; \
940fi
941
942.PHONY: update-translations
943update-translations:
944mkdir -p ./translations
945cd ./translations && curl -L https://crowdin.com/download/project/gitea.zip > gitea.zip && unzip gitea.zip
946rm ./translations/gitea.zip
947$(SED_INPLACE) -e 's/="/=/g' -e 's/"$$//g' ./translations/*.ini
948$(SED_INPLACE) -e 's/\\"/"/g' ./translations/*.ini
949mv ./translations/*.ini ./options/locale/
950rmdir ./translations
951
952.PHONY: generate-license
953generate-license:
954$(GO) run build/generate-licenses.go
955
956.PHONY: generate-gitignore
957generate-gitignore:
958$(GO) run build/generate-gitignores.go
959
960.PHONY: generate-images
961generate-images: | node_modules
962npm install --no-save fabric@6.0.0-beta20 imagemin-zopfli@7
963node tools/generate-images.js $(TAGS)
964
965.PHONY: generate-manpage
966generate-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
974docker:
975docker 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
979endif
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