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 21KB

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