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

Makefile 23 kB

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