GO ?= $(shell go env GOROOT)/bin/go DIFF ?= diff --unified EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v2/cmd/editorconfig-checker@2.8.0 # renovate: datasource=go GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.7.0 # renovate: datasource=go GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2 # renovate: datasource=go UNCOVER_PACKAGE ?= github.com/gregoryv/uncover/cmd/uncover@latest MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.6.0 # renovate: datasource=go DEADCODE_PACKAGE ?= golang.org/x/tools/cmd/deadcode@v0.24.0 # renovate: datasource=go GOMOCK_PACKAGE ?= go.uber.org/mock/mockgen@v0.5.0 # renovate: datasource=go SCHEMAS_VERSION ?= v3 DEADCODE_ARGS ?= -generated=false -test -f='{{println .Path}}{{range .Funcs}}{{printf "\t%s\n" .Name}}{{end}}{{println}}' code.forgejo.org/f3/gof3/v3/... VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//') LDFLAGS := $(LDFLAGS) -X "code.forgejo.org/f3/gof3/v3/cmd.Version=$(VERSION)" EXECUTABLE := f3-cli GO_DIRS = cmd f3 forges logger main options tree util GO_SOURCES = $(shell find $(GO_DIRS) -type f -name "*.go") $(EXECUTABLE): $(GO_SOURCES) $(GO) build -tags 'netgo osusergo' -ldflags '-extldflags -static -s -w $(LDFLAGS)' -o $@ code.forgejo.org/f3/gof3/v3/main .PHONY: deps-backend deps-backend: $(GO) mod download $(GO) install $(GOFUMPT_PACKAGE) $(GO) install $(GOLANGCI_LINT_PACKAGE) $(GO) install $(UNCOVER_PACKAGE) $(GO) install $(MISSPELL_PACKAGE) $(GO) install $(DEADCODE_PACKAGE) $(GO) install $(GOMOCK_PACKAGE) .PHONY: lint lint: @if ! $(MAKE) lint-run ; then echo "Please run 'make lint-fix' and commit the result" ; exit 1 ; fi .PHONY: lint-run lint-run: lint-schemas $(GO) run $(GOLANGCI_LINT_PACKAGE) run $(GOLANGCI_LINT_ARGS) $(GO) run $(DEADCODE_PACKAGE) $(DEADCODE_ARGS) > .cur-deadcode-out $(DIFF) .deadcode-out .cur-deadcode-out .PHONY: lint-schemas lint-schemas: status=0 ; for schema in f3/schemas/*.json ; do if ! jq '.|empty' $$schema ; then status=1 ; echo $$schema error ; fi ; done ; exit $$status d=`mktemp -d` ; trap "rm -fr $$d" EXIT ; git clone --branch $(SCHEMAS_VERSION) --quiet https://code.forgejo.org/f3/f3-schemas $$d/schemas ; diff --exclude '.*' -ru $$d/schemas f3/schemas .PHONY: lint-schemas-fix lint-schemas-fix: d=`mktemp -d` ; trap "rm -fr $$d" EXIT ; git clone --branch $(SCHEMAS_VERSION) --quiet https://code.forgejo.org/f3/f3-schemas $$d/schemas ; cp $$d/schemas/* f3/schemas .PHONY: lint-fix lint-fix: lint-schemas-fix $(GO) run $(GOLANGCI_LINT_PACKAGE) run $(GOLANGCI_LINT_ARGS) --fix $(GO) run $(DEADCODE_PACKAGE) $(DEADCODE_ARGS) > .deadcode-out .PHONY: fmt fmt: GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) gofumpt -extra -w . SPELLCHECK_FILES = $(GO_DIRS) .PHONY: lint-spell lint-spell: @$(GO) run $(MISSPELL_PACKAGE) -error $(SPELLCHECK_FILES) .PHONY: lint-spell-fix lint-spell-fix: @$(GO) run $(MISSPELL_PACKAGE) -w $(SPELLCHECK_FILES)