Skip to content

Commit

Permalink
Fail build if code is not formatted
Browse files Browse the repository at this point in the history
This change adds a new safe guard to fail tests if the code is not
formatted using 'go fmt'.
  • Loading branch information
David Pinheiro committed Nov 2, 2018
1 parent 5fe29cf commit f46cc2e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Makefile
@@ -1,20 +1,24 @@
LDFLAGS := -X main.version=$(version)

.install:
test:
ifneq ($(shell go fmt ./...),)
$(error code not formatted. Please run 'go fmt')
endif
@go test ./... -v -race -coverprofile=coverage.txt -covermode=atomic
cover: test
go tool cover -html=coverage.txt

install:
@go install github.com/davrodpin/mole/cmd/mole
.bin:

bin:
ifeq ($(version),)
$(error usage: make bin version=X.Y.Z)
endif
GOOS=darwin GOARCH=amd64 go build -o bin/mole -ldflags "$(LDFLAGS)" github.com/davrodpin/mole/cmd/mole
cd bin && tar c mole | gzip > mole$(version).darwin-amd64.tar.gz && rm mole && cd -
GOOS=linux GOARCH=amd64 go build -o bin/mole -ldflags "$(LDFLAGS)" github.com/davrodpin/mole/cmd/mole
cd bin && tar c mole | gzip > mole$(version).linux-amd64.tar.gz && rm mole && cd -
test:
@go test ./... -race -coverprofile=coverage.txt -covermode=atomic
.cover: test
go tool cover -html=coverage.txt


add-network:
-@docker network create --subnet=192.168.33.0/24 mole
Expand Down

0 comments on commit f46cc2e

Please sign in to comment.