-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
68 lines (54 loc) · 2.3 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
SHELL := /usr/bin/env bash
MAKEFLAGS += --warn-undefined-variables
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := help
.DELETE_ON_ERROR:
.SUFFIXES:
MASTER_BRANCH=master
SOURCE_README=README.gotmpl
TARGET_README=README.md
CHARTS_DIR=charts/
HELMDOCS_VERSION=v1.11.0
go_cmd ?= docker run --rm -v $$(pwd):/go/src -u $$(id -u):$$(id -g) -e GOCACHE=/go/.cache/go-build -w /go/src bitnami/golang go
.PHONY: help
help: ## Show this help
@grep -E -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = "(: ).*?## "}; {gsub(/\\:/,":",$$1)}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
.PHONY: docs
docs: docs\:helm docs\:readme
.PHONY: docs\:helm
docs\:helm: ## Creates the Chart READMEs from template and values.yaml files
@echo --- Generating Chart READMEs
@docker run --rm -v $$(pwd):/helm-docs -u $$(id -u) jnorwood/helm-docs:${HELMDOCS_VERSION} \
--template-files ./.github/helm-docs-header.gotmpl.md \
--template-files README.gotmpl.md \
--template-files ./.github/helm-docs-footer.gotmpl.md
.PHONY: docs\:readme
docs\:readme: ## Creates the root README from template
@$(go_cmd) run readme.go $(SOURCE_README) $(TARGET_README) $(MASTER_BRANCH) $(CHARTS_DIR)
.PHONY: test
test: ## Run Chart unit tests
@echo --- Executing unit tests
@go test ./...
.PHONY: lint\:fmt
lint\:fmt: ## Run go fmt against code
go fmt ./...
.PHONY: lint\:vet
lint\:vet: ## Run go vet against code
go vet ./...
.PHONY: lint
lint: lint\:fmt lint\:vet ## Invokes the fmt, vet and checks for uncommitted changes
@echo 'Check for uncommitted changes ...'
git diff --exit-code
.PHONY: lint\:versions
lint\:versions: ## Checks if chart versions have been changed
@echo --- Detecting version bumps in the charts
@echo " If this target fails, one of the listed charts below has not its version updated!"
@changed_charts=$$(git diff --dirstat=files,0 origin/master..HEAD -- charts | cut -d '/' -f 2 | uniq) ; \
echo "Charts changed: $$changed_charts" ; echo ; \
for dir in $$changed_charts; do git diff origin/master..HEAD -- "charts/$${dir}/Chart.yaml" | grep -H --label=$${dir} "+version"; done
.PHONY: prepare
prepare: ## Prepare the charts for testing
@echo --- Preparing charts
@find charts -type f -name Makefile | sed 's|/[^/]*$$||' | xargs -I '%' make -C '%' prepare
@echo 'Check for uncommitted changes ...'
git diff --exit-code