mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-15 06:11:21 +01:00
044cd4d016
* Add reverse proxy configuration support for remote IP address validation * Trust all IP addresses in containerized environments by default * Use single option to specify networks and proxy IP addresses. By default trust all loopback IPs Co-authored-by: techknowlogick <techknowlogick@gitea.io>
59 lines
1.5 KiB
Makefile
Vendored
59 lines
1.5 KiB
Makefile
Vendored
GO ?= go
|
|
HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
|
|
ifeq ($(HAS_GO), GO)
|
|
GOPATH ?= $(shell $(GO) env GOPATH)
|
|
export PATH := $(GOPATH)/bin:$(PATH)
|
|
endif
|
|
|
|
GOFMT ?= gofmt -s
|
|
|
|
ifneq ($(RACE_ENABLED),)
|
|
GOTESTFLAGS ?= -race
|
|
endif
|
|
|
|
GO_SOURCES := $(wildcard *.go)
|
|
GO_SOURCES_OWN := $(filter-out vendor/%, $(GO_SOURCES))
|
|
GO_PACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/)
|
|
|
|
.PHONY: revive
|
|
revive:
|
|
@hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
$(GO) get -u github.com/mgechev/revive; \
|
|
fi
|
|
revive -config .revive.toml -exclude=./vendor/... ./... || exit 1
|
|
|
|
.PHONY: golangci-lint
|
|
golangci-lint:
|
|
@hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
export BINARY="golangci-lint"; \
|
|
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.26.0; \
|
|
fi
|
|
golangci-lint run --timeout 5m
|
|
|
|
.PHONY: lint
|
|
lint: golangci-lint revive
|
|
|
|
.PHONY: fmt
|
|
fmt:
|
|
$(GOFMT) -w $(GO_SOURCES_OWN)
|
|
|
|
.PHONY: fmt-check
|
|
fmt-check:
|
|
# get all go files and run go fmt on them
|
|
@diff=$$($(GOFMT) -d $(GO_SOURCES_OWN)); \
|
|
if [ -n "$$diff" ]; then \
|
|
echo "Please run 'make fmt' and commit the result:"; \
|
|
echo "$${diff}"; \
|
|
exit 1; \
|
|
fi;
|
|
|
|
.PHONY: misspell-check
|
|
misspell-check:
|
|
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
|
|
fi
|
|
misspell -error $(GO_SOURCES_OWN)
|
|
|
|
.PHONY: test
|
|
test:
|
|
$(GO) test -cover -coverprofile coverage.out $(GOTESTFLAGS) $(GO_PACKAGES)
|