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

8 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>
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>
3 years ago
Split CI pipelines (#23385) - This PR attempts to split our various DB tests into separate pipelines. - It splits up some of the extra feature-related tests rather than having most of them in the MySQL test. - It disables the race detector for some of the pipelines as well, as it can cause slower runs and is mostly redundant when the pipelines just swap DBs. - It builds without SQLite support for any of the non-SQLite pipelines. - It moves the e2e test to using SQLite rather than PG (partially because I moved the minio tests to PG and that mucked up the test config, and partially because it avoids another running service) - It splits up the `go mod download` task in the Makefile from the tool installation, as the tools are only needed in the compliance pipeline. (Arguably even some of the tools aren't needed there, but that could be a follow-up PR) - SQLite is now the only arm64 pipeline, moving PG back to amd64 which can leverage autoscaler Should resolve #22010 - one thing that wasn't changed here but is mentioned in that issue, unit tests are needed in the same pipeline as an integration test in order to form a complete coverage report (at least as far as I could tell), so for now it remains in a pipeline with a DB integration test. Please let me know if I've inadvertently changed something that was how it was on purpose. --- I will say sometimes it's hard to pin down the average time, as a pipeline could be waiting for a runner for X minutes and that brings the total up by X minutes as well, but overall this does seem to be faster on average. --------- Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
1 year 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.
4 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>
3 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.
4 years ago
8 years ago
8 years ago
Split CI pipelines (#23385) - This PR attempts to split our various DB tests into separate pipelines. - It splits up some of the extra feature-related tests rather than having most of them in the MySQL test. - It disables the race detector for some of the pipelines as well, as it can cause slower runs and is mostly redundant when the pipelines just swap DBs. - It builds without SQLite support for any of the non-SQLite pipelines. - It moves the e2e test to using SQLite rather than PG (partially because I moved the minio tests to PG and that mucked up the test config, and partially because it avoids another running service) - It splits up the `go mod download` task in the Makefile from the tool installation, as the tools are only needed in the compliance pipeline. (Arguably even some of the tools aren't needed there, but that could be a follow-up PR) - SQLite is now the only arm64 pipeline, moving PG back to amd64 which can leverage autoscaler Should resolve #22010 - one thing that wasn't changed here but is mentioned in that issue, unit tests are needed in the same pipeline as an integration test in order to form a complete coverage report (at least as far as I could tell), so for now it remains in a pipeline with a DB integration test. Please let me know if I've inadvertently changed something that was how it was on purpose. --- I will say sometimes it's hard to pin down the average time, as a pipeline could be waiting for a runner for X minutes and that brings the total up by X minutes as well, but overall this does seem to be faster on average. --------- Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  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. GO ?= go
  16. SHASUM ?= shasum -a 256
  17. HAS_GO := $(shell hash $(GO) > /dev/null 2>&1 && echo yes)
  18. COMMA := ,
  19. XGO_VERSION := go-1.20.x
  20. AIR_PACKAGE ?= github.com/cosmtrek/air@v1.44.0
  21. EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.7.0
  22. GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.5.0
  23. GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
  24. GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11
  25. MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/misspell@v0.3.4
  26. SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5
  27. XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
  28. GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1.6.0
  29. GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1.0.0
  30. ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1.6.25
  31. DOCKER_IMAGE ?= gitea/gitea
  32. DOCKER_TAG ?= latest
  33. DOCKER_REF := $(DOCKER_IMAGE):$(DOCKER_TAG)
  34. ifeq ($(HAS_GO), yes)
  35. GOPATH ?= $(shell $(GO) env GOPATH)
  36. export PATH := $(GOPATH)/bin:$(PATH)
  37. CGO_EXTRA_CFLAGS := -DSQLITE_MAX_VARIABLE_NUMBER=32766
  38. CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
  39. endif
  40. ifeq ($(OS), Windows_NT)
  41. GOFLAGS := -v -buildmode=exe
  42. EXECUTABLE ?= gitea.exe
  43. else ifeq ($(OS), Windows)
  44. GOFLAGS := -v -buildmode=exe
  45. EXECUTABLE ?= gitea.exe
  46. else
  47. GOFLAGS := -v
  48. EXECUTABLE ?= gitea
  49. endif
  50. ifeq ($(shell sed --version 2>/dev/null | grep -q GNU && echo gnu),gnu)
  51. SED_INPLACE := sed -i
  52. else
  53. SED_INPLACE := sed -i ''
  54. endif
  55. EXTRA_GOFLAGS ?=
  56. MAKE_VERSION := $(shell "$(MAKE)" -v | cat | head -n 1)
  57. MAKE_EVIDENCE_DIR := .make_evidence
  58. ifeq ($(RACE_ENABLED),true)
  59. GOFLAGS += -race
  60. GOTESTFLAGS += -race
  61. endif
  62. STORED_VERSION_FILE := VERSION
  63. HUGO_VERSION ?= 0.111.3
  64. GITHUB_REF_TYPE ?= branch
  65. GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
  66. ifneq ($(GITHUB_REF_TYPE),branch)
  67. VERSION ?= $(subst v,,$(GITHUB_REF_NAME))
  68. GITEA_VERSION ?= $(VERSION)
  69. else
  70. ifneq ($(GITHUB_REF_NAME),)
  71. VERSION ?= $(subst release/v,,$(GITHUB_REF_NAME))
  72. else
  73. VERSION ?= main
  74. endif
  75. STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null)
  76. ifneq ($(STORED_VERSION),)
  77. GITEA_VERSION ?= $(STORED_VERSION)
  78. else
  79. GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
  80. endif
  81. endif
  82. # if version = "main" then update version to "nightly"
  83. ifeq ($(VERSION),main)
  84. VERSION := main-nightly
  85. endif
  86. LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
  87. LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
  88. GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
  89. GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
  90. FOMANTIC_WORK_DIR := web_src/fomantic
  91. WEBPACK_SOURCES := $(shell find web_src/js web_src/css -type f)
  92. WEBPACK_CONFIGS := webpack.config.js
  93. WEBPACK_DEST := public/assets/js/index.js public/assets/css/index.css
  94. WEBPACK_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts public/assets/img/webpack
  95. BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
  96. BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))
  97. GENERATED_GO_DEST := modules/charset/invisible_gen.go modules/charset/ambiguous_gen.go
  98. SVG_DEST_DIR := public/assets/img/svg
  99. AIR_TMP_DIR := .air
  100. GO_LICENSE_TMP_DIR := .go-licenses
  101. GO_LICENSE_FILE := assets/go-licenses.json
  102. TAGS ?=
  103. TAGS_SPLIT := $(subst $(COMMA), ,$(TAGS))
  104. TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
  105. TEST_TAGS ?= sqlite sqlite_unlock_notify
  106. TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMANTIC_WORK_DIR)/node_modules $(DIST) $(MAKE_EVIDENCE_DIR) $(AIR_TMP_DIR) $(GO_LICENSE_TMP_DIR)
  107. GO_DIRS := build cmd models modules routers services tests
  108. WEB_DIRS := web_src/js web_src/css
  109. GO_SOURCES := $(wildcard *.go)
  110. GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" ! -path modules/options/bindata.go ! -path modules/public/bindata.go ! -path modules/templates/bindata.go)
  111. GO_SOURCES += $(GENERATED_GO_DEST)
  112. GO_SOURCES_NO_BINDATA := $(GO_SOURCES)
  113. ifeq ($(filter $(TAGS_SPLIT),bindata),bindata)
  114. GO_SOURCES += $(BINDATA_DEST)
  115. GENERATED_GO_DEST += $(BINDATA_DEST)
  116. endif
  117. # Force installation of playwright dependencies by setting this flag
  118. ifdef DEPS_PLAYWRIGHT
  119. PLAYWRIGHT_FLAGS += --with-deps
  120. endif
  121. SWAGGER_SPEC := templates/swagger/v1_json.tmpl
  122. SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl \| JSEscape \| Safe}}/api/v1"|g
  123. SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl \| JSEscape \| Safe}}/api/v1"|"basePath": "/api/v1"|g
  124. SWAGGER_EXCLUDE := code.gitea.io/sdk
  125. SWAGGER_NEWLINE_COMMAND := -e '$$a\'
  126. TEST_MYSQL_HOST ?= mysql:3306
  127. TEST_MYSQL_DBNAME ?= testgitea
  128. TEST_MYSQL_USERNAME ?= root
  129. TEST_MYSQL_PASSWORD ?=
  130. TEST_MYSQL8_HOST ?= mysql8:3306
  131. TEST_MYSQL8_DBNAME ?= testgitea
  132. TEST_MYSQL8_USERNAME ?= root
  133. TEST_MYSQL8_PASSWORD ?=
  134. TEST_PGSQL_HOST ?= pgsql:5432
  135. TEST_PGSQL_DBNAME ?= testgitea
  136. TEST_PGSQL_USERNAME ?= postgres
  137. TEST_PGSQL_PASSWORD ?= postgres
  138. TEST_PGSQL_SCHEMA ?= gtestschema
  139. TEST_MSSQL_HOST ?= mssql:1433
  140. TEST_MSSQL_DBNAME ?= gitea
  141. TEST_MSSQL_USERNAME ?= sa
  142. TEST_MSSQL_PASSWORD ?= MwantsaSecurePassword1
  143. .PHONY: all
  144. all: build
  145. .PHONY: help
  146. help:
  147. @echo "Make Routines:"
  148. @echo " - \"\" equivalent to \"build\""
  149. @echo " - build build everything"
  150. @echo " - frontend build frontend files"
  151. @echo " - backend build backend files"
  152. @echo " - watch watch everything and continuously rebuild"
  153. @echo " - watch-frontend watch frontend files and continuously rebuild"
  154. @echo " - watch-backend watch backend files and continuously rebuild"
  155. @echo " - clean delete backend and integration files"
  156. @echo " - clean-all delete backend, frontend and integration files"
  157. @echo " - deps install dependencies"
  158. @echo " - deps-frontend install frontend dependencies"
  159. @echo " - deps-backend install backend dependencies"
  160. @echo " - deps-tools install tool dependencies"
  161. @echo " - deps-py install python dependencies"
  162. @echo " - lint lint everything"
  163. @echo " - lint-fix lint everything and fix issues"
  164. @echo " - lint-actions lint action workflow files"
  165. @echo " - lint-frontend lint frontend files"
  166. @echo " - lint-frontend-fix lint frontend files and fix issues"
  167. @echo " - lint-backend lint backend files"
  168. @echo " - lint-backend-fix lint backend files and fix issues"
  169. @echo " - lint-go lint go files"
  170. @echo " - lint-go-fix lint go files and fix issues"
  171. @echo " - lint-go-vet lint go files with vet"
  172. @echo " - lint-js lint js files"
  173. @echo " - lint-js-fix lint js files and fix issues"
  174. @echo " - lint-css lint css files"
  175. @echo " - lint-css-fix lint css files and fix issues"
  176. @echo " - lint-md lint markdown files"
  177. @echo " - lint-swagger lint swagger files"
  178. @echo " - lint-templates lint template files"
  179. @echo " - checks run various consistency checks"
  180. @echo " - checks-frontend check frontend files"
  181. @echo " - checks-backend check backend files"
  182. @echo " - test test everything"
  183. @echo " - test-frontend test frontend files"
  184. @echo " - test-backend test backend files"
  185. @echo " - test-e2e[\#TestSpecificName] test end to end using playwright"
  186. @echo " - update-js update js dependencies"
  187. @echo " - update-py update py dependencies"
  188. @echo " - webpack build webpack files"
  189. @echo " - svg build svg files"
  190. @echo " - fomantic build fomantic files"
  191. @echo " - generate run \"go generate\""
  192. @echo " - fmt format the Go code"
  193. @echo " - generate-license update license files"
  194. @echo " - generate-gitignore update gitignore files"
  195. @echo " - generate-manpage generate manpage"
  196. @echo " - generate-swagger generate the swagger spec from code comments"
  197. @echo " - swagger-validate check if the swagger spec is valid"
  198. @echo " - go-licenses regenerate go licenses"
  199. @echo " - tidy run go mod tidy"
  200. @echo " - test[\#TestSpecificName] run unit test"
  201. @echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite"
  202. .PHONY: go-check
  203. go-check:
  204. $(eval MIN_GO_VERSION_STR := $(shell grep -Eo '^go\s+[0-9]+\.[0-9]+' go.mod | cut -d' ' -f2))
  205. $(eval MIN_GO_VERSION := $(shell printf "%03d%03d" $(shell echo '$(MIN_GO_VERSION_STR)' | tr '.' ' ')))
  206. $(eval GO_VERSION := $(shell printf "%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9]+' | tr '.' ' ');))
  207. @if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \
  208. echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://go.dev/dl/"; \
  209. exit 1; \
  210. fi
  211. .PHONY: git-check
  212. git-check:
  213. @if git lfs >/dev/null 2>&1 ; then : ; else \
  214. echo "Gitea requires git with lfs support to run tests." ; \
  215. exit 1; \
  216. fi
  217. .PHONY: node-check
  218. node-check:
  219. $(eval MIN_NODE_VERSION_STR := $(shell grep -Eo '"node":.*[0-9.]+"' package.json | sed -n 's/.*[^0-9.]\([0-9.]*\)"/\1/p'))
  220. $(eval MIN_NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_NODE_VERSION_STR)' | tr '.' ' ')))
  221. $(eval NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell node -v | cut -c2- | tr '.' ' ');))
  222. $(eval NPM_MISSING := $(shell hash npm > /dev/null 2>&1 || echo 1))
  223. @if [ "$(NODE_VERSION)" -lt "$(MIN_NODE_VERSION)" -o "$(NPM_MISSING)" = "1" ]; then \
  224. echo "Gitea requires Node.js $(MIN_NODE_VERSION_STR) or greater and npm to build. You can get it at https://nodejs.org/en/download/"; \
  225. exit 1; \
  226. fi
  227. .PHONY: clean-all
  228. clean-all: clean
  229. rm -rf $(WEBPACK_DEST_ENTRIES) node_modules
  230. .PHONY: clean
  231. clean:
  232. $(GO) clean -i ./...
  233. rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST) $(BINDATA_HASH) \
  234. integrations*.test \
  235. e2e*.test \
  236. tests/integration/gitea-integration-pgsql/ tests/integration/gitea-integration-mysql/ tests/integration/gitea-integration-mysql8/ tests/integration/gitea-integration-sqlite/ \
  237. tests/integration/gitea-integration-mssql/ tests/integration/indexers-mysql/ tests/integration/indexers-mysql8/ tests/integration/indexers-pgsql tests/integration/indexers-sqlite \
  238. tests/integration/indexers-mssql tests/mysql.ini tests/mysql8.ini tests/pgsql.ini tests/mssql.ini man/ \
  239. tests/e2e/gitea-e2e-pgsql/ tests/e2e/gitea-e2e-mysql/ tests/e2e/gitea-e2e-mysql8/ tests/e2e/gitea-e2e-sqlite/ \
  240. tests/e2e/gitea-e2e-mssql/ tests/e2e/indexers-mysql/ tests/e2e/indexers-mysql8/ tests/e2e/indexers-pgsql/ tests/e2e/indexers-sqlite/ \
  241. tests/e2e/indexers-mssql/ tests/e2e/reports/ tests/e2e/test-artifacts/ tests/e2e/test-snapshots/
  242. .PHONY: fmt
  243. fmt:
  244. GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}'
  245. $(eval TEMPLATES := $(shell find templates -type f -name '*.tmpl'))
  246. @# strip whitespace after '{{' or '(' and before '}}' or ')' unless there is only
  247. @# whitespace before it
  248. @$(SED_INPLACE) \
  249. -e 's/{{[ ]\{1,\}/{{/g' -e '/^[ ]\{1,\}}}/! s/[ ]\{1,\}}}/}}/g' \
  250. -e 's/([ ]\{1,\}/(/g' -e '/^[ ]\{1,\})/! s/[ ]\{1,\})/)/g' \
  251. $(TEMPLATES)
  252. .PHONY: fmt-check
  253. fmt-check: fmt
  254. @diff=$$(git diff --color=always $(GO_SOURCES) templates $(WEB_DIRS)); \
  255. if [ -n "$$diff" ]; then \
  256. echo "Please run 'make fmt' and commit the result:"; \
  257. echo "$${diff}"; \
  258. exit 1; \
  259. fi
  260. .PHONY: misspell-check
  261. misspell-check:
  262. go run $(MISSPELL_PACKAGE) -error $(GO_DIRS) $(WEB_DIRS)
  263. .PHONY: $(TAGS_EVIDENCE)
  264. $(TAGS_EVIDENCE):
  265. @mkdir -p $(MAKE_EVIDENCE_DIR)
  266. @echo "$(TAGS)" > $(TAGS_EVIDENCE)
  267. ifneq "$(TAGS)" "$(shell cat $(TAGS_EVIDENCE) 2>/dev/null)"
  268. TAGS_PREREQ := $(TAGS_EVIDENCE)
  269. endif
  270. .PHONY: generate-swagger
  271. generate-swagger: $(SWAGGER_SPEC)
  272. $(SWAGGER_SPEC): $(GO_SOURCES_NO_BINDATA)
  273. $(GO) run $(SWAGGER_PACKAGE) generate spec -x "$(SWAGGER_EXCLUDE)" -o './$(SWAGGER_SPEC)'
  274. $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
  275. $(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)'
  276. .PHONY: swagger-check
  277. swagger-check: generate-swagger
  278. @diff=$$(git diff --color=always '$(SWAGGER_SPEC)'); \
  279. if [ -n "$$diff" ]; then \
  280. echo "Please run 'make generate-swagger' and commit the result:"; \
  281. echo "$${diff}"; \
  282. exit 1; \
  283. fi
  284. .PHONY: swagger-validate
  285. swagger-validate:
  286. $(SED_INPLACE) '$(SWAGGER_SPEC_S_JSON)' './$(SWAGGER_SPEC)'
  287. $(GO) run $(SWAGGER_PACKAGE) validate './$(SWAGGER_SPEC)'
  288. $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
  289. .PHONY: checks
  290. checks: checks-frontend checks-backend
  291. .PHONY: checks-frontend
  292. checks-frontend: lockfile-check svg-check
  293. .PHONY: checks-backend
  294. checks-backend: tidy-check swagger-check fmt-check misspell-check swagger-validate security-check
  295. .PHONY: lint
  296. lint: lint-frontend lint-backend
  297. .PHONY: lint-fix
  298. lint-fix: lint-frontend-fix lint-backend-fix
  299. .PHONY: lint-frontend
  300. lint-frontend: lint-js lint-css
  301. .PHONY: lint-frontend-fix
  302. lint-frontend-fix: lint-js-fix lint-css-fix
  303. .PHONY: lint-backend
  304. lint-backend: lint-go lint-go-vet lint-editorconfig
  305. .PHONY: lint-backend-fix
  306. lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig
  307. .PHONY: lint-js
  308. lint-js: node_modules
  309. npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js tests/e2e
  310. .PHONY: lint-js-fix
  311. lint-js-fix: node_modules
  312. npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js tests/e2e --fix
  313. .PHONY: lint-css
  314. lint-css: node_modules
  315. npx stylelint --color --max-warnings=0 web_src/css web_src/js/components/*.vue
  316. .PHONY: lint-css-fix
  317. lint-css-fix: node_modules
  318. npx stylelint --color --max-warnings=0 web_src/css web_src/js/components/*.vue --fix
  319. .PHONY: lint-swagger
  320. lint-swagger: node_modules
  321. npx spectral lint -q -F hint $(SWAGGER_SPEC)
  322. .PHONY: lint-md
  323. lint-md: node_modules
  324. npx markdownlint docs *.md
  325. .PHONY: lint-go
  326. lint-go:
  327. $(GO) run $(GOLANGCI_LINT_PACKAGE) run
  328. .PHONY: lint-go-fix
  329. lint-go-fix:
  330. $(GO) run $(GOLANGCI_LINT_PACKAGE) run --fix
  331. # workaround step for the lint-go-windows CI task because 'go run' can not
  332. # have distinct GOOS/GOARCH for its build and run steps
  333. .PHONY: lint-go-windows
  334. lint-go-windows:
  335. @GOOS= GOARCH= $(GO) install $(GOLANGCI_LINT_PACKAGE)
  336. golangci-lint run
  337. .PHONY: lint-go-vet
  338. lint-go-vet:
  339. @echo "Running go vet..."
  340. @GOOS= GOARCH= $(GO) build code.gitea.io/gitea-vet
  341. @$(GO) vet -vettool=gitea-vet $(GO_PACKAGES)
  342. .PHONY: lint-editorconfig
  343. lint-editorconfig:
  344. $(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) templates .github/workflows
  345. .PHONY: lint-actions
  346. lint-actions:
  347. $(GO) run $(ACTIONLINT_PACKAGE)
  348. .PHONY: lint-templates
  349. lint-templates: .venv
  350. @poetry run djlint $(shell find templates -type f -iname '*.tmpl')
  351. .PHONY: watch
  352. watch:
  353. @bash build/watch.sh
  354. .PHONY: watch-frontend
  355. watch-frontend: node-check node_modules
  356. @rm -rf $(WEBPACK_DEST_ENTRIES)
  357. NODE_ENV=development npx webpack --watch --progress
  358. .PHONY: watch-backend
  359. watch-backend: go-check
  360. GITEA_RUN_MODE=dev $(GO) run $(AIR_PACKAGE) -c .air.toml
  361. .PHONY: test
  362. test: test-frontend test-backend
  363. .PHONY: test-backend
  364. test-backend:
  365. @echo "Running go test with $(GOTESTFLAGS) -tags '$(TEST_TAGS)'..."
  366. @$(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' $(GO_TEST_PACKAGES)
  367. .PHONY: test-frontend
  368. test-frontend: node_modules
  369. npx vitest
  370. .PHONY: test-check
  371. test-check:
  372. @echo "Running test-check...";
  373. @diff=$$(git status -s); \
  374. if [ -n "$$diff" ]; then \
  375. echo "make test-backend has changed files in the source tree:"; \
  376. echo "$${diff}"; \
  377. echo "You should change the tests to create these files in a temporary directory."; \
  378. echo "Do not simply add these files to .gitignore"; \
  379. exit 1; \
  380. fi
  381. .PHONY: test\#%
  382. test\#%:
  383. @echo "Running go test with -tags '$(TEST_TAGS)'..."
  384. @$(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -run $(subst .,/,$*) $(GO_TEST_PACKAGES)
  385. .PHONY: coverage
  386. coverage:
  387. grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' coverage.out > coverage-bodged.out
  388. grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' integration.coverage.out > integration.coverage-bodged.out
  389. $(GO) run build/gocovmerge.go integration.coverage-bodged.out coverage-bodged.out > coverage.all
  390. .PHONY: unit-test-coverage
  391. unit-test-coverage:
  392. @echo "Running unit-test-coverage $(GOTESTFLAGS) -tags '$(TEST_TAGS)'..."
  393. @$(GO) test $(GOTESTFLAGS) -timeout=20m -tags='$(TEST_TAGS)' -cover -coverprofile coverage.out $(GO_TEST_PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
  394. .PHONY: tidy
  395. tidy:
  396. $(eval MIN_GO_VERSION := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2))
  397. $(GO) mod tidy -compat=$(MIN_GO_VERSION)
  398. @$(MAKE) --no-print-directory $(GO_LICENSE_FILE)
  399. vendor: go.mod go.sum
  400. $(GO) mod vendor
  401. @touch vendor
  402. .PHONY: tidy-check
  403. tidy-check: tidy
  404. @diff=$$(git diff --color=always go.mod go.sum $(GO_LICENSE_FILE)); \
  405. if [ -n "$$diff" ]; then \
  406. echo "Please run 'make tidy' and commit the result:"; \
  407. echo "$${diff}"; \
  408. exit 1; \
  409. fi
  410. .PHONY: go-licenses
  411. go-licenses: $(GO_LICENSE_FILE)
  412. $(GO_LICENSE_FILE): go.mod go.sum
  413. -$(GO) run $(GO_LICENSES_PACKAGE) save . --force --save_path=$(GO_LICENSE_TMP_DIR) 2>/dev/null
  414. $(GO) run build/generate-go-licenses.go $(GO_LICENSE_TMP_DIR) $(GO_LICENSE_FILE)
  415. @rm -rf $(GO_LICENSE_TMP_DIR)
  416. generate-ini-sqlite:
  417. sed -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
  418. -e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
  419. -e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \
  420. tests/sqlite.ini.tmpl > tests/sqlite.ini
  421. .PHONY: test-sqlite
  422. test-sqlite: integrations.sqlite.test generate-ini-sqlite
  423. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test
  424. .PHONY: test-sqlite\#%
  425. test-sqlite\#%: integrations.sqlite.test generate-ini-sqlite
  426. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test -test.run $(subst .,/,$*)
  427. .PHONY: test-sqlite-migration
  428. test-sqlite-migration: migrations.sqlite.test migrations.individual.sqlite.test
  429. generate-ini-mysql:
  430. sed -e 's|{{TEST_MYSQL_HOST}}|${TEST_MYSQL_HOST}|g' \
  431. -e 's|{{TEST_MYSQL_DBNAME}}|${TEST_MYSQL_DBNAME}|g' \
  432. -e 's|{{TEST_MYSQL_USERNAME}}|${TEST_MYSQL_USERNAME}|g' \
  433. -e 's|{{TEST_MYSQL_PASSWORD}}|${TEST_MYSQL_PASSWORD}|g' \
  434. -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
  435. -e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
  436. -e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \
  437. tests/mysql.ini.tmpl > tests/mysql.ini
  438. .PHONY: test-mysql
  439. test-mysql: integrations.mysql.test generate-ini-mysql
  440. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test
  441. .PHONY: test-mysql\#%
  442. test-mysql\#%: integrations.mysql.test generate-ini-mysql
  443. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test -test.run $(subst .,/,$*)
  444. .PHONY: test-mysql-migration
  445. test-mysql-migration: migrations.mysql.test migrations.individual.mysql.test
  446. generate-ini-mysql8:
  447. sed -e 's|{{TEST_MYSQL8_HOST}}|${TEST_MYSQL8_HOST}|g' \
  448. -e 's|{{TEST_MYSQL8_DBNAME}}|${TEST_MYSQL8_DBNAME}|g' \
  449. -e 's|{{TEST_MYSQL8_USERNAME}}|${TEST_MYSQL8_USERNAME}|g' \
  450. -e 's|{{TEST_MYSQL8_PASSWORD}}|${TEST_MYSQL8_PASSWORD}|g' \
  451. -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
  452. -e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
  453. -e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \
  454. tests/mysql8.ini.tmpl > tests/mysql8.ini
  455. .PHONY: test-mysql8
  456. test-mysql8: integrations.mysql8.test generate-ini-mysql8
  457. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql8.ini ./integrations.mysql8.test
  458. .PHONY: test-mysql8\#%
  459. test-mysql8\#%: integrations.mysql8.test generate-ini-mysql8
  460. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql8.ini ./integrations.mysql8.test -test.run $(subst .,/,$*)
  461. .PHONY: test-mysql8-migration
  462. test-mysql8-migration: migrations.mysql8.test migrations.individual.mysql8.test
  463. generate-ini-pgsql:
  464. sed -e 's|{{TEST_PGSQL_HOST}}|${TEST_PGSQL_HOST}|g' \
  465. -e 's|{{TEST_PGSQL_DBNAME}}|${TEST_PGSQL_DBNAME}|g' \
  466. -e 's|{{TEST_PGSQL_USERNAME}}|${TEST_PGSQL_USERNAME}|g' \
  467. -e 's|{{TEST_PGSQL_PASSWORD}}|${TEST_PGSQL_PASSWORD}|g' \
  468. -e 's|{{TEST_PGSQL_SCHEMA}}|${TEST_PGSQL_SCHEMA}|g' \
  469. -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
  470. -e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
  471. -e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \
  472. tests/pgsql.ini.tmpl > tests/pgsql.ini
  473. .PHONY: test-pgsql
  474. test-pgsql: integrations.pgsql.test generate-ini-pgsql
  475. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test
  476. .PHONY: test-pgsql\#%
  477. test-pgsql\#%: integrations.pgsql.test generate-ini-pgsql
  478. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test -test.run $(subst .,/,$*)
  479. .PHONY: test-pgsql-migration
  480. test-pgsql-migration: migrations.pgsql.test migrations.individual.pgsql.test
  481. generate-ini-mssql:
  482. sed -e 's|{{TEST_MSSQL_HOST}}|${TEST_MSSQL_HOST}|g' \
  483. -e 's|{{TEST_MSSQL_DBNAME}}|${TEST_MSSQL_DBNAME}|g' \
  484. -e 's|{{TEST_MSSQL_USERNAME}}|${TEST_MSSQL_USERNAME}|g' \
  485. -e 's|{{TEST_MSSQL_PASSWORD}}|${TEST_MSSQL_PASSWORD}|g' \
  486. -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
  487. -e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
  488. -e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \
  489. tests/mssql.ini.tmpl > tests/mssql.ini
  490. .PHONY: test-mssql
  491. test-mssql: integrations.mssql.test generate-ini-mssql
  492. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test
  493. .PHONY: test-mssql\#%
  494. test-mssql\#%: integrations.mssql.test generate-ini-mssql
  495. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test -test.run $(subst .,/,$*)
  496. .PHONY: test-mssql-migration
  497. test-mssql-migration: migrations.mssql.test migrations.individual.mssql.test
  498. .PHONY: playwright
  499. playwright: $(PLAYWRIGHT_DIR)
  500. npm install --no-save @playwright/test
  501. npx playwright install $(PLAYWRIGHT_FLAGS)
  502. .PHONY: test-e2e%
  503. test-e2e%: TEST_TYPE ?= e2e
  504. # Clear display env variable. Otherwise, chromium tests can fail.
  505. DISPLAY=
  506. .PHONY: test-e2e
  507. test-e2e: test-e2e-sqlite
  508. .PHONY: test-e2e-sqlite
  509. test-e2e-sqlite: playwright e2e.sqlite.test generate-ini-sqlite
  510. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./e2e.sqlite.test
  511. .PHONY: test-e2e-sqlite\#%
  512. test-e2e-sqlite\#%: playwright e2e.sqlite.test generate-ini-sqlite
  513. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./e2e.sqlite.test -test.run TestE2e/$*
  514. .PHONY: test-e2e-mysql
  515. test-e2e-mysql: playwright e2e.mysql.test generate-ini-mysql
  516. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./e2e.mysql.test
  517. .PHONY: test-e2e-mysql\#%
  518. test-e2e-mysql\#%: playwright e2e.mysql.test generate-ini-mysql
  519. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./e2e.mysql.test -test.run TestE2e/$*
  520. .PHONY: test-e2e-mysql8
  521. test-e2e-mysql8: playwright e2e.mysql8.test generate-ini-mysql8
  522. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql8.ini ./e2e.mysql8.test
  523. .PHONY: test-e2e-mysql8\#%
  524. test-e2e-mysql8\#%: playwright e2e.mysql8.test generate-ini-mysql8
  525. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql8.ini ./e2e.mysql8.test -test.run TestE2e/$*
  526. .PHONY: test-e2e-pgsql
  527. test-e2e-pgsql: playwright e2e.pgsql.test generate-ini-pgsql
  528. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./e2e.pgsql.test
  529. .PHONY: test-e2e-pgsql\#%
  530. test-e2e-pgsql\#%: playwright e2e.pgsql.test generate-ini-pgsql
  531. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./e2e.pgsql.test -test.run TestE2e/$*
  532. .PHONY: test-e2e-mssql
  533. test-e2e-mssql: playwright e2e.mssql.test generate-ini-mssql
  534. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test
  535. .PHONY: test-e2e-mssql\#%
  536. test-e2e-mssql\#%: playwright e2e.mssql.test generate-ini-mssql
  537. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test -test.run TestE2e/$*
  538. .PHONY: bench-sqlite
  539. bench-sqlite: integrations.sqlite.test generate-ini-sqlite
  540. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  541. .PHONY: bench-mysql
  542. bench-mysql: integrations.mysql.test generate-ini-mysql
  543. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  544. .PHONY: bench-mssql
  545. bench-mssql: integrations.mssql.test generate-ini-mssql
  546. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  547. .PHONY: bench-pgsql
  548. bench-pgsql: integrations.pgsql.test generate-ini-pgsql
  549. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  550. .PHONY: integration-test-coverage
  551. integration-test-coverage: integrations.cover.test generate-ini-mysql
  552. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
  553. .PHONY: integration-test-coverage-sqlite
  554. integration-test-coverage-sqlite: integrations.cover.sqlite.test generate-ini-sqlite
  555. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.cover.sqlite.test -test.coverprofile=integration.coverage.out
  556. integrations.mysql.test: git-check $(GO_SOURCES)
  557. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.mysql.test
  558. integrations.mysql8.test: git-check $(GO_SOURCES)
  559. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.mysql8.test
  560. integrations.pgsql.test: git-check $(GO_SOURCES)
  561. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.pgsql.test
  562. integrations.mssql.test: git-check $(GO_SOURCES)
  563. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.mssql.test
  564. integrations.sqlite.test: git-check $(GO_SOURCES)
  565. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.sqlite.test -tags '$(TEST_TAGS)'
  566. integrations.cover.test: git-check $(GO_SOURCES)
  567. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -coverpkg $(shell echo $(GO_TEST_PACKAGES) | tr ' ' ',') -o integrations.cover.test
  568. integrations.cover.sqlite.test: git-check $(GO_SOURCES)
  569. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -coverpkg $(shell echo $(GO_TEST_PACKAGES) | tr ' ' ',') -o integrations.cover.sqlite.test -tags '$(TEST_TAGS)'
  570. .PHONY: migrations.mysql.test
  571. migrations.mysql.test: $(GO_SOURCES) generate-ini-mysql
  572. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.mysql.test
  573. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./migrations.mysql.test
  574. .PHONY: migrations.mysql8.test
  575. migrations.mysql8.test: $(GO_SOURCES) generate-ini-mysql8
  576. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.mysql8.test
  577. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql8.ini ./migrations.mysql8.test
  578. .PHONY: migrations.pgsql.test
  579. migrations.pgsql.test: $(GO_SOURCES) generate-ini-pgsql
  580. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.pgsql.test
  581. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./migrations.pgsql.test
  582. .PHONY: migrations.mssql.test
  583. migrations.mssql.test: $(GO_SOURCES) generate-ini-mssql
  584. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.mssql.test
  585. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./migrations.mssql.test
  586. .PHONY: migrations.sqlite.test
  587. migrations.sqlite.test: $(GO_SOURCES) generate-ini-sqlite
  588. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.sqlite.test -tags '$(TEST_TAGS)'
  589. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./migrations.sqlite.test
  590. .PHONY: migrations.individual.mysql.test
  591. migrations.individual.mysql.test: $(GO_SOURCES)
  592. for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
  593. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \
  594. done
  595. .PHONY: migrations.individual.mysql8.test
  596. migrations.individual.mysql8.test: $(GO_SOURCES)
  597. for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
  598. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql8.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \
  599. done
  600. .PHONY: migrations.individual.mysql8.test\#%
  601. migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite
  602. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
  603. .PHONY: migrations.individual.pgsql.test
  604. migrations.individual.pgsql.test: $(GO_SOURCES)
  605. for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
  606. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \
  607. done
  608. .PHONY: migrations.individual.pgsql.test\#%
  609. migrations.individual.pgsql.test\#%: $(GO_SOURCES) generate-ini-pgsql
  610. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
  611. .PHONY: migrations.individual.mssql.test
  612. migrations.individual.mssql.test: $(GO_SOURCES) generate-ini-mssql
  613. for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
  614. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg -test.failfast; \
  615. done
  616. .PHONY: migrations.individual.mssql.test\#%
  617. migrations.individual.mssql.test\#%: $(GO_SOURCES) generate-ini-mssql
  618. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
  619. .PHONY: migrations.individual.sqlite.test
  620. migrations.individual.sqlite.test: $(GO_SOURCES) generate-ini-sqlite
  621. for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
  622. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \
  623. done
  624. .PHONY: migrations.individual.sqlite.test\#%
  625. migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite
  626. GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
  627. e2e.mysql.test: $(GO_SOURCES)
  628. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mysql.test
  629. e2e.mysql8.test: $(GO_SOURCES)
  630. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mysql8.test
  631. e2e.pgsql.test: $(GO_SOURCES)
  632. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.pgsql.test
  633. e2e.mssql.test: $(GO_SOURCES)
  634. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mssql.test
  635. e2e.sqlite.test: $(GO_SOURCES)
  636. $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.sqlite.test -tags '$(TEST_TAGS)'
  637. .PHONY: check
  638. check: test
  639. .PHONY: install $(TAGS_PREREQ)
  640. install: $(wildcard *.go)
  641. CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
  642. .PHONY: build
  643. build: frontend backend
  644. .PHONY: frontend
  645. frontend: $(WEBPACK_DEST)
  646. .PHONY: backend
  647. backend: go-check generate-backend $(EXECUTABLE)
  648. # We generate the backend before the frontend in case we in future we want to generate things in the frontend from generated files in backend
  649. .PHONY: generate
  650. generate: generate-backend
  651. .PHONY: generate-backend
  652. generate-backend: $(TAGS_PREREQ) generate-go
  653. .PHONY: generate-go
  654. generate-go: $(TAGS_PREREQ)
  655. @echo "Running go generate..."
  656. @CC= GOOS= GOARCH= $(GO) generate -tags '$(TAGS)' $(GO_PACKAGES)
  657. .PHONY: security-check
  658. security-check:
  659. go run $(GOVULNCHECK_PACKAGE) ./...
  660. $(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
  661. CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
  662. .PHONY: release
  663. release: frontend generate release-windows release-linux release-darwin release-freebsd release-copy release-compress vendor release-sources release-docs release-check
  664. $(DIST_DIRS):
  665. mkdir -p $(DIST_DIRS)
  666. .PHONY: release-windows
  667. release-windows: | $(DIST_DIRS)
  668. CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
  669. ifeq (,$(findstring gogit,$(TAGS)))
  670. CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'osusergo gogit $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION)-gogit .
  671. endif
  672. .PHONY: release-linux
  673. release-linux: | $(DIST_DIRS)
  674. CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(LINUX_ARCHS)' -out gitea-$(VERSION) .
  675. .PHONY: release-darwin
  676. release-darwin: | $(DIST_DIRS)
  677. CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin-10.12/amd64,darwin-10.12/arm64' -out gitea-$(VERSION) .
  678. .PHONY: release-freebsd
  679. release-freebsd: | $(DIST_DIRS)
  680. CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'freebsd/amd64' -out gitea-$(VERSION) .
  681. .PHONY: release-copy
  682. release-copy: | $(DIST_DIRS)
  683. cd $(DIST); for file in `find . -type f -name "*"`; do cp $${file} ./release/; done;
  684. .PHONY: release-check
  685. release-check: | $(DIST_DIRS)
  686. cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done;
  687. .PHONY: release-compress
  688. release-compress: | $(DIST_DIRS)
  689. cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && $(GO) run $(GXZ_PACKAGE) -k -9 $${file}; done;
  690. .PHONY: release-sources
  691. release-sources: | $(DIST_DIRS)
  692. echo $(VERSION) > $(STORED_VERSION_FILE)
  693. # bsdtar needs a ^ to prevent matching subdirectories
  694. $(eval EXCL := --exclude=$(shell tar --help | grep -q bsdtar && echo "^")./)
  695. # use transform to a add a release-folder prefix; in bsdtar the transform parameter equivalent is -s
  696. $(eval TRANSFORM := $(shell tar --help | grep -q bsdtar && echo "-s '/^./gitea-src-$(VERSION)/'" || echo "--transform 's|^./|gitea-src-$(VERSION)/|'"))
  697. tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) $(TRANSFORM) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
  698. rm -f $(STORED_VERSION_FILE)
  699. .PHONY: release-docs
  700. release-docs: | $(DIST_DIRS) docs
  701. tar -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs .
  702. .PHONY: docs
  703. docs:
  704. cd docs; bash scripts/trans-copy.sh;
  705. .PHONY: deps
  706. deps: deps-frontend deps-backend deps-tools deps-py
  707. .PHONY: deps-py
  708. deps-py: .venv
  709. .PHONY: deps-frontend
  710. deps-frontend: node_modules
  711. .PHONY: deps-backend
  712. deps-backend:
  713. $(GO) mod download
  714. .PHONY: deps-tools
  715. deps-tools:
  716. $(GO) install $(AIR_PACKAGE)
  717. $(GO) install $(EDITORCONFIG_CHECKER_PACKAGE)
  718. $(GO) install $(GOFUMPT_PACKAGE)
  719. $(GO) install $(GOLANGCI_LINT_PACKAGE)
  720. $(GO) install $(GXZ_PACKAGE)
  721. $(GO) install $(MISSPELL_PACKAGE)
  722. $(GO) install $(SWAGGER_PACKAGE)
  723. $(GO) install $(XGO_PACKAGE)
  724. $(GO) install $(GO_LICENSES_PACKAGE)
  725. $(GO) install $(GOVULNCHECK_PACKAGE)
  726. $(GO) install $(ACTIONLINT_PACKAGE)
  727. node_modules: package-lock.json
  728. npm install --no-save
  729. @touch node_modules
  730. .venv: poetry.lock
  731. poetry install
  732. @touch .venv
  733. .PHONY: update-js
  734. update-js: node-check | node_modules
  735. npx updates -u -f package.json
  736. rm -rf node_modules package-lock.json
  737. npm install --package-lock
  738. @touch node_modules
  739. .PHONY: update-py
  740. update-py: node-check | node_modules
  741. npx updates -u -f pyproject.toml
  742. rm -rf .venv poetry.lock
  743. poetry install
  744. @touch .venv
  745. .PHONY: fomantic
  746. fomantic:
  747. rm -rf $(FOMANTIC_WORK_DIR)/build
  748. cd $(FOMANTIC_WORK_DIR) && npm install --no-save
  749. cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config
  750. cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/
  751. cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build
  752. # fomantic uses "touchstart" as click event for some browsers, it's not ideal, so we force fomantic to always use "click" as click event
  753. $(SED_INPLACE) -e 's/clickEvent[ \t]*=/clickEvent = "click", unstableClickEvent =/g' $(FOMANTIC_WORK_DIR)/build/semantic.js
  754. $(SED_INPLACE) -e 's/\r//g' $(FOMANTIC_WORK_DIR)/build/semantic.css $(FOMANTIC_WORK_DIR)/build/semantic.js
  755. rm -f $(FOMANTIC_WORK_DIR)/build/*.min.*
  756. .PHONY: webpack
  757. webpack: $(WEBPACK_DEST)
  758. $(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json
  759. @$(MAKE) -s node-check node_modules
  760. rm -rf $(WEBPACK_DEST_ENTRIES)
  761. npx webpack
  762. @touch $(WEBPACK_DEST)
  763. .PHONY: svg
  764. svg: node-check | node_modules
  765. rm -rf $(SVG_DEST_DIR)
  766. node build/generate-svg.js
  767. .PHONY: svg-check
  768. svg-check: svg
  769. @git add $(SVG_DEST_DIR)
  770. @diff=$$(git diff --color=always --cached $(SVG_DEST_DIR)); \
  771. if [ -n "$$diff" ]; then \
  772. echo "Please run 'make svg' and 'git add $(SVG_DEST_DIR)' and commit the result:"; \
  773. echo "$${diff}"; \
  774. exit 1; \
  775. fi
  776. .PHONY: lockfile-check
  777. lockfile-check:
  778. npm install --package-lock-only
  779. @diff=$$(git diff --color=always package-lock.json); \
  780. if [ -n "$$diff" ]; then \
  781. echo "package-lock.json is inconsistent with package.json"; \
  782. echo "Please run 'npm install --package-lock-only' and commit the result:"; \
  783. echo "$${diff}"; \
  784. exit 1; \
  785. fi
  786. .PHONY: update-translations
  787. update-translations:
  788. mkdir -p ./translations
  789. cd ./translations && curl -L https://crowdin.com/download/project/gitea.zip > gitea.zip && unzip gitea.zip
  790. rm ./translations/gitea.zip
  791. $(SED_INPLACE) -e 's/="/=/g' -e 's/"$$//g' ./translations/*.ini
  792. $(SED_INPLACE) -e 's/\\"/"/g' ./translations/*.ini
  793. mv ./translations/*.ini ./options/locale/
  794. rmdir ./translations
  795. .PHONY: generate-license
  796. generate-license:
  797. $(GO) run build/generate-licenses.go
  798. .PHONY: generate-gitignore
  799. generate-gitignore:
  800. $(GO) run build/generate-gitignores.go
  801. .PHONY: generate-images
  802. generate-images: | node_modules
  803. npm install --no-save --no-package-lock fabric@5 imagemin-zopfli@7
  804. node build/generate-images.js $(TAGS)
  805. .PHONY: generate-manpage
  806. generate-manpage:
  807. @[ -f gitea ] || make backend
  808. @mkdir -p man/man1/ man/man5
  809. @./gitea docs --man > man/man1/gitea.1
  810. @gzip -9 man/man1/gitea.1 && echo man/man1/gitea.1.gz created
  811. @#TODO A small script that formats config-cheat-sheet.en-us.md nicely for use as a config man page
  812. .PHONY: docker
  813. docker:
  814. docker build --disable-content-trust=false -t $(DOCKER_REF) .
  815. # support also build args docker build --build-arg GITEA_VERSION=v1.2.3 --build-arg TAGS="bindata sqlite sqlite_unlock_notify" .
  816. # This endif closes the if at the top of the file
  817. endif