Skip to content

Commit f2e0536

Browse files
authored
Merge branch 'master' into cache-pr-GetDiverging
2 parents 235f1e4 + 71979d9 commit f2e0536

File tree

167 files changed

+10822
-813
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+10822
-813
lines changed

.drone.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ steps:
5151
- go build -mod=vendor -o gitea_no_gcc # test if build succeeds without the sqlite tag
5252
depends_on: [lint-backend]
5353

54+
- name: build-backend-arm64
55+
pull: always
56+
image: golang:1.14
57+
environment:
58+
GO111MODULE: on
59+
GOPROXY: off
60+
GOOS: linux
61+
GOARCH: arm64
62+
TAGS: bindata
63+
commands:
64+
- curl -sL https://deb.nodesource.com/setup_12.x | bash - && apt -y install nodejs
65+
- make build # test cross compile
66+
- rm ./gitea # clean
67+
depends_on: [lint-backend]
68+
5469
- name: build-backend-386
5570
pull: always
5671
image: golang:1.14
@@ -406,7 +421,7 @@ steps:
406421
- export PATH=$PATH:$GOPATH/bin
407422
- make release
408423
environment:
409-
GOPROXY: off
424+
GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not
410425
TAGS: bindata sqlite sqlite_unlock_notify
411426

412427
- name: gpg-sign
@@ -504,7 +519,7 @@ steps:
504519
- export PATH=$PATH:$GOPATH/bin
505520
- make release
506521
environment:
507-
GOPROXY: off
522+
GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not
508523
TAGS: bindata sqlite sqlite_unlock_notify
509524

510525
- name: gpg-sign

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ coverage.all
4444
*.log
4545

4646
/gitea
47+
/gitea-vet
4748
/debug
4849
/integrations.test
4950

Makefile

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
DIST := dist
22
DIST_DIRS := $(DIST)/binaries $(DIST)/release
33
IMPORT := code.gitea.io/gitea
4-
export GO111MODULE=off
4+
export GO111MODULE=on
55

66
GO ?= go
77
SED_INPLACE := sed -i
@@ -66,7 +66,7 @@ endif
6666

6767
LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
6868

69-
GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations/migration-test,$(filter-out code.gitea.io/gitea/integrations,$(shell GO111MODULE=on $(GO) list -mod=vendor ./... | grep -v /vendor/)))
69+
GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations/migration-test,$(filter-out code.gitea.io/gitea/integrations,$(shell $(GO) list -mod=vendor ./... | grep -v /vendor/)))
7070

7171
WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f)
7272
WEBPACK_CONFIGS := webpack.config.js
@@ -95,7 +95,7 @@ FOMANTIC_DEST := public/fomantic/semantic.min.js public/fomantic/semantic.min.cs
9595
FOMANTIC_DEST_DIR := public/fomantic
9696

9797
#To update swagger use: GO111MODULE=on go get -u github.com/go-swagger/go-swagger/cmd/[email protected]
98-
SWAGGER := GO111MODULE=on $(GO) run -mod=vendor github.com/go-swagger/go-swagger/cmd/swagger
98+
SWAGGER := $(GO) run -mod=vendor github.com/go-swagger/go-swagger/cmd/swagger
9999
SWAGGER_SPEC := templates/swagger/v1_json.tmpl
100100
SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl}}/api/v1"|g
101101
SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl}}/api/v1"|"basePath": "/api/v1"|g
@@ -193,7 +193,11 @@ fmt:
193193

194194
.PHONY: vet
195195
vet:
196+
# Default vet
196197
$(GO) vet $(GO_PACKAGES)
198+
# Custom vet
199+
$(GO) build -mod=vendor gitea.com/jolheiser/gitea-vet
200+
$(GO) vet -vettool=gitea-vet $(GO_PACKAGES)
197201

198202
.PHONY: $(TAGS_EVIDENCE)
199203
$(TAGS_EVIDENCE):
@@ -264,7 +268,7 @@ fmt-check:
264268
lint: lint-backend lint-frontend
265269

266270
.PHONY: lint-backend
267-
lint-backend: golangci-lint revive swagger-check swagger-validate test-vendor
271+
lint-backend: golangci-lint revive vet swagger-check swagger-validate test-vendor
268272

269273
.PHONY: lint-frontend
270274
lint-frontend: node_modules
@@ -273,7 +277,7 @@ lint-frontend: node_modules
273277

