Skip to content
Snippets Groups Projects
Commit 3d7730fd authored by baude's avatar baude
Browse files

add makefile


add makefile with preliminary targets for validating code, format, lint

Signed-off-by: default avatarbaude <bbaude@redhat.com>
parent 394c06f4
No related branches found
No related tags found
No related merge requests found
FROM registry.fedoraproject.org/fedora:latest
RUN dnf update && dnf install -y golang && dnf -y clean all
Makefile 0 → 100644
GO ?= go
EPOCH_TEST_COMMIT ?= 394c06f491fe9f1c28a410e3b0b91916a5119406
FIRST_GOPATH := $(firstword $(subst :, ,$(GOPATH)))
GOPKGDIR := $(FIRST_GOPATH)/src/$(PROJECT)
GOPKGBASEDIR ?= $(shell dirname "$(GOPKGDIR)")
GO_BUILD=$(GO) build
GOBIN := $(shell $(GO) env GOBIN)
ifeq ($(GOBIN),)
GOBIN := $(FIRST_GOPATH)/bin
endif
validate: gofmt .gitvalidation lint
gofmt:
find . -name '*.go' ! -path './vendor/*' -exec gofmt -s -w {} \+
git diff --exit-code
.PHONY: .gitvalidation
.gitvalidation:
GIT_CHECK_EXCLUDE="./vendor" $(GOBIN)/git-validation -v -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..$(HEAD)
.PHONY: install.tools
install.tools: .install.gitvalidation .install.ginkgo .install.golangci-lint
lint: .install.golangci-lint
$(GOBIN)/golangci-lint run --tests=false
define go-get
env GO111MODULE=off \
$(GO) get -u ${1}
endef
.install.ginkgo:
if [ ! -x "$(GOBIN)/ginkgo" ]; then \
$(call go-get,github.com/onsi/ginkgo); \
fi
.install.gitvalidation:
if [ ! -x "$(GOBIN)/git-validation" ]; then \
$(call go-get,github.com/vbatts/git-validation); \
fi
.install.golangci-lint:
if [ ! -x "$(GOBIN)/golangci-lint" ]; then \
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOBIN)/ v1.17.1; \
fi
.PHONY: \
gofmt \
lint \
validate
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment