generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
72 lines (58 loc) · 2.03 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright 2022 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0
#
# Makefile for KRM functions registry.
MYGOBIN = $(shell go env GOBIN)
ifeq ($(MYGOBIN),)
MYGOBIN = $(shell go env GOPATH)/bin
endif
export PATH := $(MYGOBIN):$(PATH)
# Run all tests in this repo for in-tree and out-of-tree functions
all: install-tools license validate-metadata test-in-tree
## Run all unit tests and e2e tests for in-tree functions
test-in-tree: e2e-test unit-test lint
# Run all the e2e tests for in-tree functions
e2e-test: build-local $(MYGOBIN)/kustomize
cd tests; \
go test -v -run TestExamples
# Validate the metadata for all published functions
validate-metadata:
cd tests; \
go test -v -run TestValidateMetadata
# Run all unit tests for in-tree functions
unit-test:
cd krm-functions && $(MAKE) unit-test
# Build all in-tree functions locally
build-local:
cd krm-functions && $(MAKE) build-local
# Add project licenses to all code files in here
.PHONY: license
license: $(MYGOBIN)/addlicense
( find . -type f -exec bash -c "$(MYGOBIN)/addlicense -y 2022 -c 'The Kubernetes Authors.' -f LICENSE_TEMPLATE {}" ";" )
# Lint all in-tree functions
lint:
cd tests; golangci-lint run ./...
cd krm-functions && find . -type f -name go.mod -execdir golangci-lint run ./... \;
# Install tools needed to run tests
install-tools: \
install-kustomize \
install-addlicense \
install-golangci-lint \
install-helm
# Install kustomize
install-kustomize:
ifeq (, $(shell which kustomize))
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash; \
mv ./kustomize $(MYGOBIN)/kustomize
endif
# Install the addlicense tool
install-addlicense:
go install github.com/google/[email protected]
# Install the lint tool
install-golangci-lint:
go install github.com/golangci/golangci-lint/cmd/[email protected]
# Install helm v3 (needed for sig-cli/render-helm-chart)
install-helm:
ifeq (, $(shell which helm))
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
endif