| 1 |
# Copyright 2022 The Kubernetes Authors. |
| 2 |
# SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
MYGOBIN = $(shell go env GOBIN) |
| 5 |
ifeq ($(MYGOBIN),) |
| 6 |
MYGOBIN = $(shell go env GOPATH)/bin |
| 7 |
endif |
| 8 |
export PATH := $(MYGOBIN):$(PATH) |
| 9 |
|
| 10 |
# only set this if not already set, so importing makefiles can override it |
| 11 |
export KUSTOMIZE_ROOT ?= $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\1|') |
| 12 |
include $(KUSTOMIZE_ROOT)/Makefile-tools.mk |
| 13 |
|
| 14 |
.PHONY: lint test fix fmt tidy vet build |
| 15 |
|
| 16 |
lint: $(MYGOBIN)/golangci-lint |
| 17 |
$(MYGOBIN)/golangci-lint cache clean # Workaround for https://github.com/golangci/golangci-lint/issues/3228 |
| 18 |
$(MYGOBIN)/golangci-lint \ |
| 19 |
-c $$KUSTOMIZE_ROOT/.golangci.yml \ |
| 20 |
--path-prefix $(shell pwd | sed -E 's|(.*\/kustomize)/(.*)|\2|') \ |
| 21 |
run ./... |
| 22 |
|
| 23 |
test: |
| 24 |
go test -v -timeout 45m -cover ./... |
| 25 |
|
| 26 |
fix: |
| 27 |
go fix ./... |
| 28 |
|
| 29 |
fmt: |
| 30 |
go fmt ./... |
| 31 |
|
| 32 |
tidy: |
| 33 |
go mod tidy |
| 34 |
|
| 35 |
vet: |
| 36 |
go vet ./... |
| 37 |
|
| 38 |
build: |
| 39 |
go build -v -o $(MYGOBIN) ./... |