@@ -25,9 +25,18 @@ HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
25
25
COMMA := ,
26
26
27
27
XGO_VERSION := go-1.17.x
28
- MIN_GO_VERSION := 001016000
28
+ MIN_GO_VERSION := 001017000
29
29
MIN_NODE_VERSION := 012017000
30
- MIN_GOLANGCI_LINT_VERSION := 001044000
30
+
31
+ AIR_PACKAGE ?= github.com/cosmtrek/air@bedc18201271882c2be66d216d0e1a275b526ec4
32
+ EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@50adf46752da119dfef66e57be3ce2693ea4aa9c
33
+ ERRCHECK_PACKAGE ?= github.com/kisielk/errcheck@8ddee489636a8311a376fc92e27a6a13c6658344
34
+ GOFUMPT_PACKAGE ?= mvdan.cc/
[email protected]
35
+ GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/
[email protected]
36
+ GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/
[email protected]
37
+ MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/
[email protected]
38
+ SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/
[email protected]
39
+ XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
31
40
32
41
DOCKER_IMAGE ?= gitea/gitea
33
42
DOCKER_TAG ?= latest
@@ -125,8 +134,6 @@ ifeq ($(filter $(TAGS_SPLIT),bindata),bindata)
125
134
GO_SOURCES += $(BINDATA_DEST)
126
135
endif
127
136
128
- # To update swagger use: GO111MODULE=on go get -u github.com/go-swagger/go-swagger/cmd/swagger
129
- SWAGGER := $(GO ) run github.com/go-swagger/go-swagger/cmd/swagger
130
137
SWAGGER_SPEC := templates/swagger/v1_json.tmpl
131
138
SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl \| JSEscape \| Safe}}/api/v1"|g
132
139
SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl \| JSEscape \| Safe}}/api/v1"|"basePath": "/api/v1"|g
@@ -234,11 +241,8 @@ clean:
234
241
235
242
.PHONY : fmt
236
243
fmt :
237
- @hash gofumpt > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
238
- $(GO ) install mvdan.cc/
[email protected] ; \
239
- fi
240
244
@echo " Running gitea-fmt (with gofumpt)..."
241
- @$(GO ) run build/code-batch-process.go gitea-fmt -w ' {file-list}'
245
+ @MISSPELL_PACKAGE= $( MISSPELL_PACKAGE ) GOFUMPT_PACKAGE= $( GOFUMPT_PACKAGE ) $(GO ) run build/code-batch-process.go gitea-fmt -w ' {file-list}'
242
246
243
247
.PHONY : vet
244
248
vet :
@@ -257,7 +261,7 @@ endif
257
261
258
262
.PHONY : generate-swagger
259
263
generate-swagger :
260
- $(SWAGGER ) generate spec -x " $( SWAGGER_EXCLUDE) " -o ' ./$(SWAGGER_SPEC)'
264
+ $(GO ) run $( SWAGGER_PACKAGE ) generate spec -x " $( SWAGGER_EXCLUDE) " -o ' ./$(SWAGGER_SPEC)'
261
265
$(SED_INPLACE ) ' $(SWAGGER_SPEC_S_TMPL)' ' ./$(SWAGGER_SPEC)'
262
266
$(SED_INPLACE ) $(SWAGGER_NEWLINE_COMMAND ) ' ./$(SWAGGER_SPEC)'
263
267
@@ -273,24 +277,18 @@ swagger-check: generate-swagger
273
277
.PHONY : swagger-validate
274
278
swagger-validate :
275
279
$(SED_INPLACE ) ' $(SWAGGER_SPEC_S_JSON)' ' ./$(SWAGGER_SPEC)'
276
- $(SWAGGER ) validate ' ./$(SWAGGER_SPEC)'
280
+ $(GO ) run $( SWAGGER_PACKAGE ) validate ' ./$(SWAGGER_SPEC)'
277
281
$(SED_INPLACE ) ' $(SWAGGER_SPEC_S_TMPL)' ' ./$(SWAGGER_SPEC)'
278
282
279
283
.PHONY : errcheck
280
284
errcheck :
281
- @hash errcheck > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
282
- $(GO ) install github.com/kisielk/errcheck@8ddee489636a8311a376fc92e27a6a13c6658344; \
283
- fi
284
285
@echo " Running errcheck..."
285
- @errcheck $(GO_PACKAGES )
286
+ $( GO ) run $( ERRCHECK_PACKAGE ) $(GO_PACKAGES )
286
287
287
288
.PHONY : fmt-check
288
289
fmt-check :
289
- @hash gofumpt > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
290
- $(GO ) install mvdan.cc/
[email protected] ; \
291
- fi
292
290
# get all go files and run gitea-fmt (with gofmt) on them
293
- @diff=$$($(GO ) run build/code-batch-process.go gitea-fmt -l '{file-list}') ; \
291
+ @diff=$$(MISSPELL_PACKAGE= $( MISSPELL_PACKAGE ) GOFUMPT_PACKAGE= $( GOFUMPT_PACKAGE ) $(GO ) run build/code-batch-process.go gitea-fmt -l '{file-list}' ) ; \
294
292
if [ -n " $$ diff" ]; then \
295
293
echo " Please run 'make fmt' and commit the result:" ; \
296
294
echo " $$ {diff}" ; \
@@ -328,10 +326,7 @@ watch-frontend: node-check node_modules
328
326
329
327
.PHONY : watch-backend
330
328
watch-backend : go-check
331
- @hash air > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
332
- $(GO ) install github.com/cosmtrek/air@bedc18201271882c2be66d216d0e1a275b526ec4; \
333
- fi
334
- air -c .air.toml
329
+ $(GO ) run $(AIR_PACKAGE ) -c .air.toml
335
330
336
331
.PHONY : test
337
332
test : test-frontend test-backend
@@ -611,33 +606,24 @@ $(DIST_DIRS):
611
606
612
607
.PHONY : release-windows
613
608
release-windows : | $(DIST_DIRS )
614
- @hash xgo > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
615
- $(GO ) install src.techknowlogick.com/xgo@latest; \
616
- fi
617
- CGO_CFLAGS=" $( CGO_CFLAGS) " xgo -go $(XGO_VERSION ) -buildmode exe -dest $(DIST ) /binaries -tags ' netgo osusergo $(TAGS)' -ldflags ' -linkmode external -extldflags "-static" $(LDFLAGS)' -targets ' windows/*' -out gitea-$(VERSION ) .
609
+ CGO_CFLAGS=" $( CGO_CFLAGS) " $(GO ) run $(XGO_PACKAGE ) -go $(XGO_VERSION ) -buildmode exe -dest $(DIST ) /binaries -tags ' netgo osusergo $(TAGS)' -ldflags ' -linkmode external -extldflags "-static" $(LDFLAGS)' -targets ' windows/*' -out gitea-$(VERSION ) .
618
610
ifeq (,$(findstring gogit,$(TAGS ) ) )
619
- CGO_CFLAGS="$(CGO_CFLAGS)" xgo -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'netgo osusergo gogit $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION)-gogit .
611
+ CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'netgo osusergo gogit $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION)-gogit .
620
612
endif
621
613
ifeq ($(CI ) ,drone)
622
614
cp /build/* $(DIST)/binaries
623
615
endif
624
616
625
617
.PHONY : release-linux
626
618
release-linux : | $(DIST_DIRS )
627
- @hash xgo > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
628
- $(GO ) install src.techknowlogick.com/xgo@latest; \
629
- fi
630
- CGO_CFLAGS=" $( CGO_CFLAGS) " xgo -go $(XGO_VERSION ) -dest $(DIST ) /binaries -tags ' netgo osusergo $(TAGS)' -ldflags ' -linkmode external -extldflags "-static" $(LDFLAGS)' -targets ' $(LINUX_ARCHS)' -out gitea-$(VERSION ) .
619
+ 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 ) .
631
620
ifeq ($(CI ) ,drone)
632
621
cp /build/* $(DIST)/binaries
633
622
endif
634
623
635
624
.PHONY : release-darwin
636
625
release-darwin : | $(DIST_DIRS )
637
- @hash xgo > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
638
- $(GO ) install src.techknowlogick.com/xgo@latest; \
639
- fi
640
- CGO_CFLAGS=" $( CGO_CFLAGS) " xgo -go $(XGO_VERSION ) -dest $(DIST ) /binaries -tags ' netgo osusergo $(TAGS)' -ldflags ' $(LDFLAGS)' -targets ' darwin-10.12/amd64,darwin-10.12/arm64' -out gitea-$(VERSION ) .
626
+ 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 ) .
641
627
ifeq ($(CI ) ,drone)
642
628
cp /build/* $(DIST)/binaries
643
629
endif
@@ -652,10 +638,7 @@ release-check: | $(DIST_DIRS)
652
638
653
639
.PHONY : release-compress
654
640
release-compress : | $(DIST_DIRS )
655
- @hash gxz > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
656
- $(GO ) install github.com/ulikunitz/xz/cmd/
[email protected] ; \
657
- fi
658
- cd $(DIST ) /release/; for file in ` find . -type f -name " *" ` ; do echo " compressing $$ {file}" && gxz -k -9 $$ {file}; done ;
641
+ cd $(DIST ) /release/; for file in ` find . -type f -name " *" ` ; do echo " compressing $$ {file}" && $( GO) run $( GXZ_PAGAGE) -k -9 $$ {file}; done ;
659
642
660
643
.PHONY : release-sources
661
644
release-sources : | $(DIST_DIRS )
@@ -685,6 +668,15 @@ deps-frontend: node_modules
685
668
.PHONY : deps-backend
686
669
deps-backend :
687
670
$(GO ) mod download
671
+ $(GO ) install $(AIR_PACKAGE )
672
+ $(GO ) install $(EDITORCONFIG_CHECKER_PACKAGE )
673
+ $(GO ) install $(ERRCHECK_PACKAGE )
674
+ $(GO ) install $(GOFUMPT_PACKAGE )
675
+ $(GO ) install $(GOLANGCI_LINT_PACKAGE )
676
+ $(GO ) install $(GXZ_PAGAGE )
677
+ $(GO ) install $(MISSPELL_PACKAGE )
678
+ $(GO ) install $(SWAGGER_PACKAGE )
679
+ $(GO ) install $(XGO_PACKAGE )
688
680
689
681
node_modules : package-lock.json
690
682
npm install --no-save
@@ -778,29 +770,19 @@ pr\#%: clean-all
778
770
$(GO ) run contrib/pr/checkout.go $*
779
771
780
772
.PHONY : golangci-lint
781
- golangci-lint : golangci-lint-check
782
- golangci-lint run --timeout 10m
783
-
784
- .PHONY : golangci-lint-check
785
- golangci-lint-check :
786
- $(eval GOLANGCI_LINT_VERSION := $(shell printf "% 03d% 03d% 03d" $(shell golangci-lint --version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ') ;) )
787
- $(eval MIN_GOLANGCI_LINT_VER_FMT := $(shell printf "% g.% g.% g" $(shell echo $(MIN_GOLANGCI_LINT_VERSION ) | grep -o ...) ) )
788
- @hash golangci-lint > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
789
- echo " Downloading golangci-lint v${MIN_GOLANGCI_LINT_VER_FMT} " ; \
790
- export BINARY=" golangci-lint" ; \
791
- curl -sfL " https://raw.githubusercontent.com/golangci/golangci-lint/v${MIN_GOLANGCI_LINT_VER_FMT} /install.sh" | sh -s -- -b $(GOPATH ) /bin v$(MIN_GOLANGCI_LINT_VER_FMT ) ; \
792
- elif [ " $( GOLANGCI_LINT_VERSION) " -lt " $( MIN_GOLANGCI_LINT_VERSION) " ]; then \
793
- echo " Downloading newer version of golangci-lint v${MIN_GOLANGCI_LINT_VER_FMT} " ; \
794
- export BINARY=" golangci-lint" ; \
795
- curl -sfL " https://raw.githubusercontent.com/golangci/golangci-lint/v${MIN_GOLANGCI_LINT_VER_FMT} /install.sh" | sh -s -- -b $(GOPATH ) /bin v$(MIN_GOLANGCI_LINT_VER_FMT ) ; \
796
- fi
773
+ golangci-lint :
774
+ $(GO ) run $(GOLANGCI_LINT_PACKAGE ) run
775
+
776
+ # workaround step for the lint-backend-windows CI task because 'go run' can not
777
+ # have distinct GOOS/GOARCH for its build and run steps
778
+ .PHONY : golangci-lint-windows
779
+ golangci-lint-windows :
780
+ @GOOS= GOARCH= $(GO ) install $(GOLANGCI_LINT_PACKAGE )
781
+ golangci-lint run
797
782
798
783
.PHONY : editorconfig-checker
799
784
editorconfig-checker :
800
- @hash editorconfig-checker > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
801
- $(GO ) install github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@50adf46752da119dfef66e57be3ce2693ea4aa9c; \
802
- fi
803
- editorconfig-checker templates
785
+ $(GO ) run $(EDITORCONFIG_CHECKER_PACKAGE ) templates
804
786
805
787
.PHONY : docker
806
788
docker :
0 commit comments