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

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