Skip to content

Commit 8137f43

Browse files
committed
update makefile and improve lint
Signed-off-by: Markus Blaschke <[email protected]>
1 parent 96892f2 commit 8137f43

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

Makefile

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,45 @@
1-
.PHONY: all build clean image check vendor dependencies
2-
3-
NAME := kube-pool-manager
1+
PROJECT_NAME := kube-pool-manager
42
GIT_TAG := $(shell git describe --dirty --tags --always)
53
GIT_COMMIT := $(shell git rev-parse --short HEAD)
6-
LDFLAGS := -X "main.gitTag=$(GIT_TAG)" -X "main.gitCommit=$(GIT_COMMIT)" -extldflags "-static"
7-
8-
PKGS := $(shell go list ./... | grep -v -E '/vendor/|/test')
9-
FIRST_GOPATH := $(firstword $(subst :, ,$(shell go env GOPATH)))
10-
GOLANGCI_LINT_BIN := $(FIRST_GOPATH)/bin/golangci-lint
4+
LDFLAGS := -X "main.gitTag=$(GIT_TAG)" -X "main.gitCommit=$(GIT_COMMIT)" -extldflags "-static"
115

6+
FIRST_GOPATH := $(firstword $(subst :, ,$(shell go env GOPATH)))
7+
GOLANGCI_LINT_BIN := $(FIRST_GOPATH)/bin/golangci-lint
128

9+
.PHONY: all
1310
all: build
1411

12+
.PHONY: clean
1513
clean:
1614
git clean -Xfd .
1715

16+
.PHONY: build
1817
build:
19-
CGO_ENABLED=0 go build -a -ldflags '$(LDFLAGS)' -o $(NAME) .
18+
CGO_ENABLED=0 go build -a -ldflags '$(LDFLAGS)' -o $(PROJECT_NAME) .
2019

20+
.PHONY: vendor
2121
vendor:
2222
go mod tidy
2323
go mod vendor
2424
go mod verify
2525

26+
.PHONY: image
2627
image: build
27-
docker build -t $(NAME):$(TAG) .
28+
docker build -t $(PROJECT_NAME):$(GIT_TAG) .
2829

2930
build-push-development:
30-
docker build -t webdevops/$(NAME):development . && docker push webdevops/$(NAME):development
31+
docker build -t webdevops/$(PROJECT_NAME):development . && docker push webdevops/$(PROJECT_NAME):development
3132

33+
.PHONY: test
3234
test:
3335
go test ./...
3436

3537
.PHONY: lint
3638
lint: $(GOLANGCI_LINT_BIN)
37-
# megacheck fails to respect build flags, causing compilation failure during linting.
38-
# instead, use the unused, gosimple, and staticcheck linters directly
39-
$(GOLANGCI_LINT_BIN) run -D megacheck -E unused,gosimple,staticcheck --timeout=10m
39+
$(GOLANGCI_LINT_BIN) run -E exportloopref,gofmt --timeout=10m
4040

41+
.PHONY: dependencies
4142
dependencies: $(GOLANGCI_LINT_BIN)
42-
go mod download
4343

4444
$(GOLANGCI_LINT_BIN):
45-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(FIRST_GOPATH)/bin v1.30.0
46-
47-
45+
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(FIRST_GOPATH)/bin v1.32.2

0 commit comments

Comments
 (0)