You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. DIST := dist
  2. DIST_DIRS := $(DIST)/binaries $(DIST)/release
  3. IMPORT := code.gitea.io/gitea
  4. export GO111MODULE=off
  5. GO ?= go
  6. SED_INPLACE := sed -i
  7. SHASUM ?= shasum -a 256
  8. HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
  9. ifeq ($(HAS_GO), GO)
  10. GOPATH ?= $(shell $(GO) env GOPATH)
  11. export PATH := $(GOPATH)/bin:$(PATH)
  12. endif
  13. ifeq ($(OS), Windows_NT)
  14. EXECUTABLE ?= gitea.exe
  15. FIND_PWD_REGEXP := find . -regextype posix-egrep
  16. else
  17. EXECUTABLE ?= gitea
  18. UNAME_S := $(shell uname -s)
  19. FIND_PWD_REGEXP := find . -regextype posix-egrep
  20. BUSYBOX := $(shell find --help 2>&1 | grep -o BusyBox)
  21. ifeq ($(UNAME_S),Darwin)
  22. SED_INPLACE := sed -i ''
  23. FIND_PWD_REGEXP := find -E .
  24. endif
  25. ifeq ($(UNAME_S),FreeBSD)
  26. SED_INPLACE := sed -i ''
  27. FIND_PWD_REGEXP := find -E .
  28. endif
  29. ifeq ($(BUSYBOX),BusyBox)
  30. FIND_PWD_REGEXP := find .
  31. endif
  32. endif
  33. GOFMT ?= gofmt -s
  34. GOFLAGS := -v
  35. EXTRA_GOFLAGS ?=
  36. MAKE_VERSION := $(shell $(MAKE) -v | head -n 1)
  37. MAKE_EVIDENCE_DIR := .make_evidence
  38. ifneq ($(RACE_ENABLED),)
  39. GOTESTFLAGS ?= -race
  40. endif
  41. STORED_VERSION_FILE := VERSION
  42. ifneq ($(DRONE_TAG),)
  43. VERSION ?= $(subst v,,$(DRONE_TAG))
  44. GITEA_VERSION ?= $(VERSION)
  45. else
  46. ifneq ($(DRONE_BRANCH),)
  47. VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
  48. else
  49. VERSION ?= master
  50. endif
  51. STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null)
  52. ifneq ($(STORED_VERSION),)
  53. GITEA_VERSION ?= $(STORED_VERSION)
  54. else
  55. GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
  56. endif
  57. endif
  58. LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
  59. PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations/migration-test,$(filter-out code.gitea.io/gitea/integrations,$(shell GO111MODULE=on $(GO) list -mod=vendor ./... | grep -v /vendor/)))
  60. GO_SOURCES ?= $(shell $(FIND_PWD_REGEXP) -regex '\./(node_modules|docs|public|options|contrib|data)' -prune -o -name "*.go" -type f -print)
  61. GO_SOURCES_OWN := $(filter-out ./vendor/% %/bindata.go, $(GO_SOURCES))
  62. WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f)
  63. WEBPACK_CONFIGS := webpack.config.js .eslintrc .stylelintrc
  64. WEBPACK_DEST := public/js/index.js public/css/index.css
  65. WEBPACK_DEST_DIRS := public/js public/css
  66. BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
  67. BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))
  68. FOMANTIC_CONFIGS := semantic.json web_src/fomantic/theme.config.less web_src/fomantic/_site/globals/site.variables
  69. FOMANTIC_DEST := public/fomantic/semantic.min.js public/fomantic/semantic.min.css
  70. FOMANTIC_DEST_DIR := public/fomantic
  71. TAGS ?=
  72. TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
  73. #To update swagger use: GO111MODULE=on go get -u github.com/go-swagger/go-swagger/cmd/swagger@v0.20.1
  74. SWAGGER := GO111MODULE=on $(GO) run -mod=vendor github.com/go-swagger/go-swagger/cmd/swagger
  75. SWAGGER_SPEC := templates/swagger/v1_json.tmpl
  76. SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl}}/api/v1"|g
  77. SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl}}/api/v1"|"basePath": "/api/v1"|g
  78. SWAGGER_NEWLINE_COMMAND := -e '$$a\'
  79. TEST_MYSQL_HOST ?= mysql:3306
  80. TEST_MYSQL_DBNAME ?= testgitea
  81. TEST_MYSQL_USERNAME ?= root
  82. TEST_MYSQL_PASSWORD ?=
  83. TEST_MYSQL8_HOST ?= mysql8:3306
  84. TEST_MYSQL8_DBNAME ?= testgitea
  85. TEST_MYSQL8_USERNAME ?= root
  86. TEST_MYSQL8_PASSWORD ?=
  87. TEST_PGSQL_HOST ?= pgsql:5432
  88. TEST_PGSQL_DBNAME ?= testgitea
  89. TEST_PGSQL_USERNAME ?= postgres
  90. TEST_PGSQL_PASSWORD ?= postgres
  91. TEST_PGSQL_SCHEMA ?= gtestschema
  92. TEST_MSSQL_HOST ?= mssql:1433
  93. TEST_MSSQL_DBNAME ?= gitea
  94. TEST_MSSQL_USERNAME ?= sa
  95. TEST_MSSQL_PASSWORD ?= MwantsaSecurePassword1
  96. .PHONY: all
  97. all: build
  98. include docker/Makefile
  99. .PHONY: help
  100. help:
  101. @echo "Make Routines:"
  102. @echo " - \"\" equivalent to \"build\""
  103. @echo " - build build everything"
  104. @echo " - frontend build frontend files"
  105. @echo " - backend build backend files"
  106. @echo " - clean delete backend and integration files"
  107. @echo " - clean-all delete backend, frontend and integration files"
  108. @echo " - webpack build webpack files"
  109. @echo " - fomantic build fomantic files"
  110. @echo " - generate run \"go generate\""
  111. @echo " - fmt format the Go code"
  112. @echo " - generate-swagger generate the swagger spec from code comments"
  113. @echo " - swagger-validate check if the swagger spec is valid"
  114. @echo " - revive run code linter revive"
  115. @echo " - misspell check if a word is written wrong"
  116. @echo " - vet examines Go source code and reports suspicious constructs"
  117. @echo " - test run unit test"
  118. @echo " - test-sqlite run integration test for sqlite"
  119. @echo " - pr#<index> build and start gitea from a PR with integration test data loaded"
  120. .PHONY: go-check
  121. go-check:
  122. $(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell go version | grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?[[:space:]]' | tr '.' ' ');))
  123. @if [ "$(GO_VERSION)" -lt "001011000" ]; then \
  124. echo "Gitea requires Go 1.11.0 or greater to build. You can get it at https://golang.org/dl/"; \
  125. exit 1; \
  126. fi
  127. .PHONY: git-check
  128. git-check:
  129. @if git lfs >/dev/null 2>&1 ; then : ; else \
  130. echo "Gitea requires git with lfs support to run tests." ; \
  131. exit 1; \
  132. fi
  133. .PHONY: node-check
  134. node-check:
  135. $(eval NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell node -v | grep -Eo '[0-9]+\.?[0-9]+?\.?[0-9]?' | tr '.' ' ');))
  136. $(eval NPM_MISSING := $(shell hash npm > /dev/null 2>&1 || echo 1))
  137. @if [ "$(NODE_VERSION)" -lt "010000000" -o "$(NPM_MISSING)" = "1" ]; then \
  138. echo "Gitea requires Node.js 10.0.0 or greater and npm to build. You can get it at https://nodejs.org/en/download/"; \
  139. exit 1; \
  140. fi
  141. .PHONY: clean-all
  142. clean-all: clean
  143. rm -rf $(WEBPACK_DEST_DIRS) $(FOMANTIC_DEST_DIR)
  144. .PHONY: clean
  145. clean:
  146. $(GO) clean -i ./...
  147. rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST) $(BINDATA_HASH) \
  148. integrations*.test \
  149. integrations/gitea-integration-pgsql/ integrations/gitea-integration-mysql/ integrations/gitea-integration-mysql8/ integrations/gitea-integration-sqlite/ \
  150. integrations/gitea-integration-mssql/ integrations/indexers-mysql/ integrations/indexers-mysql8/ integrations/indexers-pgsql integrations/indexers-sqlite \
  151. integrations/indexers-mssql integrations/mysql.ini integrations/mysql8.ini integrations/pgsql.ini integrations/mssql.ini
  152. .PHONY: fmt
  153. fmt:
  154. $(GOFMT) -w $(GO_SOURCES_OWN)
  155. .PHONY: vet
  156. vet:
  157. $(GO) vet $(PACKAGES)
  158. .PHONY: $(TAGS_EVIDENCE)
  159. $(TAGS_EVIDENCE):
  160. @mkdir -p $(MAKE_EVIDENCE_DIR)
  161. @echo "$(TAGS)" > $(TAGS_EVIDENCE)
  162. ifneq "$(TAGS)" "$(shell cat $(TAGS_EVIDENCE) 2>/dev/null)"
  163. TAGS_PREREQ := $(TAGS_EVIDENCE)
  164. endif
  165. .PHONY: generate-swagger
  166. generate-swagger:
  167. $(SWAGGER) generate spec -o './$(SWAGGER_SPEC)'
  168. $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
  169. $(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)'
  170. .PHONY: swagger-check
  171. swagger-check: generate-swagger
  172. @diff=$$(git diff '$(SWAGGER_SPEC)'); \
  173. if [ -n "$$diff" ]; then \
  174. echo "Please run 'make generate-swagger' and commit the result:"; \
  175. echo "$${diff}"; \
  176. exit 1; \
  177. fi;
  178. .PHONY: swagger-validate
  179. swagger-validate:
  180. $(SED_INPLACE) '$(SWAGGER_SPEC_S_JSON)' './$(SWAGGER_SPEC)'
  181. $(SWAGGER) validate './$(SWAGGER_SPEC)'
  182. $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
  183. .PHONY: errcheck
  184. errcheck:
  185. @hash errcheck > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  186. $(GO) get -u github.com/kisielk/errcheck; \
  187. fi
  188. errcheck $(PACKAGES)
  189. .PHONY: revive
  190. revive:
  191. @hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  192. $(GO) get -u github.com/mgechev/revive; \
  193. fi
  194. revive -config .revive.toml -exclude=./vendor/... ./... || exit 1
  195. .PHONY: misspell-check
  196. misspell-check:
  197. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  198. $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  199. fi
  200. misspell -error -i unknwon,destory $(GO_SOURCES_OWN)
  201. .PHONY: misspell
  202. misspell:
  203. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  204. $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  205. fi
  206. misspell -w -i unknwon $(GO_SOURCES_OWN)
  207. .PHONY: fmt-check
  208. fmt-check:
  209. # get all go files and run go fmt on them
  210. @diff=$$($(GOFMT) -d $(GO_SOURCES_OWN)); \
  211. if [ -n "$$diff" ]; then \
  212. echo "Please run 'make fmt' and commit the result:"; \
  213. echo "$${diff}"; \
  214. exit 1; \
  215. fi;
  216. .PHONY: test
  217. test:
  218. GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -tags='sqlite sqlite_unlock_notify' $(PACKAGES)
  219. PHONY: test-check
  220. test-check:
  221. @echo "Checking if tests have changed the source tree...";
  222. @diff=$$(git status -s); \
  223. if [ -n "$$diff" ]; then \
  224. echo "make test has changed files in the source tree:"; \
  225. echo "$${diff}"; \
  226. echo "You should change the tests to create these files in a temporary directory."; \
  227. echo "Do not simply add these files to .gitignore"; \
  228. exit 1; \
  229. fi;
  230. .PHONY: test\#%
  231. test\#%:
  232. GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' -run $* $(PACKAGES)
  233. .PHONY: coverage
  234. coverage:
  235. @hash gocovmerge > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  236. $(GO) get -u github.com/wadey/gocovmerge; \
  237. fi
  238. gocovmerge integration.coverage.out $(shell find . -type f -name "coverage.out") > coverage.all;\
  239. .PHONY: unit-test-coverage
  240. unit-test-coverage:
  241. GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -tags='sqlite sqlite_unlock_notify' -cover -coverprofile coverage.out $(PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
  242. .PHONY: vendor
  243. vendor:
  244. GO111MODULE=on $(GO) mod tidy && GO111MODULE=on $(GO) mod vendor
  245. .PHONY: test-vendor
  246. test-vendor: vendor
  247. @diff=$$(git diff vendor/); \
  248. if [ -n "$$diff" ]; then \
  249. echo "Please run 'make vendor' and commit the result:"; \
  250. echo "$${diff}"; \
  251. exit 1; \
  252. fi;
  253. .PHONY: test-sqlite
  254. test-sqlite: integrations.sqlite.test
  255. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test
  256. .PHONY: test-sqlite\#%
  257. test-sqlite\#%: integrations.sqlite.test
  258. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.run $*
  259. .PHONY: test-sqlite-migration
  260. test-sqlite-migration: migrations.sqlite.test
  261. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./migrations.sqlite.test
  262. generate-ini-mysql:
  263. sed -e 's|{{TEST_MYSQL_HOST}}|${TEST_MYSQL_HOST}|g' \
  264. -e 's|{{TEST_MYSQL_DBNAME}}|${TEST_MYSQL_DBNAME}|g' \
  265. -e 's|{{TEST_MYSQL_USERNAME}}|${TEST_MYSQL_USERNAME}|g' \
  266. -e 's|{{TEST_MYSQL_PASSWORD}}|${TEST_MYSQL_PASSWORD}|g' \
  267. integrations/mysql.ini.tmpl > integrations/mysql.ini
  268. .PHONY: test-mysql
  269. test-mysql: integrations.mysql.test generate-ini-mysql
  270. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test
  271. .PHONY: test-mysql\#%
  272. test-mysql\#%: integrations.mysql.test generate-ini-mysql
  273. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.run $*
  274. .PHONY: test-mysql-migration
  275. test-mysql-migration: migrations.mysql.test generate-ini-mysql
  276. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./migrations.mysql.test
  277. generate-ini-mysql8:
  278. sed -e 's|{{TEST_MYSQL8_HOST}}|${TEST_MYSQL8_HOST}|g' \
  279. -e 's|{{TEST_MYSQL8_DBNAME}}|${TEST_MYSQL8_DBNAME}|g' \
  280. -e 's|{{TEST_MYSQL8_USERNAME}}|${TEST_MYSQL8_USERNAME}|g' \
  281. -e 's|{{TEST_MYSQL8_PASSWORD}}|${TEST_MYSQL8_PASSWORD}|g' \
  282. integrations/mysql8.ini.tmpl > integrations/mysql8.ini
  283. .PHONY: test-mysql8
  284. test-mysql8: integrations.mysql8.test generate-ini-mysql8
  285. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./integrations.mysql8.test
  286. .PHONY: test-mysql8\#%
  287. test-mysql8\#%: integrations.mysql8.test generate-ini-mysql8
  288. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./integrations.mysql8.test -test.run $*
  289. .PHONY: test-mysql8-migration
  290. test-mysql8-migration: migrations.mysql8.test generate-ini-mysql8
  291. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./migrations.mysql8.test
  292. generate-ini-pgsql:
  293. sed -e 's|{{TEST_PGSQL_HOST}}|${TEST_PGSQL_HOST}|g' \
  294. -e 's|{{TEST_PGSQL_DBNAME}}|${TEST_PGSQL_DBNAME}|g' \
  295. -e 's|{{TEST_PGSQL_USERNAME}}|${TEST_PGSQL_USERNAME}|g' \
  296. -e 's|{{TEST_PGSQL_PASSWORD}}|${TEST_PGSQL_PASSWORD}|g' \
  297. -e 's|{{TEST_PGSQL_SCHEMA}}|${TEST_PGSQL_SCHEMA}|g' \
  298. integrations/pgsql.ini.tmpl > integrations/pgsql.ini
  299. .PHONY: test-pgsql
  300. test-pgsql: integrations.pgsql.test generate-ini-pgsql
  301. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test
  302. .PHONY: test-pgsql\#%
  303. test-pgsql\#%: integrations.pgsql.test generate-ini-pgsql
  304. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.run $*
  305. .PHONY: test-pgsql-migration
  306. test-pgsql-migration: migrations.pgsql.test generate-ini-pgsql
  307. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./migrations.pgsql.test
  308. generate-ini-mssql:
  309. sed -e 's|{{TEST_MSSQL_HOST}}|${TEST_MSSQL_HOST}|g' \
  310. -e 's|{{TEST_MSSQL_DBNAME}}|${TEST_MSSQL_DBNAME}|g' \
  311. -e 's|{{TEST_MSSQL_USERNAME}}|${TEST_MSSQL_USERNAME}|g' \
  312. -e 's|{{TEST_MSSQL_PASSWORD}}|${TEST_MSSQL_PASSWORD}|g' \
  313. integrations/mssql.ini.tmpl > integrations/mssql.ini
  314. .PHONY: test-mssql
  315. test-mssql: integrations.mssql.test generate-ini-mssql
  316. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test
  317. .PHONY: test-mssql\#%
  318. test-mssql\#%: integrations.mssql.test generate-ini-mssql
  319. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test -test.run $*
  320. .PHONY: test-mssql-migration
  321. test-mssql-migration: migrations.mssql.test generate-ini-mssql
  322. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./migrations.mssql.test
  323. .PHONY: bench-sqlite
  324. bench-sqlite: integrations.sqlite.test
  325. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  326. .PHONY: bench-mysql
  327. bench-mysql: integrations.mysql.test generate-ini-mysql
  328. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  329. .PHONY: bench-mssql
  330. bench-mssql: integrations.mssql.test generate-ini-mssql
  331. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  332. .PHONY: bench-pgsql
  333. bench-pgsql: integrations.pgsql.test generate-ini-pgsql
  334. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  335. .PHONY: integration-test-coverage
  336. integration-test-coverage: integrations.cover.test generate-ini-mysql
  337. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
  338. integrations.mysql.test: git-check $(GO_SOURCES)
  339. GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql.test
  340. integrations.mysql8.test: git-check $(GO_SOURCES)
  341. GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql8.test
  342. integrations.pgsql.test: git-check $(GO_SOURCES)
  343. GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.pgsql.test
  344. integrations.mssql.test: git-check $(GO_SOURCES)
  345. GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mssql.test
  346. integrations.sqlite.test: git-check $(GO_SOURCES)
  347. GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags 'sqlite sqlite_unlock_notify'
  348. integrations.cover.test: git-check $(GO_SOURCES)
  349. GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -coverpkg $(shell echo $(PACKAGES) | tr ' ' ',') -o integrations.cover.test
  350. .PHONY: migrations.mysql.test
  351. migrations.mysql.test: $(GO_SOURCES)
  352. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql.test
  353. .PHONY: migrations.mysql8.test
  354. migrations.mysql8.test: $(GO_SOURCES)
  355. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql8.test
  356. .PHONY: migrations.pgsql.test
  357. migrations.pgsql.test: $(GO_SOURCES)
  358. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/integrations/migration-test -o migrations.pgsql.test
  359. .PHONY: migrations.mssql.test
  360. migrations.mssql.test: $(GO_SOURCES)
  361. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/integrations/migration-test -o migrations.mssql.test
  362. .PHONY: migrations.sqlite.test
  363. migrations.sqlite.test: $(GO_SOURCES)
  364. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/integrations/migration-test -o migrations.sqlite.test -tags 'sqlite sqlite_unlock_notify'
  365. .PHONY: check
  366. check: test
  367. .PHONY: install $(TAGS_PREREQ)
  368. install: $(wildcard *.go)
  369. $(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
  370. .PHONY: build
  371. build: frontend backend
  372. .PHONY: frontend
  373. frontend: node-check $(FOMANTIC_DEST) $(WEBPACK_DEST)
  374. .PHONY: backend
  375. backend: go-check generate $(EXECUTABLE)
  376. .PHONY: generate
  377. generate: $(TAGS_PREREQ)
  378. GO111MODULE=on $(GO) generate -mod=vendor -tags '$(TAGS)' $(PACKAGES)
  379. $(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
  380. GO111MODULE=on $(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
  381. .PHONY: release
  382. release: frontend generate release-windows release-linux release-darwin release-copy release-compress release-sources release-check
  383. $(DIST_DIRS):
  384. mkdir -p $(DIST_DIRS)
  385. .PHONY: release-windows
  386. release-windows: | $(DIST_DIRS)
  387. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  388. $(GO) get -u src.techknowlogick.com/xgo; \
  389. fi
  390. xgo -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
  391. ifeq ($(CI),drone)
  392. cp /build/* $(DIST)/binaries
  393. endif
  394. .PHONY: release-linux
  395. release-linux: | $(DIST_DIRS)
  396. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  397. $(GO) get -u src.techknowlogick.com/xgo; \
  398. fi
  399. xgo -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/mips64le,linux/mips,linux/mipsle' -out gitea-$(VERSION) .
  400. ifeq ($(CI),drone)
  401. cp /build/* $(DIST)/binaries
  402. endif
  403. .PHONY: release-darwin
  404. release-darwin: | $(DIST_DIRS)
  405. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  406. $(GO) get -u src.techknowlogick.com/xgo; \
  407. fi
  408. xgo -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out gitea-$(VERSION) .
  409. ifeq ($(CI),drone)
  410. cp /build/* $(DIST)/binaries
  411. endif
  412. .PHONY: release-copy
  413. release-copy: | $(DIST_DIRS)
  414. cd $(DIST); for file in `find /build -type f -name "*"`; do cp $${file} ./release/; done;
  415. .PHONY: release-check
  416. release-check: | $(DIST_DIRS)
  417. cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done;
  418. .PHONY: release-compress
  419. release-compress: | $(DIST_DIRS)
  420. @hash gxz > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  421. $(GO) get -u github.com/ulikunitz/xz/cmd/gxz; \
  422. fi
  423. cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
  424. .PHONY: release-sources
  425. release-sources: | $(DIST_DIRS) node_modules
  426. echo $(VERSION) > $(STORED_VERSION_FILE)
  427. tar --exclude=./$(DIST) --exclude=./.git --exclude=./$(MAKE_EVIDENCE_DIR) --exclude=./node_modules/.cache -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
  428. rm -f $(STORED_VERSION_FILE)
  429. node_modules: package-lock.json
  430. npm install --no-save
  431. @touch node_modules
  432. .PHONY: npm-update
  433. npm-update: node-check | node_modules
  434. npx updates -cu
  435. rm -rf node_modules package-lock.json
  436. npm install --package-lock
  437. .PHONY: js
  438. js:
  439. @echo "'make js' is deprecated, please use 'make webpack'"
  440. $(MAKE) webpack
  441. .PHONY: css
  442. css:
  443. @echo "'make css' is deprecated, please use 'make webpack'"
  444. $(MAKE) webpack
  445. .PHONY: fomantic
  446. fomantic: $(FOMANTIC_DEST)
  447. $(FOMANTIC_DEST): $(FOMANTIC_CONFIGS) package-lock.json | node_modules
  448. rm -rf $(FOMANTIC_DEST_DIR)
  449. cp web_src/fomantic/theme.config.less node_modules/fomantic-ui/src/theme.config
  450. cp web_src/fomantic/_site/globals/* node_modules/fomantic-ui/src/_site/globals/
  451. npx gulp -f node_modules/fomantic-ui/gulpfile.js build
  452. @touch $(FOMANTIC_DEST)
  453. .PHONY: webpack
  454. webpack: $(WEBPACK_DEST)
  455. $(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json | node_modules
  456. npx eslint web_src/js webpack.config.js
  457. npx stylelint web_src/less
  458. npx webpack --hide-modules --display-entrypoints=false
  459. @touch $(WEBPACK_DEST)
  460. .PHONY: update-translations
  461. update-translations:
  462. mkdir -p ./translations
  463. cd ./translations && curl -L https://crowdin.com/download/project/gitea.zip > gitea.zip && unzip gitea.zip
  464. rm ./translations/gitea.zip
  465. $(SED_INPLACE) -e 's/="/=/g' -e 's/"$$//g' ./translations/*.ini
  466. $(SED_INPLACE) -e 's/\\"/"/g' ./translations/*.ini
  467. mv ./translations/*.ini ./options/locale/
  468. rmdir ./translations
  469. .PHONY: generate-images
  470. generate-images:
  471. $(eval TMPDIR := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'gitea-temp'))
  472. mkdir -p $(TMPDIR)/images
  473. inkscape -f $(PWD)/assets/logo.svg -w 880 -h 880 -e $(PWD)/public/img/gitea-lg.png
  474. inkscape -f $(PWD)/assets/logo.svg -w 512 -h 512 -e $(PWD)/public/img/gitea-512.png
  475. inkscape -f $(PWD)/assets/logo.svg -w 192 -h 192 -e $(PWD)/public/img/gitea-192.png
  476. inkscape -f $(PWD)/assets/logo.svg -w 120 -h 120 -jC -i layer1 -e $(TMPDIR)/images/sm-1.png
  477. inkscape -f $(PWD)/assets/logo.svg -w 120 -h 120 -jC -i layer2 -e $(TMPDIR)/images/sm-2.png
  478. composite -compose atop $(TMPDIR)/images/sm-2.png $(TMPDIR)/images/sm-1.png $(PWD)/public/img/gitea-sm.png
  479. inkscape -f $(PWD)/assets/logo.svg -w 200 -h 200 -e $(PWD)/public/img/avatar_default.png
  480. inkscape -f $(PWD)/assets/logo.svg -w 180 -h 180 -e $(PWD)/public/img/favicon.png
  481. inkscape -f $(PWD)/assets/logo.svg -w 128 -h 128 -e $(TMPDIR)/images/128-raw.png
  482. inkscape -f $(PWD)/assets/logo.svg -w 64 -h 64 -e $(TMPDIR)/images/64-raw.png
  483. inkscape -f $(PWD)/assets/logo.svg -w 32 -h 32 -jC -i layer1 -e $(TMPDIR)/images/32-1.png
  484. inkscape -f $(PWD)/assets/logo.svg -w 32 -h 32 -jC -i layer2 -e $(TMPDIR)/images/32-2.png
  485. composite -compose atop $(TMPDIR)/images/32-2.png $(TMPDIR)/images/32-1.png $(TMPDIR)/images/32-raw.png
  486. inkscape -f $(PWD)/assets/logo.svg -w 16 -h 16 -jC -i layer1 -e $(TMPDIR)/images/16-raw.png
  487. zopflipng -m -y $(TMPDIR)/images/128-raw.png $(TMPDIR)/images/128.png
  488. zopflipng -m -y $(TMPDIR)/images/64-raw.png $(TMPDIR)/images/64.png
  489. zopflipng -m -y $(TMPDIR)/images/32-raw.png $(TMPDIR)/images/32.png
  490. zopflipng -m -y $(TMPDIR)/images/16-raw.png $(TMPDIR)/images/16.png
  491. rm -f $(TMPDIR)/images/*-*.png
  492. convert $(TMPDIR)/images/16.png $(TMPDIR)/images/32.png \
  493. $(TMPDIR)/images/64.png $(TMPDIR)/images/128.png \
  494. $(PWD)/public/img/favicon.ico
  495. convert -flatten $(PWD)/public/img/favicon.png $(PWD)/public/img/apple-touch-icon.png
  496. rm -rf $(TMPDIR)/images
  497. $(foreach file, $(shell find public/img -type f -name '*.png' ! -name 'loading.png'),zopflipng -m -y $(file) $(file);)
  498. .PHONY: pr\#%
  499. pr\#%: clean-all
  500. $(GO) run contrib/pr/checkout.go $*
  501. .PHONY: golangci-lint
  502. golangci-lint:
  503. @hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  504. export BINARY="golangci-lint"; \
  505. curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.20.0; \
  506. fi
  507. golangci-lint run --timeout 5m