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.

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