Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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