Fork to maintain patches against the official gitea for https://code.ceondo.com https://github.com/go-gitea/gitea

Makefile 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. DIST := dist
  2. IMPORT := code.gitea.io/gitea
  3. ifeq ($(OS), Windows_NT)
  4. EXECUTABLE := gitea.exe
  5. else
  6. EXECUTABLE := gitea
  7. endif
  8. BINDATA := modules/{options,public,templates}/bindata.go
  9. STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less)
  10. JAVASCRIPTS :=
  11. GOFLAGS := -i -v
  12. EXTRA_GOFLAGS ?=
  13. VERSION := $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
  14. LDFLAGS := -X "main.Version=$(VERSION)" -X "main.Tags=$(TAGS)"
  15. PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations,$(shell go list ./... | grep -v /vendor/))
  16. SOURCES ?= $(shell find . -name "*.go" -type f)
  17. TAGS ?=
  18. ifneq ($(DRONE_TAG),)
  19. VERSION ?= $(subst v,,$(DRONE_TAG))
  20. else
  21. ifneq ($(DRONE_BRANCH),)
  22. VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
  23. else
  24. VERSION ?= master
  25. endif
  26. endif
  27. .PHONY: all
  28. all: build
  29. .PHONY: clean
  30. clean:
  31. go clean -i ./...
  32. rm -rf $(EXECUTABLE) $(DIST) $(BINDATA)
  33. .PHONY: fmt
  34. fmt:
  35. find . -name "*.go" -type f -not -path "./vendor/*" | xargs gofmt -s -w
  36. .PHONY: vet
  37. vet:
  38. go vet $(PACKAGES)
  39. .PHONY: generate
  40. generate:
  41. @hash go-bindata > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  42. go get -u github.com/jteeuwen/go-bindata/...; \
  43. fi
  44. go generate $(PACKAGES)
  45. .PHONY: errcheck
  46. errcheck:
  47. @hash errcheck > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  48. go get -u github.com/kisielk/errcheck; \
  49. fi
  50. errcheck $(PACKAGES)
  51. .PHONY: lint
  52. lint:
  53. @hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  54. go get -u github.com/golang/lint/golint; \
  55. fi
  56. for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
  57. .PHONY: integrations
  58. integrations: TAGS=bindata sqlite
  59. integrations: build
  60. go test code.gitea.io/gitea/integrations
  61. .PHONY: test
  62. test:
  63. for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done;
  64. .PHONY: test-vendor
  65. test-vendor:
  66. @hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  67. go get -u github.com/kardianos/govendor; \
  68. fi
  69. govendor status +outside +unused || exit 1
  70. .PHONY: test-sqlite
  71. test-sqlite: integrations.test integrations/gitea-integration
  72. GITEA_CONF=integrations/sqlite.ini ./integrations.test
  73. .PHONY: test-mysql
  74. test-mysql: integrations.test integrations/gitea-integration
  75. echo "CREATE DATABASE IF NOT EXISTS testgitea" | mysql -u root
  76. GITEA_CONF=integrations/mysql.ini ./integrations.test
  77. .PHONY: test-pgsql
  78. test-pgsql: integrations.test integrations/gitea-integration
  79. GITEA_CONF=integrations/pgsql.ini ./integrations.test
  80. integrations.test: $(SOURCES)
  81. go test -c code.gitea.io/gitea/integrations -tags 'sqlite'
  82. integrations/gitea-integration:
  83. curl -L https://github.com/ethantkoenig/gitea-integration/archive/v2.tar.gz > integrations/gitea-integration.tar.gz
  84. mkdir -p integrations/gitea-integration
  85. tar -xf integrations/gitea-integration.tar.gz -C integrations/gitea-integration --strip-components 1
  86. .PHONY: check
  87. check: test
  88. .PHONY: install
  89. install: $(wildcard *.go)
  90. go install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
  91. .PHONY: build
  92. build: $(EXECUTABLE)
  93. $(EXECUTABLE): $(SOURCES)
  94. go build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
  95. .PHONY: docker
  96. docker:
  97. docker run -ti --rm -v $(CURDIR):/srv/app/src/code.gitea.io/gitea -w /srv/app/src/code.gitea.io/gitea -e TAGS="bindata $(TAGS)" webhippie/golang:edge make clean generate build
  98. docker build -t gitea/gitea:latest .
  99. .PHONY: release
  100. release: release-dirs release-windows release-linux release-darwin release-copy release-check
  101. .PHONY: release-dirs
  102. release-dirs:
  103. mkdir -p $(DIST)/binaries $(DIST)/release
  104. .PHONY: release-windows
  105. release-windows:
  106. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  107. go get -u github.com/karalabe/xgo; \
  108. fi
  109. xgo -dest $(DIST)/binaries -tags '$(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
  110. ifeq ($(CI),drone)
  111. mv /build/* $(DIST)/binaries
  112. endif
  113. .PHONY: release-linux
  114. release-linux:
  115. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  116. go get -u github.com/karalabe/xgo; \
  117. fi
  118. xgo -dest $(DIST)/binaries -tags '$(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/*' -out gitea-$(VERSION) .
  119. ifeq ($(CI),drone)
  120. mv /build/* $(DIST)/binaries
  121. endif
  122. .PHONY: release-darwin
  123. release-darwin:
  124. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  125. go get -u github.com/karalabe/xgo; \
  126. fi
  127. xgo -dest $(DIST)/binaries -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out gitea-$(VERSION) .
  128. ifeq ($(CI),drone)
  129. mv /build/* $(DIST)/binaries
  130. endif
  131. .PHONY: release-copy
  132. release-copy:
  133. $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));)
  134. .PHONY: release-check
  135. release-check:
  136. cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
  137. .PHONY: javascripts
  138. javascripts: public/js/index.js
  139. .IGNORE: public/js/index.js
  140. public/js/index.js: $(JAVASCRIPTS)
  141. cat $< >| $@
  142. .PHONY: stylesheets
  143. stylesheets: public/css/index.css
  144. .IGNORE: public/css/index.css
  145. public/css/index.css: $(STYLESHEETS)
  146. lessc $< $@
  147. .PHONY: assets
  148. assets: javascripts stylesheets