forked from helm-unittest/helm-unittest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (83 loc) · 3.25 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# borrowed from https://github.com/technosophos/helm-template
GO ?= go
HELM_3_PLUGINS := $(shell bash -c 'eval $$(helm env); echo $$HELM_PLUGINS')
HELM_PLUGIN_DIR := $(HELM_3_PLUGINS)/helm-unittest
VERSION := $(shell sed -n -e 's/version:[ "]*\([^"]*\).*/\1/p' plugin.yaml)
DIST := ./_dist
LDFLAGS := "-X main.version=${VERSION} -extldflags '-static'"
DOCKER ?= "helmunittest/helm-unittest"
PROJECT_DIR := $(shell pwd)
TEST_NAMES ?=basic \
failing-template \
full-snapshot \
global-double-setting \
invalidbasic \
nested_glob \
with-document-select \
with-files \
with-helm-tests \
with-samenamesubsubcharts \
with-schema \
with-subchart \
with-subfolder \
with-subsubcharts
.PHONY: help
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: install
install: bootstrap build
mkdir -p $(HELM_PLUGIN_DIR)
cp untt $(HELM_PLUGIN_DIR)
cp plugin.yaml $(HELM_PLUGIN_DIR)
.PHONY: install-dbg
install-dbg: bootstrap build-debug
mkdir -p $(HELM_PLUGIN_DIR)
cp untt-dbg $(HELM_PLUGIN_DIR)
cp plugin-dbg.yaml $(HELM_PLUGIN_DIR)/plugin.yaml
.PHONY: hookInstall
hookInstall: bootstrap build
.PHONY: unittest
unittest: ## Run unit tests
go test ./... -v -cover
.PHONY: build-debug
build-debug: ## Compile packages and dependencies with debug flag
go build -o untt-dbg -gcflags "all=-N -l" ./cmd/helm-unittest
.PHONY: build
build: unittest ## Compile packages and dependencies
go build -o untt -ldflags $(LDFLAGS) ./cmd/helm-unittest
.PHONY: dist
dist:
mkdir -p $(DIST)
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o untt -ldflags $(LDFLAGS) ./cmd/helm-unittest
tar -zcvf $(DIST)/helm-unittest-linux-arm64-$(VERSION).tgz untt README.md LICENSE plugin.yaml
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o untt -ldflags $(LDFLAGS) ./cmd/helm-unittest
tar -zcvf $(DIST)/helm-unittest-linux-amd64-$(VERSION).tgz untt README.md LICENSE plugin.yaml
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o untt -ldflags $(LDFLAGS) ./cmd/helm-unittest
tar -zcvf $(DIST)/helm-unittest-macos-amd64-$(VERSION).tgz untt README.md LICENSE plugin.yaml
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o untt -ldflags $(LDFLAGS) ./cmd/helm-unittest
tar -zcvf $(DIST)/helm-unittest-macos-arm64-$(VERSION).tgz untt README.md LICENSE plugin.yaml
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o untt.exe -ldflags $(LDFLAGS) ./cmd/helm-unittest
tar -zcvf $(DIST)/helm-unittest-windows-amd64-$(VERSION).tgz untt.exe README.md LICENSE plugin.yaml
shasum -a 256 -b $(DIST)/* > $(DIST)/helm-unittest-checksum.sha
tar -zcvf $(DIST)/helm-unittest-windows_nt-amd64-$(VERSION).tgz untt.exe README.md LICENSE plugin.yaml
shasum -a 256 -b $(DIST)/* > $(DIST)/helm-unittest-checksum.sha
.PHONY: bootstrap
bootstrap:
.PHONY: dockerdist
dockerdist:
./docker-build.sh
.PHONY: go-dependency
dependency: ## Dependency maintanance
@$(GO) get -u ./...
@$(GO) mod tidy
.PHONY: dockerimage
dockerimage: ## Build docker image
docker build -t $(DOCKER):$(VERSION) .
.PHONY: test-docker
test-docker: ## Execute 'helm unittests' in container
@for f in $(TEST_NAMES); do \
echo "running helm unit tests in folder '$${f}'"; \
docker run \
-v $(PROJECT_DIR)/test/data/v3/$${f}:/apps/\
-it --rm $(DOCKER) -f tests/*.yaml .;\
done