Add Makefile (#99)

Add a Makefile to simplify build and test.

Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
Ben Kochie 2020-09-14 23:26:21 +02:00 committed by GitHub
parent e11dda7fa5
commit 54d38cd396
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 3 deletions

View File

@ -11,9 +11,7 @@ jobs:
steps:
- checkout
- run: go mod download
- run: go vet ./...
- run: go test ./... -cover -race
- run: go build -race ./cmd/ping
- run: make
- run: curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | BINDIR=/home/circleci/.local/bin sh
- run: goreleaser release --skip-publish --snapshot
- store_artifacts:

32
Makefile Normal file
View File

@ -0,0 +1,32 @@
GO ?= go
GOFMT ?= $(GO)fmt
GOOPTS ?=
GO111MODULE :=
pkgs = ./...
all: style vet build test
.PHONY: build
build:
@echo ">> building ping"
GO111MODULE=$(GO111MODULE) $(GO) build $(GOOPTS) ./cmd/ping
.PHONY: style
style:
@echo ">> checking code style"
@fmtRes=$$($(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print)); \
if [ -n "$${fmtRes}" ]; then \
echo "gofmt checking failed!"; echo "$${fmtRes}"; echo; \
echo "Please ensure you are using $$($(GO) version) for formatting code."; \
exit 1; \
fi
.PHONY: test
test:
@echo ">> running all tests"
GO111MODULE=$(GO111MODULE) $(GO) test -race -cover $(GOOPTS) $(pkgs)
.PHONY: vet
vet:
@echo ">> vetting code"
GO111MODULE=$(GO111MODULE) $(GO) vet $(GOOPTS) $(pkgs)