code.gitea.io/gitea@v1.22.3/Makefile (about) 1 ifeq ($(USE_REPO_TEST_DIR),1) 2 3 # This rule replaces the whole Makefile when we're trying to use /tmp repository temporary files 4 location = $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) 5 self := $(location) 6 7 %: 8 @tmpdir=`mktemp --tmpdir -d` ; \ 9 echo Using temporary directory $$tmpdir for test repositories ; \ 10 USE_REPO_TEST_DIR= $(MAKE) -f $(self) --no-print-directory REPO_TEST_DIR=$$tmpdir/ $@ ; \ 11 STATUS=$$? ; rm -r "$$tmpdir" ; exit $$STATUS 12 13 else 14 15 # This is the "normal" part of the Makefile 16 17 DIST := dist 18 DIST_DIRS := $(DIST)/binaries $(DIST)/release 19 IMPORT := code.gitea.io/gitea 20 21 GO ?= go 22 SHASUM ?= shasum -a 256 23 HAS_GO := $(shell hash $(GO) > /dev/null 2>&1 && echo yes) 24 COMMA := , 25 26 XGO_VERSION := go-1.22.x 27 28 AIR_PACKAGE ?= github.com/air-verse/air@v1 29 EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.7.0 30 GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.6.0 31 GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2 32 GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11 33 MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.5.1 34 SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@db51e79a0e37c572d8b59ae0c58bf2bbbbe53285 35 XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest 36 GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1 37 GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1 38 ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1 39 40 DOCKER_IMAGE ?= gitea/gitea 41 DOCKER_TAG ?= latest 42 DOCKER_REF := $(DOCKER_IMAGE):$(DOCKER_TAG) 43 44 ifeq ($(HAS_GO), yes) 45 CGO_EXTRA_CFLAGS := -DSQLITE_MAX_VARIABLE_NUMBER=32766 46 CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS) 47 endif 48 49 ifeq ($(GOOS),windows) 50 IS_WINDOWS := yes 51 else ifeq ($(patsubst Windows%,Windows,$(OS)),Windows) 52 ifeq ($(GOOS),) 53 IS_WINDOWS := yes 54 endif 55 endif 56 ifeq ($(IS_WINDOWS),yes) 57 GOFLAGS := -v -buildmode=exe 58 EXECUTABLE ?= gitea.exe 59 else 60 GOFLAGS := -v 61 EXECUTABLE ?= gitea 62 endif 63 64 ifeq ($(shell sed --version 2>/dev/null | grep -q GNU && echo gnu),gnu) 65 SED_INPLACE := sed -i 66 else 67 SED_INPLACE := sed -i '' 68 endif 69 70 EXTRA_GOFLAGS ?= 71 72 MAKE_VERSION := $(shell "$(MAKE)" -v | cat | head -n 1) 73 MAKE_EVIDENCE_DIR := .make_evidence 74 75 ifeq ($(RACE_ENABLED),true) 76 GOFLAGS += -race 77 GOTESTFLAGS += -race 78 endif 79 80 STORED_VERSION_FILE := VERSION 81 HUGO_VERSION ?= 0.111.3 82 83 GITHUB_REF_TYPE ?= branch 84 GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD) 85 86 ifneq ($(GITHUB_REF_TYPE),branch) 87 VERSION ?= $(subst v,,$(GITHUB_REF_NAME)) 88 GITEA_VERSION ?= $(VERSION) 89 else 90 ifneq ($(GITHUB_REF_NAME),) 91 VERSION ?= $(subst release/v,,$(GITHUB_REF_NAME))-nightly 92 else 93 VERSION ?= main 94 endif 95 96 STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null) 97 ifneq ($(STORED_VERSION),) 98 GITEA_VERSION ?= $(STORED_VERSION) 99 else 100 GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//') 101 endif 102 endif 103 104 # if version = "main" then update version to "nightly" 105 ifeq ($(VERSION),main) 106 VERSION := main-nightly 107 endif 108 109 LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)" 110 111 LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64 112 113 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/)) 114 MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) 115 116 FOMANTIC_WORK_DIR := web_src/fomantic 117 118 WEBPACK_SOURCES := $(shell find web_src/js web_src/css -type f) 119 WEBPACK_CONFIGS := webpack.config.js tailwind.config.js 120 WEBPACK_DEST := public/assets/js/index.js public/assets/css/index.css 121 WEBPACK_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts 122 123 BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go 124 BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST)) 125 126 GENERATED_GO_DEST := modules/charset/invisible_gen.go modules/charset/ambiguous_gen.go 127 128 SVG_DEST_DIR := public/assets/img/svg 129 130 AIR_TMP_DIR := .air 131 132 GO_LICENSE_TMP_DIR := .go-licenses 133 GO_LICENSE_FILE := assets/go-licenses.json 134 135 TAGS ?= 136 TAGS_SPLIT := $(subst $(COMMA), ,$(TAGS)) 137 TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags 138 139 TEST_TAGS ?= $(TAGS_SPLIT) sqlite sqlite_unlock_notify 140 141 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) 142 143 GO_DIRS := build cmd models modules routers services tests 144 WEB_DIRS := web_src/js web_src/css 145 146 ESLINT_FILES := web_src/js tools *.js tests/e2e 147 STYLELINT_FILES := web_src/css web_src/js/components/*.vue 148 SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) docs/content templates options/locale/locale_en-US.ini .github $(filter-out CHANGELOG.md, $(wildcard *.go *.js *.md *.yml *.yaml *.toml)) 149 EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.ini 150 151 GO_SOURCES := $(wildcard *.go) 152 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) 153 GO_SOURCES += $(GENERATED_GO_DEST) 154 GO_SOURCES_NO_BINDATA := $(GO_SOURCES) 155 156 ifeq ($(filter $(TAGS_SPLIT),bindata),bindata) 157 GO_SOURCES += $(BINDATA_DEST) 158 GENERATED_GO_DEST += $(BINDATA_DEST) 159 endif 160 161 # Force installation of playwright dependencies by setting this flag 162 ifdef DEPS_PLAYWRIGHT 163 PLAYWRIGHT_FLAGS += --with-deps 164 endif 165 166 SWAGGER_SPEC := templates/swagger/v1_json.tmpl 167 SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl \| JSEscape}}/api/v1"|g 168 SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl \| JSEscape}}/api/v1"|"basePath": "/api/v1"|g 169 SWAGGER_EXCLUDE := code.gitea.io/sdk 170 SWAGGER_NEWLINE_COMMAND := -e '$$a\' 171 172 TEST_MYSQL_HOST ?= mysql:3306 173 TEST_MYSQL_DBNAME ?= testgitea 174 TEST_MYSQL_USERNAME ?= root 175 TEST_MYSQL_PASSWORD ?= 176 TEST_PGSQL_HOST ?= pgsql:5432 177 TEST_PGSQL_DBNAME ?= testgitea 178 TEST_PGSQL_USERNAME ?= postgres 179 TEST_PGSQL_PASSWORD ?= postgres 180 TEST_PGSQL_SCHEMA ?= gtestschema 181 TEST_MSSQL_HOST ?= mssql:1433 182 TEST_MSSQL_DBNAME ?= gitea 183 TEST_MSSQL_USERNAME ?= sa 184 TEST_MSSQL_PASSWORD ?= MwantsaSecurePassword1 185 186 .PHONY: all 187 all: build 188 189 .PHONY: help 190 help: 191 @echo "Make Routines:" 192 @echo " - \"\" equivalent to \"build\"" 193 @echo " - build build everything" 194 @echo " - frontend build frontend files" 195 @echo " - backend build backend files" 196 @echo " - watch watch everything and continuously rebuild" 197 @echo " - watch-frontend watch frontend files and continuously rebuild" 198 @echo " - watch-backend watch backend files and continuously rebuild" 199 @echo " - clean delete backend and integration files" 200 @echo " - clean-all delete backend, frontend and integration files" 201 @echo " - deps install dependencies" 202 @echo " - deps-frontend install frontend dependencies" 203 @echo " - deps-backend install backend dependencies" 204 @echo " - deps-tools install tool dependencies" 205 @echo " - deps-py install python dependencies" 206 @echo " - lint lint everything" 207 @echo " - lint-fix lint everything and fix issues" 208 @echo " - lint-actions lint action workflow files" 209 @echo " - lint-frontend lint frontend files" 210 @echo " - lint-frontend-fix lint frontend files and fix issues" 211 @echo " - lint-backend lint backend files" 212 @echo " - lint-backend-fix lint backend files and fix issues" 213 @echo " - lint-go lint go files" 214 @echo " - lint-go-fix lint go files and fix issues" 215 @echo " - lint-go-vet lint go files with vet" 216 @echo " - lint-js lint js files" 217 @echo " - lint-js-fix lint js files and fix issues" 218 @echo " - lint-css lint css files" 219 @echo " - lint-css-fix lint css files and fix issues" 220 @echo " - lint-md lint markdown files" 221 @echo " - lint-swagger lint swagger files" 222 @echo " - lint-templates lint template files" 223 @echo " - lint-yaml lint yaml files" 224 @echo " - lint-spell lint spelling" 225 @echo " - lint-spell-fix lint spelling and fix issues" 226 @echo " - checks run various consistency checks" 227 @echo " - checks-frontend check frontend files" 228 @echo " - checks-backend check backend files" 229 @echo " - test test everything" 230 @echo " - test-frontend test frontend files" 231 @echo " - test-backend test backend files" 232 @echo " - test-e2e[\#TestSpecificName] test end to end using playwright" 233 @echo " - update update js and py dependencies" 234 @echo " - update-js update js dependencies" 235 @echo " - update-py update py dependencies" 236 @echo " - webpack build webpack files" 237 @echo " - svg build svg files" 238 @echo " - fomantic build fomantic files" 239 @echo " - generate run \"go generate\"" 240 @echo " - fmt format the Go code" 241 @echo " - generate-license update license files" 242 @echo " - generate-gitignore update gitignore files" 243 @echo " - generate-manpage generate manpage" 244 @echo " - generate-swagger generate the swagger spec from code comments" 245 @echo " - swagger-validate check if the swagger spec is valid" 246 @echo " - go-licenses regenerate go licenses" 247 @echo " - tidy run go mod tidy" 248 @echo " - test[\#TestSpecificName] run unit test" 249 @echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite" 250 251 .PHONY: go-check 252 go-check: 253 $(eval MIN_GO_VERSION_STR := $(shell grep -Eo '^go\s+[0-9]+\.[0-9]+' go.mod | cut -d' ' -f2)) 254 $(eval MIN_GO_VERSION := $(shell printf "%03d%03d" $(shell echo '$(MIN_GO_VERSION_STR)' | tr '.' ' '))) 255 $(eval GO_VERSION := $(shell printf "%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9]+' | tr '.' ' ');)) 256 @if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \ 257 echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://go.dev/dl/"; \ 258 exit 1; \ 259 fi 260 261 .PHONY: git-check 262 git-check: 263 @if git lfs >/dev/null 2>&1 ; then : ; else \ 264 echo "Gitea requires git with lfs support to run tests." ; \ 265 exit 1; \ 266 fi 267 268 .PHONY: node-check 269 node-check: 270 $(eval MIN_NODE_VERSION_STR := $(shell grep -Eo '"node":.*[0-9.]+"' package.json | sed -n 's/.*[^0-9.]\([0-9.]*\)"/\1/p')) 271 $(eval MIN_NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_NODE_VERSION_STR)' | tr '.' ' '))) 272 $(eval NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell node -v | cut -c2- | tr '.' ' ');)) 273 $(eval NPM_MISSING := $(shell hash npm > /dev/null 2>&1 || echo 1)) 274 @if [ "$(NODE_VERSION)" -lt "$(MIN_NODE_VERSION)" -o "$(NPM_MISSING)" = "1" ]; then \ 275 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/"; \ 276 exit 1; \ 277 fi 278 279 .PHONY: clean-all 280 clean-all: clean 281 rm -rf $(WEBPACK_DEST_ENTRIES) node_modules 282 283 .PHONY: clean 284 clean: 285 rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST) $(BINDATA_HASH) \ 286 integrations*.test \ 287 e2e*.test \ 288 tests/integration/gitea-integration-* \ 289 tests/integration/indexers-* \ 290 tests/mysql.ini tests/pgsql.ini tests/mssql.ini man/ \ 291 tests/e2e/gitea-e2e-*/ \ 292 tests/e2e/indexers-*/ \ 293 tests/e2e/reports/ tests/e2e/test-artifacts/ tests/e2e/test-snapshots/ 294 295 .PHONY: fmt 296 fmt: 297 @GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}' 298 $(eval TEMPLATES := $(shell find templates -type f -name '*.tmpl')) 299 @# strip whitespace after '{{' or '(' and before '}}' or ')' unless there is only 300 @# whitespace before it 301 @$(SED_INPLACE) \ 302 -e 's/{{[ ]\{1,\}/{{/g' -e '/^[ ]\{1,\}}}/! s/[ ]\{1,\}}}/}}/g' \ 303 -e 's/([ ]\{1,\}/(/g' -e '/^[ ]\{1,\})/! s/[ ]\{1,\})/)/g' \ 304 $(TEMPLATES) 305 306 .PHONY: fmt-check 307 fmt-check: fmt 308 @diff=$$(git diff --color=always $(GO_SOURCES) templates $(WEB_DIRS)); \ 309 if [ -n "$$diff" ]; then \ 310 echo "Please run 'make fmt' and commit the result:"; \ 311 echo "$${diff}"; \ 312 exit 1; \ 313 fi 314 315 .PHONY: $(TAGS_EVIDENCE) 316 $(TAGS_EVIDENCE): 317 @mkdir -p $(MAKE_EVIDENCE_DIR) 318 @echo "$(TAGS)" > $(TAGS_EVIDENCE) 319 320 ifneq "$(TAGS)" "$(shell cat $(TAGS_EVIDENCE) 2>/dev/null)" 321 TAGS_PREREQ := $(TAGS_EVIDENCE) 322 endif 323 324 .PHONY: generate-swagger 325 generate-swagger: $(SWAGGER_SPEC) 326 327 $(SWAGGER_SPEC): $(GO_SOURCES_NO_BINDATA) 328 $(GO) run $(SWAGGER_PACKAGE) generate spec -x "$(SWAGGER_EXCLUDE)" -o './$(SWAGGER_SPEC)' 329 $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)' 330 $(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)' 331 332 .PHONY: swagger-check 333 swagger-check: generate-swagger 334 @diff=$$(git diff --color=always '$(SWAGGER_SPEC)'); \ 335 if [ -n "$$diff" ]; then \ 336 echo "Please run 'make generate-swagger' and commit the result:"; \ 337 echo "$${diff}"; \ 338 exit 1; \ 339 fi 340 341 .PHONY: swagger-validate 342 swagger-validate: 343 $(SED_INPLACE) '$(SWAGGER_SPEC_S_JSON)' './$(SWAGGER_SPEC)' 344 $(GO) run $(SWAGGER_PACKAGE) validate './$(SWAGGER_SPEC)' 345 $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)' 346 347 .PHONY: checks 348 checks: checks-frontend checks-backend 349 350 .PHONY: checks-frontend 351 checks-frontend: lockfile-check svg-check 352 353 .PHONY: checks-backend 354 checks-backend: tidy-check swagger-check fmt-check swagger-validate security-check 355 356 .PHONY: lint 357 lint: lint-frontend lint-backend lint-spell 358 359 .PHONY: lint-fix 360 lint-fix: lint-frontend-fix lint-backend-fix lint-spell-fix 361 362 .PHONY: lint-frontend 363 lint-frontend: lint-js lint-css 364 365 .PHONY: lint-frontend-fix 366 lint-frontend-fix: lint-js-fix lint-css-fix 367 368 .PHONY: lint-backend 369 lint-backend: lint-go lint-go-vet lint-editorconfig 370 371 .PHONY: lint-backend-fix 372 lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig 373 374 .PHONY: lint-js 375 lint-js: node_modules 376 npx eslint --color --max-warnings=0 --ext js,vue $(ESLINT_FILES) 377 378 .PHONY: lint-js-fix 379 lint-js-fix: node_modules 380 npx eslint --color --max-warnings=0 --ext js,vue $(ESLINT_FILES) --fix 381 382 .PHONY: lint-css 383 lint-css: node_modules 384 npx stylelint --color --max-warnings=0 $(STYLELINT_FILES) 385 386 .PHONY: lint-css-fix 387 lint-css-fix: node_modules 388 npx stylelint --color --max-warnings=0 $(STYLELINT_FILES) --fix 389 390 .PHONY: lint-swagger 391 lint-swagger: node_modules 392 npx spectral lint -q -F hint $(SWAGGER_SPEC) 393 394 .PHONY: lint-md 395 lint-md: node_modules 396 npx markdownlint docs *.md 397 398 .PHONY: lint-spell 399 lint-spell: 400 @go run $(MISSPELL_PACKAGE) -dict tools/misspellings.csv -error $(SPELLCHECK_FILES) 401 402 .PHONY: lint-spell-fix 403 lint-spell-fix: 404 @go run $(MISSPELL_PACKAGE) -dict tools/misspellings.csv -w $(SPELLCHECK_FILES) 405 406 .PHONY: lint-go 407 lint-go: 408 $(GO) run $(GOLANGCI_LINT_PACKAGE) run 409 410 .PHONY: lint-go-fix 411 lint-go-fix: 412 $(GO) run $(GOLANGCI_LINT_PACKAGE) run --fix 413 414 # workaround step for the lint-go-windows CI task because 'go run' can not 415 # have distinct GOOS/GOARCH for its build and run steps 416 .PHONY: lint-go-windows 417 lint-go-windows: 418 @GOOS= GOARCH= $(GO) install $(GOLANGCI_LINT_PACKAGE) 419 golangci-lint run 420 421 .PHONY: lint-go-vet 422 lint-go-vet: 423 @echo "Running go vet..." 424 @GOOS= GOARCH= $(GO) build code.gitea.io/gitea-vet 425 @$(GO) vet -vettool=gitea-vet ./... 426 427 .PHONY: lint-editorconfig 428 lint-editorconfig: 429 @$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) $(EDITORCONFIG_FILES) 430 431 .PHONY: lint-actions 432 lint-actions: 433 $(GO) run $(ACTIONLINT_PACKAGE) 434 435 .PHONY: lint-templates 436 lint-templates: .venv node_modules 437 @node tools/lint-templates-svg.js 438 @poetry run djlint $(shell find templates -type f -iname '*.tmpl') 439 440 .PHONY: lint-yaml 441 lint-yaml: .venv 442 @poetry run yamllint . 443 444 .PHONY: watch 445 watch: 446 @bash tools/watch.sh 447 448 .PHONY: watch-frontend 449 watch-frontend: node-check node_modules 450 @rm -rf $(WEBPACK_DEST_ENTRIES) 451 NODE_ENV=development npx webpack --watch --progress 452 453 .PHONY: watch-backend 454 watch-backend: go-check 455 GITEA_RUN_MODE=dev $(GO) run $(AIR_PACKAGE) -c .air.toml 456 457 .PHONY: test 458 test: test-frontend test-backend 459 460 .PHONY: test-backend 461 test-backend: 462 @echo "Running go test with $(GOTESTFLAGS) -tags '$(TEST_TAGS)'..." 463 @$(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' $(GO_TEST_PACKAGES) 464 465 .PHONY: test-frontend 466 test-frontend: node_modules 467 npx vitest 468 469 .PHONY: test-check 470 test-check: 471 @echo "Running test-check..."; 472 @diff=$$(git status -s); \ 473 if [ -n "$$diff" ]; then \ 474 echo "make test-backend has changed files in the source tree:"; \ 475 echo "$${diff}"; \ 476 echo "You should change the tests to create these files in a temporary directory."; \ 477 echo "Do not simply add these files to .gitignore"; \ 478 exit 1; \ 479 fi 480 481 .PHONY: test\#% 482 test\#%: 483 @echo "Running go test with -tags '$(TEST_TAGS)'..." 484 @$(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -run $(subst .,/,$*) $(GO_TEST_PACKAGES) 485 486 .PHONY: coverage 487 coverage: 488 grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' coverage.out > coverage-bodged.out 489 grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' integration.coverage.out > integration.coverage-bodged.out 490 $(GO) run build/gocovmerge.go integration.coverage-bodged.out coverage-bodged.out > coverage.all 491 492 .PHONY: unit-test-coverage 493 unit-test-coverage: 494 @echo "Running unit-test-coverage $(GOTESTFLAGS) -tags '$(TEST_TAGS)'..." 495 @$(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 496 497 .PHONY: tidy 498 tidy: 499 $(eval MIN_GO_VERSION := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2)) 500 $(GO) mod tidy -compat=$(MIN_GO_VERSION) 501 @$(MAKE) --no-print-directory $(GO_LICENSE_FILE) 502 503 vendor: go.mod go.sum 504 $(GO) mod vendor 505 @touch vendor 506 507 .PHONY: tidy-check 508 tidy-check: tidy 509 @diff=$$(git diff --color=always go.mod go.sum $(GO_LICENSE_FILE)); \ 510 if [ -n "$$diff" ]; then \ 511 echo "Please run 'make tidy' and commit the result:"; \ 512 echo "$${diff}"; \ 513 exit 1; \ 514 fi 515 516 .PHONY: go-licenses 517 go-licenses: $(GO_LICENSE_FILE) 518 519 $(GO_LICENSE_FILE): go.mod go.sum 520 -$(GO) run $(GO_LICENSES_PACKAGE) save . --force --save_path=$(GO_LICENSE_TMP_DIR) 2>/dev/null 521 $(GO) run build/generate-go-licenses.go $(GO_LICENSE_TMP_DIR) $(GO_LICENSE_FILE) 522 @rm -rf $(GO_LICENSE_TMP_DIR) 523 524 generate-ini-sqlite: 525 sed -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \ 526 -e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \ 527 -e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \ 528 tests/sqlite.ini.tmpl > tests/sqlite.ini 529 530 .PHONY: test-sqlite 531 test-sqlite: integrations.sqlite.test generate-ini-sqlite 532 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test 533 534 .PHONY: test-sqlite\#% 535 test-sqlite\#%: integrations.sqlite.test generate-ini-sqlite 536 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test -test.run $(subst .,/,$*) 537 538 .PHONY: test-sqlite-migration 539 test-sqlite-migration: migrations.sqlite.test migrations.individual.sqlite.test 540 541 generate-ini-mysql: 542 sed -e 's|{{TEST_MYSQL_HOST}}|${TEST_MYSQL_HOST}|g' \ 543 -e 's|{{TEST_MYSQL_DBNAME}}|${TEST_MYSQL_DBNAME}|g' \ 544 -e 's|{{TEST_MYSQL_USERNAME}}|${TEST_MYSQL_USERNAME}|g' \ 545 -e 's|{{TEST_MYSQL_PASSWORD}}|${TEST_MYSQL_PASSWORD}|g' \ 546 -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \ 547 -e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \ 548 -e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \ 549 tests/mysql.ini.tmpl > tests/mysql.ini 550 551 .PHONY: test-mysql 552 test-mysql: integrations.mysql.test generate-ini-mysql 553 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test 554 555 .PHONY: test-mysql\#% 556 test-mysql\#%: integrations.mysql.test generate-ini-mysql 557 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test -test.run $(subst .,/,$*) 558 559 .PHONY: test-mysql-migration 560 test-mysql-migration: migrations.mysql.test migrations.individual.mysql.test 561 562 generate-ini-pgsql: 563 sed -e 's|{{TEST_PGSQL_HOST}}|${TEST_PGSQL_HOST}|g' \ 564 -e 's|{{TEST_PGSQL_DBNAME}}|${TEST_PGSQL_DBNAME}|g' \ 565 -e 's|{{TEST_PGSQL_USERNAME}}|${TEST_PGSQL_USERNAME}|g' \ 566 -e 's|{{TEST_PGSQL_PASSWORD}}|${TEST_PGSQL_PASSWORD}|g' \ 567 -e 's|{{TEST_PGSQL_SCHEMA}}|${TEST_PGSQL_SCHEMA}|g' \ 568 -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \ 569 -e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \ 570 -e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \ 571 tests/pgsql.ini.tmpl > tests/pgsql.ini 572 573 .PHONY: test-pgsql 574 test-pgsql: integrations.pgsql.test generate-ini-pgsql 575 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test 576 577 .PHONY: test-pgsql\#% 578 test-pgsql\#%: integrations.pgsql.test generate-ini-pgsql 579 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test -test.run $(subst .,/,$*) 580 581 .PHONY: test-pgsql-migration 582 test-pgsql-migration: migrations.pgsql.test migrations.individual.pgsql.test 583 584 generate-ini-mssql: 585 sed -e 's|{{TEST_MSSQL_HOST}}|${TEST_MSSQL_HOST}|g' \ 586 -e 's|{{TEST_MSSQL_DBNAME}}|${TEST_MSSQL_DBNAME}|g' \ 587 -e 's|{{TEST_MSSQL_USERNAME}}|${TEST_MSSQL_USERNAME}|g' \ 588 -e 's|{{TEST_MSSQL_PASSWORD}}|${TEST_MSSQL_PASSWORD}|g' \ 589 -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \ 590 -e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \ 591 -e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \ 592 tests/mssql.ini.tmpl > tests/mssql.ini 593 594 .PHONY: test-mssql 595 test-mssql: integrations.mssql.test generate-ini-mssql 596 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test 597 598 .PHONY: test-mssql\#% 599 test-mssql\#%: integrations.mssql.test generate-ini-mssql 600 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test -test.run $(subst .,/,$*) 601 602 .PHONY: test-mssql-migration 603 test-mssql-migration: migrations.mssql.test migrations.individual.mssql.test 604 605 .PHONY: playwright 606 playwright: deps-frontend 607 npx playwright install $(PLAYWRIGHT_FLAGS) 608 609 .PHONY: test-e2e% 610 test-e2e%: TEST_TYPE ?= e2e 611 # Clear display env variable. Otherwise, chromium tests can fail. 612 DISPLAY= 613 614 .PHONY: test-e2e 615 test-e2e: test-e2e-sqlite 616 617 .PHONY: test-e2e-sqlite 618 test-e2e-sqlite: playwright e2e.sqlite.test generate-ini-sqlite 619 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./e2e.sqlite.test 620 621 .PHONY: test-e2e-sqlite\#% 622 test-e2e-sqlite\#%: playwright e2e.sqlite.test generate-ini-sqlite 623 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./e2e.sqlite.test -test.run TestE2e/$* 624 625 .PHONY: test-e2e-mysql 626 test-e2e-mysql: playwright e2e.mysql.test generate-ini-mysql 627 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./e2e.mysql.test 628 629 .PHONY: test-e2e-mysql\#% 630 test-e2e-mysql\#%: playwright e2e.mysql.test generate-ini-mysql 631 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./e2e.mysql.test -test.run TestE2e/$* 632 633 .PHONY: test-e2e-pgsql 634 test-e2e-pgsql: playwright e2e.pgsql.test generate-ini-pgsql 635 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./e2e.pgsql.test 636 637 .PHONY: test-e2e-pgsql\#% 638 test-e2e-pgsql\#%: playwright e2e.pgsql.test generate-ini-pgsql 639 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./e2e.pgsql.test -test.run TestE2e/$* 640 641 .PHONY: test-e2e-mssql 642 test-e2e-mssql: playwright e2e.mssql.test generate-ini-mssql 643 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test 644 645 .PHONY: test-e2e-mssql\#% 646 test-e2e-mssql\#%: playwright e2e.mssql.test generate-ini-mssql 647 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test -test.run TestE2e/$* 648 649 .PHONY: bench-sqlite 650 bench-sqlite: integrations.sqlite.test generate-ini-sqlite 651 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench . 652 653 .PHONY: bench-mysql 654 bench-mysql: integrations.mysql.test generate-ini-mysql 655 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench . 656 657 .PHONY: bench-mssql 658 bench-mssql: integrations.mssql.test generate-ini-mssql 659 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench . 660 661 .PHONY: bench-pgsql 662 bench-pgsql: integrations.pgsql.test generate-ini-pgsql 663 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench . 664 665 .PHONY: integration-test-coverage 666 integration-test-coverage: integrations.cover.test generate-ini-mysql 667 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out 668 669 .PHONY: integration-test-coverage-sqlite 670 integration-test-coverage-sqlite: integrations.cover.sqlite.test generate-ini-sqlite 671 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.cover.sqlite.test -test.coverprofile=integration.coverage.out 672 673 integrations.mysql.test: git-check $(GO_SOURCES) 674 $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.mysql.test 675 676 integrations.pgsql.test: git-check $(GO_SOURCES) 677 $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.pgsql.test 678 679 integrations.mssql.test: git-check $(GO_SOURCES) 680 $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.mssql.test 681 682 integrations.sqlite.test: git-check $(GO_SOURCES) 683 $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.sqlite.test -tags '$(TEST_TAGS)' 684 685 integrations.cover.test: git-check $(GO_SOURCES) 686 $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -coverpkg $(shell echo $(GO_TEST_PACKAGES) | tr ' ' ',') -o integrations.cover.test 687 688 integrations.cover.sqlite.test: git-check $(GO_SOURCES) 689 $(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)' 690 691 .PHONY: migrations.mysql.test 692 migrations.mysql.test: $(GO_SOURCES) generate-ini-mysql 693 $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.mysql.test 694 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./migrations.mysql.test 695 696 .PHONY: migrations.pgsql.test 697 migrations.pgsql.test: $(GO_SOURCES) generate-ini-pgsql 698 $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.pgsql.test 699 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./migrations.pgsql.test 700 701 .PHONY: migrations.mssql.test 702 migrations.mssql.test: $(GO_SOURCES) generate-ini-mssql 703 $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.mssql.test 704 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./migrations.mssql.test 705 706 .PHONY: migrations.sqlite.test 707 migrations.sqlite.test: $(GO_SOURCES) generate-ini-sqlite 708 $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.sqlite.test -tags '$(TEST_TAGS)' 709 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./migrations.sqlite.test 710 711 .PHONY: migrations.individual.mysql.test 712 migrations.individual.mysql.test: $(GO_SOURCES) 713 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES) 714 715 .PHONY: migrations.individual.sqlite.test\#% 716 migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite 717 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$* 718 719 .PHONY: migrations.individual.pgsql.test 720 migrations.individual.pgsql.test: $(GO_SOURCES) 721 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES) 722 723 .PHONY: migrations.individual.pgsql.test\#% 724 migrations.individual.pgsql.test\#%: $(GO_SOURCES) generate-ini-pgsql 725 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$* 726 727 .PHONY: migrations.individual.mssql.test 728 migrations.individual.mssql.test: $(GO_SOURCES) generate-ini-mssql 729 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES) 730 731 .PHONY: migrations.individual.mssql.test\#% 732 migrations.individual.mssql.test\#%: $(GO_SOURCES) generate-ini-mssql 733 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$* 734 735 .PHONY: migrations.individual.sqlite.test 736 migrations.individual.sqlite.test: $(GO_SOURCES) generate-ini-sqlite 737 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES) 738 739 .PHONY: migrations.individual.sqlite.test\#% 740 migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite 741 GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$* 742 743 e2e.mysql.test: $(GO_SOURCES) 744 $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mysql.test 745 746 e2e.pgsql.test: $(GO_SOURCES) 747 $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.pgsql.test 748 749 e2e.mssql.test: $(GO_SOURCES) 750 $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mssql.test 751 752 e2e.sqlite.test: $(GO_SOURCES) 753 $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.sqlite.test -tags '$(TEST_TAGS)' 754 755 .PHONY: check 756 check: test 757 758 .PHONY: install $(TAGS_PREREQ) 759 install: $(wildcard *.go) 760 CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' 761 762 .PHONY: build 763 build: frontend backend 764 765 .PHONY: frontend 766 frontend: $(WEBPACK_DEST) 767 768 .PHONY: backend 769 backend: go-check generate-backend $(EXECUTABLE) 770 771 # 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 772 .PHONY: generate 773 generate: generate-backend 774 775 .PHONY: generate-backend 776 generate-backend: $(TAGS_PREREQ) generate-go 777 778 .PHONY: generate-go 779 generate-go: $(TAGS_PREREQ) 780 @echo "Running go generate..." 781 @CC= GOOS= GOARCH= CGO_ENABLED=0 $(GO) generate -tags '$(TAGS)' ./... 782 783 .PHONY: security-check 784 security-check: 785 go run $(GOVULNCHECK_PACKAGE) ./... 786 787 $(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ) 788 CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@ 789 790 .PHONY: release 791 release: frontend generate release-windows release-linux release-darwin release-freebsd release-copy release-compress vendor release-sources release-docs release-check 792 793 $(DIST_DIRS): 794 mkdir -p $(DIST_DIRS) 795 796 .PHONY: release-windows 797 release-windows: | $(DIST_DIRS) 798 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) . 799 ifeq (,$(findstring gogit,$(TAGS))) 800 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 . 801 endif 802 803 .PHONY: release-linux 804 release-linux: | $(DIST_DIRS) 805 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) . 806 807 .PHONY: release-darwin 808 release-darwin: | $(DIST_DIRS) 809 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) . 810 811 .PHONY: release-freebsd 812 release-freebsd: | $(DIST_DIRS) 813 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) . 814 815 .PHONY: release-copy 816 release-copy: | $(DIST_DIRS) 817 cd $(DIST); for file in `find . -type f -name "*"`; do cp $${file} ./release/; done; 818 819 .PHONY: release-check 820 release-check: | $(DIST_DIRS) 821 cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done; 822 823 .PHONY: release-compress 824 release-compress: | $(DIST_DIRS) 825 cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && $(GO) run $(GXZ_PACKAGE) -k -9 $${file}; done; 826 827 .PHONY: release-sources 828 release-sources: | $(DIST_DIRS) 829 echo $(VERSION) > $(STORED_VERSION_FILE) 830 # bsdtar needs a ^ to prevent matching subdirectories 831 $(eval EXCL := --exclude=$(shell tar --help | grep -q bsdtar && echo "^")./) 832 # use transform to a add a release-folder prefix; in bsdtar the transform parameter equivalent is -s 833 $(eval TRANSFORM := $(shell tar --help | grep -q bsdtar && echo "-s '/^./gitea-src-$(VERSION)/'" || echo "--transform 's|^./|gitea-src-$(VERSION)/|'")) 834 tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) $(TRANSFORM) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz . 835 rm -f $(STORED_VERSION_FILE) 836 837 .PHONY: release-docs 838 release-docs: | $(DIST_DIRS) docs 839 tar -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs . 840 841 .PHONY: deps 842 deps: deps-frontend deps-backend deps-tools deps-py 843 844 .PHONY: deps-py 845 deps-py: .venv 846 847 .PHONY: deps-frontend 848 deps-frontend: node_modules 849 850 .PHONY: deps-backend 851 deps-backend: 852 $(GO) mod download 853 854 .PHONY: deps-tools 855 deps-tools: 856 $(GO) install $(AIR_PACKAGE) 857 $(GO) install $(EDITORCONFIG_CHECKER_PACKAGE) 858 $(GO) install $(GOFUMPT_PACKAGE) 859 $(GO) install $(GOLANGCI_LINT_PACKAGE) 860 $(GO) install $(GXZ_PACKAGE) 861 $(GO) install $(MISSPELL_PACKAGE) 862 $(GO) install $(SWAGGER_PACKAGE) 863 $(GO) install $(XGO_PACKAGE) 864 $(GO) install $(GO_LICENSES_PACKAGE) 865 $(GO) install $(GOVULNCHECK_PACKAGE) 866 $(GO) install $(ACTIONLINT_PACKAGE) 867 868 node_modules: package-lock.json 869 npm install --no-save 870 @touch node_modules 871 872 .venv: poetry.lock 873 poetry install --no-root 874 @touch .venv 875 876 .PHONY: update 877 update: update-js update-py 878 879 .PHONY: update-js 880 update-js: node-check | node_modules 881 npx updates -u -f package.json 882 rm -rf node_modules package-lock.json 883 npm install --package-lock 884 @touch node_modules 885 886 .PHONY: update-py 887 update-py: node-check | node_modules 888 npx updates -u -f pyproject.toml 889 rm -rf .venv poetry.lock 890 poetry install --no-root 891 @touch .venv 892 893 .PHONY: fomantic 894 fomantic: 895 rm -rf $(FOMANTIC_WORK_DIR)/build 896 cd $(FOMANTIC_WORK_DIR) && npm install --no-save 897 cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config 898 cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/ 899 $(SED_INPLACE) -e 's/ overrideBrowserslist\r/ overrideBrowserslist: ["defaults"]\r/g' $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/tasks/config/tasks.js 900 cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build 901 # fomantic uses "touchstart" as click event for some browsers, it's not ideal, so we force fomantic to always use "click" as click event 902 $(SED_INPLACE) -e 's/clickEvent[ \t]*=/clickEvent = "click", unstableClickEvent =/g' $(FOMANTIC_WORK_DIR)/build/semantic.js 903 $(SED_INPLACE) -e 's/\r//g' $(FOMANTIC_WORK_DIR)/build/semantic.css $(FOMANTIC_WORK_DIR)/build/semantic.js 904 rm -f $(FOMANTIC_WORK_DIR)/build/*.min.* 905 906 .PHONY: webpack 907 webpack: $(WEBPACK_DEST) 908 909 $(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json 910 @$(MAKE) -s node-check node_modules 911 @rm -rf $(WEBPACK_DEST_ENTRIES) 912 @echo "Running webpack..." 913 @BROWSERSLIST_IGNORE_OLD_DATA=true npx webpack 914 @touch $(WEBPACK_DEST) 915 916 .PHONY: svg 917 svg: node-check | node_modules 918 rm -rf $(SVG_DEST_DIR) 919 node tools/generate-svg.js 920 921 .PHONY: svg-check 922 svg-check: svg 923 @git add $(SVG_DEST_DIR) 924 @diff=$$(git diff --color=always --cached $(SVG_DEST_DIR)); \ 925 if [ -n "$$diff" ]; then \ 926 echo "Please run 'make svg' and 'git add $(SVG_DEST_DIR)' and commit the result:"; \ 927 echo "$${diff}"; \ 928 exit 1; \ 929 fi 930 931 .PHONY: lockfile-check 932 lockfile-check: 933 npm install --package-lock-only 934 @diff=$$(git diff --color=always package-lock.json); \ 935 if [ -n "$$diff" ]; then \ 936 echo "package-lock.json is inconsistent with package.json"; \ 937 echo "Please run 'npm install --package-lock-only' and commit the result:"; \ 938 echo "$${diff}"; \ 939 exit 1; \ 940 fi 941 942 .PHONY: update-translations 943 update-translations: 944 mkdir -p ./translations 945 cd ./translations && curl -L https://crowdin.com/download/project/gitea.zip > gitea.zip && unzip gitea.zip 946 rm ./translations/gitea.zip 947 $(SED_INPLACE) -e 's/="/=/g' -e 's/"$$//g' ./translations/*.ini 948 $(SED_INPLACE) -e 's/\\"/"/g' ./translations/*.ini 949 mv ./translations/*.ini ./options/locale/ 950 rmdir ./translations 951 952 .PHONY: generate-license 953 generate-license: 954 $(GO) run build/generate-licenses.go 955 956 .PHONY: generate-gitignore 957 generate-gitignore: 958 $(GO) run build/generate-gitignores.go 959 960 .PHONY: generate-images 961 generate-images: | node_modules 962 npm install --no-save fabric@6.0.0-beta20 imagemin-zopfli@7 963 node tools/generate-images.js $(TAGS) 964 965 .PHONY: generate-manpage 966 generate-manpage: 967 @[ -f gitea ] || make backend 968 @mkdir -p man/man1/ man/man5 969 @./gitea docs --man > man/man1/gitea.1 970 @gzip -9 man/man1/gitea.1 && echo man/man1/gitea.1.gz created 971 @#TODO A small script that formats config-cheat-sheet.en-us.md nicely for use as a config man page 972 973 .PHONY: docker 974 docker: 975 docker build --disable-content-trust=false -t $(DOCKER_REF) . 976 # support also build args docker build --build-arg GITEA_VERSION=v1.2.3 --build-arg TAGS="bindata sqlite sqlite_unlock_notify" . 977 978 # This endif closes the if at the top of the file 979 endif 980 981 # Disable parallel execution because it would break some targets that don't 982 # specify exact dependencies like 'backend' which does currently not depend 983 # on 'frontend' to enable Node.js-less builds from source tarballs. 984 .NOTPARALLEL: