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

Makefile 4.2 kB

9 years ago
9 years ago
Add basic integration test infrastructure (and new endpoint `/api/v1/version` for testing it) (#741) * Implement '/api/v1/version' * Cleanup and various fixes * Enhance run.sh * Add install_test.go * Add parameter utils.Config for testing handlers * Re-organize TestVersion.go * Rename functions * handling process cleanup properly * Fix missing function renaming * Cleanup the 'retry' logic * Cleanup * Remove unneeded logging code * Logging messages tweaking * Logging message tweaking * Fix logging messages * Use 'const' instead of hardwired numbers * We don't really need retries anymore * Move constant ServerHttpPort to install_test.go * Restore mistakenly removed constant * Add required comments to make the linter happy. * Fix comments and naming to address linter's complaints * Detect Gitea executale version automatically * Remove tests/run.sh, `go test` suffices. * Make `make build` a prerequisite of `make test` * Do not sleep before trying * Speedup the server pinging loop * Use defined const instead of hardwired numbers * Remove redundant error handling * Use a dedicated target for running code.gitea.io/tests * Do not make 'test' depend on 'build' target * Rectify the excluded package list * Remove redundant 'exit 1' * Change the API to allow passing test.T to test handlers * Make testing.T an embedded field * Use assert.Equal to comparing results * Add copyright info * Parametrized logging output * Use tmpdir instead * Eliminate redundant casting * Remove unneeded variable * Fix last commit * Add missing copyright info * Replace fmt.Fprintf with fmt.Fprint * rename the xtest to integration-test * Use Symlink instead of hard-link for cross-device linking * Turn debugging logs on * Follow the existing framework for APIs * Output logs only if test.v is true * Re-order import statements * Enhance the error message * Fix comment which breaks the linter's rule * Rename 'integration-test' to 'e2e-test' for saving keystrokes * Add comment to avoid possible confusion * Rename tests -> integration-tests Also change back the Makefile to use `make integration-test`. * Use tests/integration for now * tests/integration -> integrations Slightly flattened directory hierarchy is better. * Update Makefile accordingly * Fix a missing change in Makefile * govendor update code.gitea.io/sdk/gitea * Fix comment of struct fields * Fix conditional nonsense * Fix missing updates regarding version string changes * Make variable naming more consistent * Check http status code * Rectify error messages
8 years ago
Add basic integration test infrastructure (and new endpoint `/api/v1/version` for testing it) (#741) * Implement '/api/v1/version' * Cleanup and various fixes * Enhance run.sh * Add install_test.go * Add parameter utils.Config for testing handlers * Re-organize TestVersion.go * Rename functions * handling process cleanup properly * Fix missing function renaming * Cleanup the 'retry' logic * Cleanup * Remove unneeded logging code * Logging messages tweaking * Logging message tweaking * Fix logging messages * Use 'const' instead of hardwired numbers * We don't really need retries anymore * Move constant ServerHttpPort to install_test.go * Restore mistakenly removed constant * Add required comments to make the linter happy. * Fix comments and naming to address linter's complaints * Detect Gitea executale version automatically * Remove tests/run.sh, `go test` suffices. * Make `make build` a prerequisite of `make test` * Do not sleep before trying * Speedup the server pinging loop * Use defined const instead of hardwired numbers * Remove redundant error handling * Use a dedicated target for running code.gitea.io/tests * Do not make 'test' depend on 'build' target * Rectify the excluded package list * Remove redundant 'exit 1' * Change the API to allow passing test.T to test handlers * Make testing.T an embedded field * Use assert.Equal to comparing results * Add copyright info * Parametrized logging output * Use tmpdir instead * Eliminate redundant casting * Remove unneeded variable * Fix last commit * Add missing copyright info * Replace fmt.Fprintf with fmt.Fprint * rename the xtest to integration-test * Use Symlink instead of hard-link for cross-device linking * Turn debugging logs on * Follow the existing framework for APIs * Output logs only if test.v is true * Re-order import statements * Enhance the error message * Fix comment which breaks the linter's rule * Rename 'integration-test' to 'e2e-test' for saving keystrokes * Add comment to avoid possible confusion * Rename tests -> integration-tests Also change back the Makefile to use `make integration-test`. * Use tests/integration for now * tests/integration -> integrations Slightly flattened directory hierarchy is better. * Update Makefile accordingly * Fix a missing change in Makefile * govendor update code.gitea.io/sdk/gitea * Fix comment of struct fields * Fix conditional nonsense * Fix missing updates regarding version string changes * Make variable naming more consistent * Check http status code * Rectify error messages
8 years ago
9 years ago
9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. LDFLAGS := -X "main.Version=$(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')" -X "main.Tags=$(TAGS)"
  14. PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations,$(shell go list ./... | grep -v /vendor/))
  15. SOURCES ?= $(shell find . -name "*.go" -type f)
  16. TAGS ?=
  17. ifneq ($(DRONE_TAG),)
  18. VERSION ?= $(subst v,,$(DRONE_TAG))
  19. else
  20. ifneq ($(DRONE_BRANCH),)
  21. VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
  22. else
  23. VERSION ?= master
  24. endif
  25. endif
  26. .PHONY: all
  27. all: build
  28. .PHONY: clean
  29. clean:
  30. go clean -i ./...
  31. rm -rf $(EXECUTABLE) $(DIST) $(BINDATA)
  32. .PHONY: fmt
  33. fmt:
  34. find . -name "*.go" -type f -not -path "./vendor/*" | xargs gofmt -s -w
  35. .PHONY: vet
  36. vet:
  37. go vet $(PACKAGES)
  38. .PHONY: generate
  39. generate:
  40. @hash go-bindata > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  41. go get -u github.com/jteeuwen/go-bindata/...; \
  42. fi
  43. go generate $(PACKAGES)
  44. .PHONY: errcheck
  45. errcheck:
  46. @hash errcheck > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  47. go get -u github.com/kisielk/errcheck; \
  48. fi
  49. errcheck $(PACKAGES)
  50. .PHONY: lint
  51. lint:
  52. @hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  53. go get -u github.com/golang/lint/golint; \
  54. fi
  55. for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
  56. .PHONY: integrations
  57. integrations: TAGS=bindata sqlite
  58. integrations: build
  59. go test code.gitea.io/gitea/integrations
  60. .PHONY: test
  61. test:
  62. for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done;
  63. .PHONY: test-mysql
  64. test-mysql:
  65. @echo "Not integrated yet!"
  66. .PHONY: test-pgsql
  67. test-pgsql:
  68. @echo "Not integrated yet!"
  69. .PHONY: check
  70. check: test
  71. .PHONY: install
  72. install: $(wildcard *.go)
  73. go install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
  74. .PHONY: build
  75. build: $(EXECUTABLE)
  76. $(EXECUTABLE): $(SOURCES)
  77. go build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
  78. .PHONY: docker
  79. docker:
  80. 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
  81. docker build -t gitea/gitea:latest .
  82. .PHONY: release
  83. release: release-dirs release-windows release-linux release-darwin release-copy release-check
  84. .PHONY: release-dirs
  85. release-dirs:
  86. mkdir -p $(DIST)/binaries $(DIST)/release
  87. .PHONY: release-windows
  88. release-windows:
  89. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  90. go get -u github.com/karalabe/xgo; \
  91. fi
  92. xgo -dest $(DIST)/binaries -tags '$(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
  93. ifeq ($(CI),drone)
  94. mv /build/* $(DIST)/binaries
  95. endif
  96. .PHONY: release-linux
  97. release-linux:
  98. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  99. go get -u github.com/karalabe/xgo; \
  100. fi
  101. xgo -dest $(DIST)/binaries -tags '$(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/*' -out gitea-$(VERSION) .
  102. ifeq ($(CI),drone)
  103. mv /build/* $(DIST)/binaries
  104. endif
  105. .PHONY: release-darwin
  106. release-darwin:
  107. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  108. go get -u github.com/karalabe/xgo; \
  109. fi
  110. xgo -dest $(DIST)/binaries -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out gitea-$(VERSION) .
  111. ifeq ($(CI),drone)
  112. mv /build/* $(DIST)/binaries
  113. endif
  114. .PHONY: release-copy
  115. release-copy:
  116. $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));)
  117. .PHONY: release-check
  118. release-check:
  119. cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
  120. .PHONY: javascripts
  121. javascripts: public/js/index.js
  122. .IGNORE: public/js/index.js
  123. public/js/index.js: $(JAVASCRIPTS)
  124. cat $< >| $@
  125. .PHONY: stylesheets
  126. stylesheets: public/css/index.css
  127. .IGNORE: public/css/index.css
  128. public/css/index.css: $(STYLESHEETS)
  129. lessc $< $@
  130. .PHONY: assets
  131. assets: javascripts stylesheets