274278
.PHONY: test
275279
test:
276-
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -tags='sqlite sqlite_unlock_notify' $(GO_PACKAGES)
280+
$(GO) test $(GOTESTFLAGS) -mod=vendor -tags='sqlite sqlite_unlock_notify' $(GO_PACKAGES)
277281

278282
.PHONY: test-check
279283
test-check:
@@ -289,22 +293,19 @@ test-check:
289293

290294
.PHONY: test\#%
291295
test\#%:
292-
GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' -run $* $(GO_PACKAGES)
296+
$(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' -run $(subst .,/,$*) $(GO_PACKAGES)
293297

294298
.PHONY: coverage
295299
coverage:
296-
@hash gocovmerge > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
297-
$(GO) get -u github.com/wadey/gocovmerge; \
298-
fi
299-
gocovmerge integration.coverage.out $(shell find . -type f -name "coverage.out") > coverage.all;\
300+
GO111MODULE=on $(GO) run -mod=vendor build/gocovmerge.go integration.coverage.out $(shell find . -type f -name "coverage.out") > coverage.all
300301

301302
.PHONY: unit-test-coverage
302303
unit-test-coverage:
303-
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -tags='sqlite sqlite_unlock_notify' -cover -coverprofile coverage.out $(GO_PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
304+
$(GO) test $(GOTESTFLAGS) -mod=vendor -tags='sqlite sqlite_unlock_notify' -cover -coverprofile coverage.out $(GO_PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
304305

305306
.PHONY: vendor
306307
vendor:
307-
GO111MODULE=on $(GO) mod tidy && GO111MODULE=on $(GO) mod vendor
308+
$(GO) mod tidy && $(GO) mod vendor
308309

309310
.PHONY: test-vendor
310311
test-vendor: vendor
@@ -321,7 +322,7 @@ test-sqlite: integrations.sqlite.test
321322

322323
.PHONY: test-sqlite\#%
323324
test-sqlite\#%: integrations.sqlite.test
324-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.run $*
325+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.run $(subst .,/,$*)
325326

326327
.PHONY: test-sqlite-migration
327328
test-sqlite-migration: migrations.sqlite.test
@@ -340,7 +341,7 @@ test-mysql: integrations.mysql.test generate-ini-mysql
340341

341342
.PHONY: test-mysql\#%
342343
test-mysql\#%: integrations.mysql.test generate-ini-mysql
343-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.run $*
344+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.run $(subst .,/,$*)
344345

345346
.PHONY: test-mysql-migration
346347
test-mysql-migration: migrations.mysql.test generate-ini-mysql
@@ -359,7 +360,7 @@ test-mysql8: integrations.mysql8.test generate-ini-mysql8
359360

360361
.PHONY: test-mysql8\#%
361362
test-mysql8\#%: integrations.mysql8.test generate-ini-mysql8
362-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./integrations.mysql8.test -test.run $*
363+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./integrations.mysql8.test -test.run $(subst .,/,$*)
363364

364365
.PHONY: test-mysql8-migration
365366
test-mysql8-migration: migrations.mysql8.test generate-ini-mysql8
@@ -379,7 +380,7 @@ test-pgsql: integrations.pgsql.test generate-ini-pgsql
379380

380381
.PHONY: test-pgsql\#%
381382
test-pgsql\#%: integrations.pgsql.test generate-ini-pgsql
382-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.run $*
383+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.run $(subst .,/,$*)
383384

384385
.PHONY: test-pgsql-migration
385386
test-pgsql-migration: migrations.pgsql.test generate-ini-pgsql
@@ -398,7 +399,7 @@ test-mssql: integrations.mssql.test generate-ini-mssql
398399

399400
.PHONY: test-mssql\#%
400401
test-mssql\#%: integrations.mssql.test generate-ini-mssql
401-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test -test.run $*
402+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test -test.run $(subst .,/,$*)
402403

403404
.PHONY: test-mssql-migration
404405
test-mssql-migration: migrations.mssql.test generate-ini-mssql
@@ -425,22 +426,22 @@ integration-test-coverage: integrations.cover.test generate-ini-mysql
425426
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
426427

427428
integrations.mysql.test: git-check $(GO_SOURCES)
428-
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql.test
429+
$(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql.test
429430

430431
integrations.mysql8.test: git-check $(GO_SOURCES)
431-
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql8.test
432+
$(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql8.test
432433

433434
integrations.pgsql.test: git-check $(GO_SOURCES)
434-
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.pgsql.test
435+
$(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.pgsql.test
435436

436437
integrations.mssql.test: git-check $(GO_SOURCES)
437-
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mssql.test
438+
$(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mssql.test
438439

439440
integrations.sqlite.test: git-check $(GO_SOURCES)
440-
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags 'sqlite sqlite_unlock_notify'
441+
$(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags 'sqlite sqlite_unlock_notify'
441442

442443
integrations.cover.test: git-check $(GO_SOURCES)
443-
GO111MODULE=on $(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -coverpkg $(shell echo $(GO_PACKAGES) | tr ' ' ',') -o integrations.cover.test
444+
$(GO) test $(GOTESTFLAGS) -mod=vendor -c code.gitea.io/gitea/integrations -coverpkg $(shell echo $(GO_PACKAGES) | tr ' ' ',') -o integrations.cover.test
444445

445446
.PHONY: migrations.mysql.test
446447
migrations.mysql.test: $(GO_SOURCES)
@@ -480,10 +481,10 @@ backend: go-check generate $(EXECUTABLE)
480481

481482
.PHONY: generate
482483
generate: $(TAGS_PREREQ)
483-
GO111MODULE=on $(GO) generate -mod=vendor -tags '$(TAGS)' $(GO_PACKAGES)
484+
CC= GOOS= GOARCH= $(GO) generate -mod=vendor -tags '$(TAGS)' $(GO_PACKAGES)
484485

485486
$(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
486-
GO111MODULE=on $(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
487+
$(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
487488

488489
.PHONY: release
489490
release: frontend generate release-windows release-linux release-darwin release-copy release-compress release-sources release-check
@@ -496,7 +497,7 @@ release-windows: | $(DIST_DIRS)
496497
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
497498
$(GO) get -u src.techknowlogick.com/xgo; \
498499
fi
499-
xgo -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
500+
GO111MODULE=off xgo -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
500501
ifeq ($(CI),drone)
501502
cp /build/* $(DIST)/binaries
502503
endif
@@ -506,7 +507,7 @@ release-linux: | $(DIST_DIRS)
506507
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
507508
$(GO) get -u src.techknowlogick.com/xgo; \
508509
fi
509-
xgo -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/mips64le,linux/mips,linux/mipsle' -out gitea-$(VERSION) .
510+
GO111MODULE=off xgo -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/mips64le,linux/mips,linux/mipsle' -out gitea-$(VERSION) .
510511
ifeq ($(CI),drone)
511512
cp /build/* $(DIST)/binaries
512513
endif
@@ -516,7 +517,7 @@ release-darwin: | $(DIST_DIRS)
516517
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
517518
$(GO) get -u src.techknowlogick.com/xgo; \
518519
fi
519-
xgo -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out gitea-$(VERSION) .
520+
GO111MODULE=off xgo -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out gitea-$(VERSION) .
520521
ifeq ($(CI),drone)
521522
cp /build/* $(DIST)/binaries
522523
endif
@@ -532,7 +533,7 @@ release-check: | $(DIST_DIRS)
532533
.PHONY: release-compress
533534
release-compress: | $(DIST_DIRS)
534535
@hash gxz > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
535-
$(GO) get -u github.com/ulikunitz/xz/cmd/gxz; \
536+
GO111MODULE=off $(GO) get -u github.com/ulikunitz/xz/cmd/gxz; \
536537
fi
537538
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
538539

@@ -620,4 +621,4 @@ golangci-lint:
620621
export BINARY="golangci-lint"; \
621622
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.24.0; \
622623
fi
623-
env GO111MODULE=on golangci-lint run --timeout 5m
624+
golangci-lint run --timeout 5m

build/vendor.go renamed to build.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5-
package build
5+
//+build vendor
6+
7+
package main
8+
9+
// Libraries that are included to vendor utilities used during build.
10+
// These libraries will not be included in a normal compilation.
611

712
import (
813
// for lint
@@ -15,4 +20,13 @@ import (
1520

1621
// for embed
1722
_ "github.com/shurcooL/vfsgen"
23+
24+
// for cover merge
25+
_ "golang.org/x/tools/cover"
26+
27+
// for vet
28+
_ "gitea.com/jolheiser/gitea-vet"
29+
30+
// for swagger
31+
_ "github.com/go-swagger/go-swagger/cmd/swagger"
1832
)

0 commit comments

Comments
 (0)