A fork of Gitea (see branch `mj`) adding Majority Judgment Polls 𐄷 over Issues and Merge Requests. https://git.mieuxvoter.fr
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.

739 lines
27 KiB

2 years ago
7 years ago
7 years ago
Use native git variants by default with go-git variants as build tag (#13673) * Move last commit cache back into modules/git Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from the interface for last commit cache Signed-off-by: Andrew Thornton <art27@cantab.net> * move cacheref to last_commit_cache Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from routers/private/hook Signed-off-by: Andrew Thornton <art27@cantab.net> * Move FindLFSFiles to pipeline Signed-off-by: Andrew Thornton <art27@cantab.net> * Make no-go-git variants Signed-off-by: Andrew Thornton <art27@cantab.net> * Submodule RefID Signed-off-by: Andrew Thornton <art27@cantab.net> * fix issue with GetCommitsInfo Signed-off-by: Andrew Thornton <art27@cantab.net> * fix GetLastCommitForPaths Signed-off-by: Andrew Thornton <art27@cantab.net> * Improve efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * More efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * even faster Signed-off-by: Andrew Thornton <art27@cantab.net> * Reduce duplication * As per @lunny Signed-off-by: Andrew Thornton <art27@cantab.net> * attempt to fix drone Signed-off-by: Andrew Thornton <art27@cantab.net> * fix test-tags Signed-off-by: Andrew Thornton <art27@cantab.net> * default to use no-go-git variants and add gogit build tag Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @6543 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 years ago
Use native git variants by default with go-git variants as build tag (#13673) * Move last commit cache back into modules/git Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from the interface for last commit cache Signed-off-by: Andrew Thornton <art27@cantab.net> * move cacheref to last_commit_cache Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from routers/private/hook Signed-off-by: Andrew Thornton <art27@cantab.net> * Move FindLFSFiles to pipeline Signed-off-by: Andrew Thornton <art27@cantab.net> * Make no-go-git variants Signed-off-by: Andrew Thornton <art27@cantab.net> * Submodule RefID Signed-off-by: Andrew Thornton <art27@cantab.net> * fix issue with GetCommitsInfo Signed-off-by: Andrew Thornton <art27@cantab.net> * fix GetLastCommitForPaths Signed-off-by: Andrew Thornton <art27@cantab.net> * Improve efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * More efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * even faster Signed-off-by: Andrew Thornton <art27@cantab.net> * Reduce duplication * As per @lunny Signed-off-by: Andrew Thornton <art27@cantab.net> * attempt to fix drone Signed-off-by: Andrew Thornton <art27@cantab.net> * fix test-tags Signed-off-by: Andrew Thornton <art27@cantab.net> * default to use no-go-git variants and add gogit build tag Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @6543 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 years ago
Use native git variants by default with go-git variants as build tag (#13673) * Move last commit cache back into modules/git Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from the interface for last commit cache Signed-off-by: Andrew Thornton <art27@cantab.net> * move cacheref to last_commit_cache Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from routers/private/hook Signed-off-by: Andrew Thornton <art27@cantab.net> * Move FindLFSFiles to pipeline Signed-off-by: Andrew Thornton <art27@cantab.net> * Make no-go-git variants Signed-off-by: Andrew Thornton <art27@cantab.net> * Submodule RefID Signed-off-by: Andrew Thornton <art27@cantab.net> * fix issue with GetCommitsInfo Signed-off-by: Andrew Thornton <art27@cantab.net> * fix GetLastCommitForPaths Signed-off-by: Andrew Thornton <art27@cantab.net> * Improve efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * More efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * even faster Signed-off-by: Andrew Thornton <art27@cantab.net> * Reduce duplication * As per @lunny Signed-off-by: Andrew Thornton <art27@cantab.net> * attempt to fix drone Signed-off-by: Andrew Thornton <art27@cantab.net> * fix test-tags Signed-off-by: Andrew Thornton <art27@cantab.net> * default to use no-go-git variants and add gogit build tag Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @6543 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 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.
3 years ago
Use native git variants by default with go-git variants as build tag (#13673) * Move last commit cache back into modules/git Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from the interface for last commit cache Signed-off-by: Andrew Thornton <art27@cantab.net> * move cacheref to last_commit_cache Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from routers/private/hook Signed-off-by: Andrew Thornton <art27@cantab.net> * Move FindLFSFiles to pipeline Signed-off-by: Andrew Thornton <art27@cantab.net> * Make no-go-git variants Signed-off-by: Andrew Thornton <art27@cantab.net> * Submodule RefID Signed-off-by: Andrew Thornton <art27@cantab.net> * fix issue with GetCommitsInfo Signed-off-by: Andrew Thornton <art27@cantab.net> * fix GetLastCommitForPaths Signed-off-by: Andrew Thornton <art27@cantab.net> * Improve efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * More efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * even faster Signed-off-by: Andrew Thornton <art27@cantab.net> * Reduce duplication * As per @lunny Signed-off-by: Andrew Thornton <art27@cantab.net> * attempt to fix drone Signed-off-by: Andrew Thornton <art27@cantab.net> * fix test-tags Signed-off-by: Andrew Thornton <art27@cantab.net> * default to use no-go-git variants and add gogit build tag Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @6543 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 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.
3 years ago
Use native git variants by default with go-git variants as build tag (#13673) * Move last commit cache back into modules/git Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from the interface for last commit cache Signed-off-by: Andrew Thornton <art27@cantab.net> * move cacheref to last_commit_cache Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from routers/private/hook Signed-off-by: Andrew Thornton <art27@cantab.net> * Move FindLFSFiles to pipeline Signed-off-by: Andrew Thornton <art27@cantab.net> * Make no-go-git variants Signed-off-by: Andrew Thornton <art27@cantab.net> * Submodule RefID Signed-off-by: Andrew Thornton <art27@cantab.net> * fix issue with GetCommitsInfo Signed-off-by: Andrew Thornton <art27@cantab.net> * fix GetLastCommitForPaths Signed-off-by: Andrew Thornton <art27@cantab.net> * Improve efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * More efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * even faster Signed-off-by: Andrew Thornton <art27@cantab.net> * Reduce duplication * As per @lunny Signed-off-by: Andrew Thornton <art27@cantab.net> * attempt to fix drone Signed-off-by: Andrew Thornton <art27@cantab.net> * fix test-tags Signed-off-by: Andrew Thornton <art27@cantab.net> * default to use no-go-git variants and add gogit build tag Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @6543 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 years ago
Use native git variants by default with go-git variants as build tag (#13673) * Move last commit cache back into modules/git Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from the interface for last commit cache Signed-off-by: Andrew Thornton <art27@cantab.net> * move cacheref to last_commit_cache Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from routers/private/hook Signed-off-by: Andrew Thornton <art27@cantab.net> * Move FindLFSFiles to pipeline Signed-off-by: Andrew Thornton <art27@cantab.net> * Make no-go-git variants Signed-off-by: Andrew Thornton <art27@cantab.net> * Submodule RefID Signed-off-by: Andrew Thornton <art27@cantab.net> * fix issue with GetCommitsInfo Signed-off-by: Andrew Thornton <art27@cantab.net> * fix GetLastCommitForPaths Signed-off-by: Andrew Thornton <art27@cantab.net> * Improve efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * More efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * even faster Signed-off-by: Andrew Thornton <art27@cantab.net> * Reduce duplication * As per @lunny Signed-off-by: Andrew Thornton <art27@cantab.net> * attempt to fix drone Signed-off-by: Andrew Thornton <art27@cantab.net> * fix test-tags Signed-off-by: Andrew Thornton <art27@cantab.net> * default to use no-go-git variants and add gogit build tag Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @6543 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 years ago
Use native git variants by default with go-git variants as build tag (#13673) * Move last commit cache back into modules/git Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from the interface for last commit cache Signed-off-by: Andrew Thornton <art27@cantab.net> * move cacheref to last_commit_cache Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from routers/private/hook Signed-off-by: Andrew Thornton <art27@cantab.net> * Move FindLFSFiles to pipeline Signed-off-by: Andrew Thornton <art27@cantab.net> * Make no-go-git variants Signed-off-by: Andrew Thornton <art27@cantab.net> * Submodule RefID Signed-off-by: Andrew Thornton <art27@cantab.net> * fix issue with GetCommitsInfo Signed-off-by: Andrew Thornton <art27@cantab.net> * fix GetLastCommitForPaths Signed-off-by: Andrew Thornton <art27@cantab.net> * Improve efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * More efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * even faster Signed-off-by: Andrew Thornton <art27@cantab.net> * Reduce duplication * As per @lunny Signed-off-by: Andrew Thornton <art27@cantab.net> * attempt to fix drone Signed-off-by: Andrew Thornton <art27@cantab.net> * fix test-tags Signed-off-by: Andrew Thornton <art27@cantab.net> * default to use no-go-git variants and add gogit build tag Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @6543 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 years ago
7 years ago
7 years ago
  1. ifeq ($(USE_REPO_TEST_DIR),1)
  2. # This rule replaces the whole Makefile when we're trying to use /tmp repository temporary files
  3. location = $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
  4. self := $(location)
  5. %:
  6. @tmpdir=`mktemp --tmpdir -d` ; \
  7. echo Using temporary directory $$tmpdir for test repositories ; \
  8. USE_REPO_TEST_DIR= $(MAKE) -f $(self) --no-print-directory REPO_TEST_DIR=$$tmpdir/ $@ ; \
  9. STATUS=$$? ; rm -r "$$tmpdir" ; exit $$STATUS
  10. else
  11. # This is the "normal" part of the Makefile
  12. DIST := dist
  13. DIST_DIRS := $(DIST)/binaries $(DIST)/release
  14. IMPORT := code.gitea.io/gitea
  15. export GO111MODULE=on
  16. GO ?= go
  17. SHASUM ?= shasum -a 256
  18. HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
  19. COMMA := ,
  20. XGO_VERSION := go-1.16.x
  21. MIN_GO_VERSION := 001014000
  22. MIN_NODE_VERSION := 010013000
  23. DOCKER_IMAGE ?= gitea/gitea
  24. DOCKER_TAG ?= latest
  25. DOCKER_REF := $(DOCKER_IMAGE):$(DOCKER_TAG)
  26. ifeq ($(HAS_GO), GO)
  27. GOPATH ?= $(shell $(GO) env GOPATH)
  28. export PATH := $(GOPATH)/bin:$(PATH)
  29. CGO_EXTRA_CFLAGS := -DSQLITE_MAX_VARIABLE_NUMBER=32766
  30. CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
  31. endif
  32. ifeq ($(OS), Windows_NT)
  33. GOFLAGS := -v -buildmode=exe
  34. EXECUTABLE ?= gitea.exe
  35. else
  36. GOFLAGS := -v
  37. EXECUTABLE ?= gitea
  38. endif
  39. ifeq ($(shell sed --version 2>/dev/null | grep -q GNU && echo gnu),gnu)
  40. SED_INPLACE := sed -i
  41. else
  42. SED_INPLACE := sed -i ''
  43. endif
  44. GOFMT ?= gofmt -s
  45. EXTRA_GOFLAGS ?=
  46. MAKE_VERSION := $(shell $(MAKE) -v | head -n 1)
  47. MAKE_EVIDENCE_DIR := .make_evidence
  48. ifneq ($(RACE_ENABLED),)
  49. GOTESTFLAGS ?= -race
  50. endif
  51. STORED_VERSION_FILE := VERSION
  52. ifneq ($(DRONE_TAG),)
  53. VERSION ?= $(subst v,,$(DRONE_TAG))
  54. GITEA_VERSION ?= $(VERSION)
  55. else
  56. ifneq ($(DRONE_BRANCH),)
  57. VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
  58. else
  59. VERSION ?= master
  60. endif
  61. STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null)
  62. ifneq ($(STORED_VERSION),)
  63. GITEA_VERSION ?= $(STORED_VERSION)
  64. else
  65. GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
  66. endif
  67. endif
  68. LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
  69. LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
  70. GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations/migration-test,$(filter-out code.gitea.io/gitea/integrations,$(shell $(GO) list -mod=vendor ./... | grep -v /vendor/)))
  71. FOMANTIC_CONFIGS := semantic.json web_src/fomantic/theme.config.less web_src/fomantic/_site/globals/site.variables
  72. FOMANTIC_DEST := web_src/fomantic/build/semantic.js web_src/fomantic/build/semantic.css
  73. FOMANTIC_DEST_DIR := web_src/fomantic/build
  74. WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f)
  75. WEBPACK_CONFIGS := webpack.config.js
  76. WEBPACK_DEST := public/js/index.js public/css/index.css
  77. WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/img/webpack public/serviceworker.js
  78. BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
  79. BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))
  80. SVG_DEST_DIR := public/img/svg
  81. AIR_TMP_DIR := .air
  82. TAGS ?=
  83. TAGS_SPLIT := $(subst $(COMMA), ,$(TAGS))
  84. TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
  85. TEST_TAGS ?= sqlite sqlite_unlock_notify
  86. GO_DIRS := cmd integrations models modules routers build services vendor tools
  87. GO_SOURCES := $(wildcard *.go)
  88. 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)
  89. ifeq ($(filter $(TAGS_SPLIT),bindata),bindata)
  90. GO_SOURCES += $(BINDATA_DEST)
  91. endif
  92. GO_SOURCES_OWN := $(filter-out vendor/% %/bindata.go, $(GO_SOURCES))
  93. #To update swagger use: GO111MODULE=on go get -u github.com/go-swagger/go-swagger/cmd/swagger
  94. SWAGGER := $(GO) run -mod=vendor github.com/go-swagger/go-swagger/cmd/swagger
  95. SWAGGER_SPEC := templates/swagger/v1_json.tmpl
  96. SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl \| JSEscape \| Safe}}/api/v1"|g
  97. SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl \| JSEscape \| Safe}}/api/v1"|"basePath": "/api/v1"|g
  98. SWAGGER_EXCLUDE := code.gitea.io/sdk
  99. SWAGGER_NEWLINE_COMMAND := -e '$$a\'
  100. TEST_MYSQL_HOST ?= mysql:3306
  101. TEST_MYSQL_DBNAME ?= testgitea
  102. TEST_MYSQL_USERNAME ?= root
  103. TEST_MYSQL_PASSWORD ?=
  104. TEST_MYSQL8_HOST ?= mysql8:3306
  105. TEST_MYSQL8_DBNAME ?= testgitea
  106. TEST_MYSQL8_USERNAME ?= root
  107. TEST_MYSQL8_PASSWORD ?=
  108. TEST_PGSQL_HOST ?= pgsql:5432
  109. TEST_PGSQL_DBNAME ?= testgitea
  110. TEST_PGSQL_USERNAME ?= postgres
  111. TEST_PGSQL_PASSWORD ?= postgres
  112. TEST_PGSQL_SCHEMA ?= gtestschema
  113. TEST_MSSQL_HOST ?= mssql:1433
  114. TEST_MSSQL_DBNAME ?= gitea
  115. TEST_MSSQL_USERNAME ?= sa
  116. TEST_MSSQL_PASSWORD ?= MwantsaSecurePassword1
  117. .PHONY: all
  118. all: build
  119. .PHONY: help
  120. help:
  121. @echo "Make Routines:"
  122. @echo " - \"\" equivalent to \"build\""
  123. @echo " - build build everything"
  124. @echo " - frontend build frontend files"
  125. @echo " - backend build backend files"
  126. @echo " - watch watch everything and continuously rebuild"
  127. @echo " - watch-frontend watch frontend files and continuously rebuild"
  128. @echo " - watch-backend watch backend files and continuously rebuild"
  129. @echo " - clean delete backend and integration files"
  130. @echo " - clean-all delete backend, frontend and integration files"
  131. @echo " - lint lint everything"
  132. @echo " - lint-frontend lint frontend files"
  133. @echo " - lint-backend lint backend files"
  134. @echo " - checks run various consistency checks"
  135. @echo " - checks-frontend check frontend files"
  136. @echo " - checks-backend check backend files"
  137. @echo " - webpack build webpack files"
  138. @echo " - svg build svg files"
  139. @echo " - fomantic build fomantic files"
  140. @echo " - generate run \"go generate\""
  141. @echo " - fmt format the Go code"
  142. @echo " - generate-license update license files"
  143. @echo " - generate-gitignore update gitignore files"
  144. @echo " - generate-manpage generate manpage"
  145. @echo " - generate-swagger generate the swagger spec from code comments"
  146. @echo " - swagger-validate check if the swagger spec is valid"
  147. @echo " - golangci-lint run golangci-lint linter"
  148. @echo " - revive run revive linter"
  149. @echo " - misspell check for misspellings"
  150. @echo " - vet examines Go source code and reports suspicious constructs"
  151. @echo " - test[\#TestSpecificName] run unit test"
  152. @echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite"
  153. @echo " - pr#<index> build and start gitea from a PR with integration test data loaded"
  154. .PHONY: go-check
  155. go-check:
  156. $(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');))
  157. @if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \
  158. echo "Gitea requires Go 1.14 or greater to build. You can get it at https://golang.org/dl/"; \
  159. exit 1; \
  160. fi
  161. .PHONY: git-check
  162. git-check:
  163. @if git lfs >/dev/null 2>&1 ; then : ; else \
  164. echo "Gitea requires git with lfs support to run tests." ; \
  165. exit 1; \
  166. fi
  167. .PHONY: node-check
  168. node-check:
  169. $(eval NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell node -v | cut -c2- | tr '.' ' ');))
  170. $(eval NPM_MISSING := $(shell hash npm > /dev/null 2>&1 || echo 1))
  171. @if [ "$(NODE_VERSION)" -lt "$(MIN_NODE_VERSION)" -o "$(NPM_MISSING)" = "1" ]; then \
  172. echo "Gitea requires Node.js 10 or greater and npm to build. You can get it at https://nodejs.org/en/download/"; \
  173. exit 1; \
  174. fi
  175. .PHONY: clean-all
  176. clean-all: clean
  177. rm -rf $(WEBPACK_DEST_ENTRIES)
  178. .PHONY: clean
  179. clean:
  180. $(GO) clean -i ./...
  181. rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST) $(BINDATA_HASH) \
  182. integrations*.test \
  183. integrations/gitea-integration-pgsql/ integrations/gitea-integration-mysql/ integrations/gitea-integration-mysql8/ integrations/gitea-integration-sqlite/ \
  184. integrations/gitea-integration-mssql/ integrations/indexers-mysql/ integrations/indexers-mysql8/ integrations/indexers-pgsql integrations/indexers-sqlite \
  185. integrations/indexers-mssql integrations/mysql.ini integrations/mysql8.ini integrations/pgsql.ini integrations/mssql.ini man/
  186. .PHONY: fmt
  187. fmt:
  188. @echo "Running go fmt..."
  189. @$(GOFMT) -w $(GO_SOURCES_OWN)
  190. .PHONY: vet
  191. vet:
  192. @echo "Running go vet..."
  193. @$(GO) vet $(GO_PACKAGES)
  194. @GOOS= GOARCH= $(GO) build -mod=vendor code.gitea.io/gitea-vet
  195. @$(GO) vet -vettool=gitea-vet $(GO_PACKAGES)
  196. .PHONY: $(TAGS_EVIDENCE)
  197. $(TAGS_EVIDENCE):
  198. @mkdir -p $(MAKE_EVIDENCE_DIR)
  199. @echo "$(TAGS)" > $(TAGS_EVIDENCE)
  200. ifneq "$(TAGS)" "$(shell cat $(TAGS_EVIDENCE) 2>/dev/null)"
  201. TAGS_PREREQ := $(TAGS_EVIDENCE)
  202. endif
  203. .PHONY: generate-swagger
  204. generate-swagger:
  205. $(SWAGGER) generate spec -x "$(SWAGGER_EXCLUDE)" -o './$(SWAGGER_SPEC)'
  206. $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
  207. $(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)'
  208. .PHONY: swagger-check
  209. swagger-check: generate-swagger
  210. @diff=$$(git diff '$(SWAGGER_SPEC)'); \
  211. if [ -n "$$diff" ]; then \
  212. echo "Please run 'make generate-swagger' and commit the result:"; \
  213. echo "$${diff}"; \
  214. exit 1; \
  215. fi
  216. .PHONY: swagger-validate
  217. swagger-validate:
  218. $(SED_INPLACE) '$(SWAGGER_SPEC_S_JSON)' './$(SWAGGER_SPEC)'
  219. $(SWAGGER) validate './$(SWAGGER_SPEC)'
  220. $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
  221. .PHONY: errcheck
  222. errcheck:
  223. @hash errcheck > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  224. GO111MODULE=off $(GO) get -u github.com/kisielk/errcheck; \
  225. fi
  226. @echo "Running errcheck..."
  227. @errcheck $(GO_PACKAGES)
  228. .PHONY: revive
  229. revive:
  230. GO111MODULE=on $(GO) run -mod=vendor build/lint.go -config .revive.toml -exclude=./vendor/... ./... || exit 1
  231. .PHONY: misspell-check
  232. misspell-check:
  233. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  234. GO111MODULE=off $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  235. fi
  236. @echo "Running misspell-check..."
  237. @misspell -error -i unknwon,destory $(GO_SOURCES_OWN)
  238. .PHONY: misspell
  239. misspell:
  240. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  241. GO111MODULE=off $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  242. fi
  243. @echo "Running go misspell..."
  244. @misspell -w -i unknwon $(GO_SOURCES_OWN)
  245. .PHONY: fmt-check
  246. fmt-check:
  247. # get all go files and run go fmt on them
  248. @diff=$$($(GOFMT) -d $(GO_SOURCES_OWN)); \
  249. if [ -n "$$diff" ]; then \
  250. echo "Please run 'make fmt' and commit the result:"; \
  251. echo "$${diff}"; \
  252. exit 1; \
  253. fi
  254. .PHONY: checks
  255. checks: checks-frontend checks-backend
  256. .PHONY: checks-frontend
  257. checks-frontend: svg-check
  258. .PHONY: checks-backend
  259. checks-backend: misspell-check test-vendor swagger-check swagger-validate
  260. .PHONY: lint
  261. lint: lint-frontend lint-backend
  262. .PHONY: lint-frontend
  263. lint-frontend: node_modules
  264. npx eslint --color --max-warnings=0 web_src/js build templates webpack.config.js
  265. npx stylelint --color --max-warnings=0 web_src/less
  266. .PHONY: lint-backend
  267. lint-backend: golangci-lint revive vet
  268. .PHONY: watch
  269. watch:
  270. bash tools/watch.sh
  271. .PHONY: watch-frontend
  272. watch-frontend: node-check node_modules
  273. rm -rf $(WEBPACK_DEST_ENTRIES)
  274. NODE_ENV=development npx webpack --watch --progress
  275. .PHONY: watch-backend
  276. watch-backend: go-check
  277. @hash air > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  278. GO111MODULE=off $(GO) get -u github.com/cosmtrek/air; \
  279. fi
  280. air -c .air.conf
  281. .PHONY: test
  282. test:
  283. @echo "Running go test with -tags '$(TEST_TAGS)'..."
  284. @$(GO) test $(GOTESTFLAGS) -mod=vendor -tags='$(TEST_TAGS)' $(GO_PACKAGES)
  285. .PHONY: test-check
  286. test-check:
  287. @echo "Running test-check...";
  288. @diff=$$(git status -s); \
  289. if [ -n "$$diff" ]; then \
  290. echo "make test has changed files in the source tree:"; \
  291. echo "$${diff}"; \
  292. echo "You should change the tests to create these files in a temporary directory."; \
  293. echo "Do not simply add these files to .gitignore"; \
  294. exit 1; \
  295. fi
  296. .PHONY: test\#%
  297. test\#%:
  298. @echo "Running go test with -tags '$(TEST_TAGS)'..."
  299. @$(GO) test -mod=vendor -tags='$(TEST_TAGS)' -run $(subst .,/,$*) $(GO_PACKAGES)
  300. .PHONY: coverage
  301. coverage:
  302. GO111MODULE=on $(GO) run -mod=vendor build/gocovmerge.go integration.coverage.out $(shell find . -type f -name "coverage.out") > coverage.all
  303. .PHONY: unit-test-coverage
  304. unit-test-coverage:
  305. @echo "Running unit-test-coverage -tags '$(TEST_TAGS)'..."
  306. @$(GO) test $(GOTESTFLAGS) -mod=vendor -tags='$(TEST_TAGS)' -cover -coverprofile coverage.out $(GO_PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
  307. .PHONY: vendor
  308. vendor:
  309. $(GO) mod tidy && $(GO) mod vendor
  310. .PHONY: test-vendor
  311. test-vendor: vendor
  312. @diff=$$(git diff vendor/); \
  313. if [ -n "$$diff" ]; then \
  314. echo "Please run 'make vendor' and commit the result:"; \
  315. echo "$${diff}"; \
  316. exit 1; \
  317. fi
  318. generate-ini-sqlite:
  319. sed -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
  320. integrations/sqlite.ini.tmpl > integrations/sqlite.ini
  321. .PHONY: test-sqlite
  322. test-sqlite: integrations.sqlite.test generate-ini-sqlite
  323. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test
  324. .PHONY: test-sqlite\#%
  325. test-sqlite\#%: integrations.sqlite.test generate-ini-sqlite
  326. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.run $(subst .,/,$*)
  327. .PHONY: test-sqlite-migration
  328. test-sqlite-migration: migrations.sqlite.test generate-ini-sqlite
  329. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/sqlite.ini ./migrations.sqlite.test
  330. generate-ini-mysql:
  331. sed -e 's|{{TEST_MYSQL_HOST}}|${TEST_MYSQL_HOST}|g' \
  332. -e 's|{{TEST_MYSQL_DBNAME}}|${TEST_MYSQL_DBNAME}|g' \
  333. -e 's|{{TEST_MYSQL_USERNAME}}|${TEST_MYSQL_USERNAME}|g' \
  334. -e 's|{{TEST_MYSQL_PASSWORD}}|${TEST_MYSQL_PASSWORD}|g' \
  335. -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
  336. integrations/mysql.ini.tmpl > integrations/mysql.ini
  337. .PHONY: test-mysql
  338. test-mysql: integrations.mysql.test generate-ini-mysql
  339. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test
  340. .PHONY: test-mysql\#%
  341. test-mysql\#%: integrations.mysql.test generate-ini-mysql
  342. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.run $(subst .,/,$*)
  343. .PHONY: test-mysql-migration
  344. test-mysql-migration: migrations.mysql.test generate-ini-mysql
  345. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/mysql.ini ./migrations.mysql.test
  346. generate-ini-mysql8:
  347. sed -e 's|{{TEST_MYSQL8_HOST}}|${TEST_MYSQL8_HOST}|g' \
  348. -e 's|{{TEST_MYSQL8_DBNAME}}|${TEST_MYSQL8_DBNAME}|g' \
  349. -e 's|{{TEST_MYSQL8_USERNAME}}|${TEST_MYSQL8_USERNAME}|g' \
  350. -e 's|{{TEST_MYSQL8_PASSWORD}}|${TEST_MYSQL8_PASSWORD}|g' \
  351. -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
  352. integrations/mysql8.ini.tmpl > integrations/mysql8.ini
  353. .PHONY: test-mysql8
  354. test-mysql8: integrations.mysql8.test generate-ini-mysql8
  355. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/mysql8.ini ./integrations.mysql8.test
  356. .PHONY: test-mysql8\#%
  357. test-mysql8\#%: integrations.mysql8.test generate-ini-mysql8
  358. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/mysql8.ini ./integrations.mysql8.test -test.run $(subst .,/,$*)
  359. .PHONY: test-mysql8-migration
  360. test-mysql8-migration: migrations.mysql8.test generate-ini-mysql8
  361. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/mysql8.ini ./migrations.mysql8.test
  362. generate-ini-pgsql:
  363. sed -e 's|{{TEST_PGSQL_HOST}}|${TEST_PGSQL_HOST}|g' \
  364. -e 's|{{TEST_PGSQL_DBNAME}}|${TEST_PGSQL_DBNAME}|g' \
  365. -e 's|{{TEST_PGSQL_USERNAME}}|${TEST_PGSQL_USERNAME}|g' \
  366. -e 's|{{TEST_PGSQL_PASSWORD}}|${TEST_PGSQL_PASSWORD}|g' \
  367. -e 's|{{TEST_PGSQL_SCHEMA}}|${TEST_PGSQL_SCHEMA}|g' \
  368. -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
  369. integrations/pgsql.ini.tmpl > integrations/pgsql.ini
  370. .PHONY: test-pgsql
  371. test-pgsql: integrations.pgsql.test generate-ini-pgsql
  372. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test
  373. .PHONY: test-pgsql\#%
  374. test-pgsql\#%: integrations.pgsql.test generate-ini-pgsql
  375. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.run $(subst .,/,$*)
  376. .PHONY: test-pgsql-migration
  377. test-pgsql-migration: migrations.pgsql.test generate-ini-pgsql
  378. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/pgsql.ini ./migrations.pgsql.test
  379. generate-ini-mssql:
  380. sed -e 's|{{TEST_MSSQL_HOST}}|${TEST_MSSQL_HOST}|g' \
  381. -e 's|{{TEST_MSSQL_DBNAME}}|${TEST_MSSQL_DBNAME}|g' \
  382. -e 's|{{TEST_MSSQL_USERNAME}}|${TEST_MSSQL_USERNAME}|g' \
  383. -e 's|{{TEST_MSSQL_PASSWORD}}|${TEST_MSSQL_PASSWORD}|g' \
  384. -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
  385. integrations/mssql.ini.tmpl > integrations/mssql.ini
  386. .PHONY: test-mssql
  387. test-mssql: integrations.mssql.test generate-ini-mssql
  388. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test
  389. .PHONY: test-mssql\#%
  390. test-mssql\#%: integrations.mssql.test generate-ini-mssql
  391. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test -test.run $(subst .,/,$*)
  392. .PHONY: test-mssql-migration
  393. test-mssql-migration: migrations.mssql.test generate-ini-mssql
  394. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/mssql.ini ./migrations.mssql.test -test.failfast
  395. .PHONY: bench-sqlite
  396. bench-sqlite: integrations.sqlite.test generate-ini-sqlite
  397. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  398. .PHONY: bench-mysql
  399. bench-mysql: integrations.mysql.test generate-ini-mysql
  400. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  401. .PHONY: bench-mssql
  402. bench-mssql: integrations.mssql.test generate-ini-mssql
  403. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  404. .PHONY: bench-pgsql
  405. bench-pgsql: integrations.pgsql.test generate-ini-pgsql
  406. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  407. .PHONY: integration-test-coverage
  408. integration-test-coverage: integrations.cover.test generate-ini-mysql
  409. GITEA_ROOT="$(CURDIR)" GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
  410. integrations.mysql.test: git-check $(GO_SOURCES)
  411. $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql.test
  412. integrations.mysql8.test: git-check $(GO_SOURCES)
  413. $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql8.test
  414. integrations.pgsql.test: git-check $(GO_SOURCES)
  415. $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.pgsql.test
  416. integrations.mssql.test: git-check $(GO_SOURCES)
  417. $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mssql.test
  418. integrations.sqlite.test: git-check $(GO_SOURCES)
  419. $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags '$(TEST_TAGS)'
  420. integrations.cover.test: git-check $(GO_SOURCES)
  421. $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -coverpkg $(shell echo $(GO_PACKAGES) | tr ' ' ',') -o integrations.cover.test
  422. .PHONY: migrations.mysql.test
  423. migrations.mysql.test: $(GO_SOURCES)
  424. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql.test
  425. .PHONY: migrations.mysql8.test
  426. migrations.mysql8.test: $(GO_SOURCES)
  427. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql8.test
  428. .PHONY: migrations.pgsql.test
  429. migrations.pgsql.test: $(GO_SOURCES)
  430. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/integrations/migration-test -o migrations.pgsql.test
  431. .PHONY: migrations.mssql.test
  432. migrations.mssql.test: $(GO_SOURCES)
  433. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/integrations/migration-test -o migrations.mssql.test
  434. .PHONY: migrations.sqlite.test
  435. migrations.sqlite.test: $(GO_SOURCES)
  436. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/integrations/migration-test -o migrations.sqlite.test -tags '$(TEST_TAGS)'
  437. .PHONY: check
  438. check: test
  439. .PHONY: install $(TAGS_PREREQ)
  440. install: $(wildcard *.go)
  441. CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
  442. .PHONY: build
  443. build: frontend backend
  444. .PHONY: frontend
  445. frontend: node-check $(WEBPACK_DEST)
  446. .PHONY: backend
  447. backend: go-check generate $(EXECUTABLE)
  448. .PHONY: generate
  449. generate: $(TAGS_PREREQ)
  450. @echo "Running go generate..."
  451. @CC= GOOS= GOARCH= $(GO) generate -mod=vendor -tags '$(TAGS)' $(GO_PACKAGES)
  452. $(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
  453. CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
  454. .PHONY: release
  455. release: frontend generate release-windows release-linux release-darwin release-copy release-compress release-sources release-docs release-check
  456. $(DIST_DIRS):
  457. mkdir -p $(DIST_DIRS)
  458. .PHONY: release-windows
  459. release-windows: | $(DIST_DIRS)
  460. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  461. $(GO) install src.techknowlogick.com/xgo@latest; \
  462. fi
  463. CGO_CFLAGS="$(CGO_CFLAGS)" xgo -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
  464. ifeq (,$(findstring gogit,$(TAGS)))
  465. CGO_CFLAGS="$(CGO_CFLAGS)" xgo -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'netgo osusergo gogit $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION)-gogit .
  466. endif
  467. ifeq ($(CI),drone)
  468. cp /build/* $(DIST)/binaries
  469. endif
  470. .PHONY: release-linux
  471. release-linux: | $(DIST_DIRS)
  472. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  473. $(GO) install src.techknowlogick.com/xgo@latest; \
  474. fi
  475. CGO_CFLAGS="$(CGO_CFLAGS)" xgo -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(LINUX_ARCHS)' -out gitea-$(VERSION) .
  476. ifeq ($(CI),drone)
  477. cp /build/* $(DIST)/binaries
  478. endif
  479. .PHONY: release-darwin
  480. release-darwin: | $(DIST_DIRS)
  481. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  482. $(GO) install src.techknowlogick.com/xgo@latest; \
  483. fi
  484. CGO_CFLAGS="$(CGO_CFLAGS)" xgo -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin-10.12/amd64,darwin-10.12/arm64' -out gitea-$(VERSION) .
  485. ifeq ($(CI),drone)
  486. cp /build/* $(DIST)/binaries
  487. endif
  488. .PHONY: release-copy
  489. release-copy: | $(DIST_DIRS)
  490. cd $(DIST); for file in `find /build -type f -name "*"`; do cp $${file} ./release/; done;
  491. .PHONY: release-check
  492. release-check: | $(DIST_DIRS)
  493. cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done;
  494. .PHONY: release-compress
  495. release-compress: | $(DIST_DIRS)
  496. @hash gxz > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  497. GO111MODULE=off $(GO) get -u github.com/ulikunitz/xz/cmd/gxz; \
  498. fi
  499. cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
  500. .PHONY: release-sources
  501. release-sources: | $(DIST_DIRS) node_modules
  502. echo $(VERSION) > $(STORED_VERSION_FILE)
  503. tar --exclude=./$(DIST) --exclude=./.git --exclude=./$(MAKE_EVIDENCE_DIR) --exclude=./node_modules/.cache --exclude=./$(AIR_TMP_DIR) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
  504. rm -f $(STORED_VERSION_FILE)
  505. .PHONY: release-docs
  506. release-docs: | $(DIST_DIRS) docs
  507. tar -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs/public .
  508. .PHONY: docs
  509. docs:
  510. @hash hugo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  511. curl -sL https://github.com/gohugoio/hugo/releases/download/v0.74.3/hugo_0.74.3_Linux-64bit.tar.gz | tar zxf - -C /tmp && mv /tmp/hugo /usr/bin/hugo && chmod +x /usr/bin/hugo; \
  512. fi
  513. cd docs; make trans-copy clean build-offline;
  514. node_modules: package-lock.json
  515. npm install --no-save
  516. @touch node_modules
  517. .PHONY: npm-update
  518. npm-update: node-check | node_modules
  519. npx updates -cu
  520. rm -rf node_modules package-lock.json
  521. npm install --package-lock
  522. @touch node_modules
  523. .PHONY: fomantic
  524. fomantic: $(FOMANTIC_DEST)
  525. $(FOMANTIC_DEST): $(FOMANTIC_CONFIGS) | node_modules
  526. @if [ ! -d node_modules/fomantic-ui ]; then \
  527. npm install --no-save --no-package-lock fomantic-ui@2.8.7; \
  528. fi
  529. rm -rf $(FOMANTIC_DEST_DIR)
  530. cp -f web_src/fomantic/theme.config.less node_modules/fomantic-ui/src/theme.config
  531. cp -rf web_src/fomantic/_site/* node_modules/fomantic-ui/src/_site/
  532. npx gulp -f node_modules/fomantic-ui/gulpfile.js build
  533. @touch $(FOMANTIC_DEST)
  534. .PHONY: webpack
  535. webpack: $(WEBPACK_DEST)
  536. $(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json | node_modules
  537. rm -rf $(WEBPACK_DEST_ENTRIES)
  538. npx webpack
  539. @touch $(WEBPACK_DEST)
  540. .PHONY: svg
  541. svg: node-check | node_modules
  542. rm -rf $(SVG_DEST_DIR)
  543. node build/generate-svg.js
  544. .PHONY: svg-check
  545. svg-check: svg
  546. @git add $(SVG_DEST_DIR)
  547. @diff=$$(git diff --cached $(SVG_DEST_DIR)); \
  548. if [ -n "$$diff" ]; then \
  549. echo "Please run 'make svg' and 'git add $(SVG_DEST_DIR)' and commit the result:"; \
  550. echo "$${diff}"; \
  551. exit 1; \
  552. fi
  553. .PHONY: update-translations
  554. update-translations:
  555. mkdir -p ./translations
  556. cd ./translations && curl -L https://crowdin.com/download/project/gitea.zip > gitea.zip && unzip gitea.zip
  557. rm ./translations/gitea.zip
  558. $(SED_INPLACE) -e 's/="/=/g' -e 's/"$$//g' ./translations/*.ini
  559. $(SED_INPLACE) -e 's/\\"/"/g' ./translations/*.ini
  560. mv ./translations/*.ini ./options/locale/
  561. rmdir ./translations
  562. .PHONY: generate-license
  563. generate-license:
  564. GO111MODULE=on $(GO) run build/generate-licenses.go
  565. .PHONY: generate-gitignore
  566. generate-gitignore:
  567. GO111MODULE=on $(GO) run build/generate-gitignores.go
  568. .PHONY: generate-images
  569. generate-images: | node_modules
  570. npm install --no-save --no-package-lock fabric@4 imagemin-zopfli@7
  571. node build/generate-images.js $(TAGS)
  572. .PHONY: generate-manpage
  573. generate-manpage:
  574. @[ -f gitea ] || make backend
  575. @mkdir -p man/man1/ man/man5
  576. @./gitea docs --man > man/man1/gitea.1
  577. @gzip -9 man/man1/gitea.1 && echo man/man1/gitea.1.gz created
  578. @#TODO A smal script witch format config-cheat-sheet.en-us.md nicely to suit as config man page
  579. .PHONY: pr\#%
  580. pr\#%: clean-all
  581. $(GO) run contrib/pr/checkout.go $*
  582. .PHONY: golangci-lint
  583. golangci-lint:
  584. @hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  585. export BINARY="golangci-lint"; \
  586. curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.37.0; \
  587. fi
  588. golangci-lint run --timeout 10m
  589. .PHONY: docker
  590. docker:
  591. docker build --disable-content-trust=false -t $(DOCKER_REF) .
  592. # support also build args docker build --build-arg GITEA_VERSION=v1.2.3 --build-arg TAGS="bindata sqlite sqlite_unlock_notify" .
  593. .PHONY: docker-build
  594. docker-build:
  595. docker run -ti --rm -v "$(CURDIR):/srv/app/src/code.gitea.io/gitea" -w /srv/app/src/code.gitea.io/gitea -e TAGS="bindata $(TAGS)" LDFLAGS="$(LDFLAGS)" CGO_EXTRA_CFLAGS="$(CGO_EXTRA_CFLAGS)" webhippie/golang:edge make clean build
  596. # This endif closes the if at the top of the file
  597. endif