Skip to content

Commit

Permalink
Makefile cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
akshayjshah committed Oct 3, 2023
1 parent 73452f4 commit a1f5d78
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ SHELL := bash
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-print-directory
GO ?= go
BIN := .tmp/bin
export PATH := $(BIN):$(PATH)
export GOBIN := $(abspath $(BIN))

.PHONY: help
help: ## Describe useful make targets
Expand All @@ -20,21 +21,21 @@ all: ## Build, test, and lint (default)

.PHONY: test
test: build ## Run unit tests
$(GO) test -vet=off -race -cover ./...
go test -vet=off -race -cover ./...

.PHONY: build
build: ## Build all packages
$(GO) build ./...
go build ./...

.PHONY: lint
lint: $(BIN)/gofmt $(BIN)/staticcheck ## Lint Go
test -z "$$($(BIN)/gofmt -s -l . | tee /dev/stderr)"
$(GO) vet ./...
$(BIN)/staticcheck ./...
test -z "$$(gofmt -s -l . | tee /dev/stderr)"
go vet ./...
staticcheck ./...

.PHONY: lintfix
lintfix: $(BIN)/gofmt ## Automatically fix some lint errors
$(BIN)/gofmt -s -w .
gofmt -s -w .

.PHONY: upgrade
upgrade: ## Upgrade dependencies
Expand All @@ -46,8 +47,8 @@ clean: ## Remove intermediate artifacts

$(BIN)/gofmt:
@mkdir -p $(@D)
$(GO) build -o $(@) cmd/gofmt
go build -o $(@) cmd/gofmt

$(BIN)/staticcheck:
@mkdir -p $(@D)
GOBIN=$(abspath $(@D)) $(GO) install honnef.co/go/tools/cmd/staticcheck@latest
go install honnef.co/go/tools/cmd/staticcheck@latest

0 comments on commit a1f5d78

Please sign in to comment.