Skip to content

Commit 461e4f0

Browse files
authored
Merge pull request #3730 from saschagrunert/help
Makefile: Fix help width and coloring
2 parents cd40028 + e0e0fe6 commit 461e4f0

1 file changed

Lines changed: 36 additions & 34 deletions

File tree

‎Makefile‎

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,51 @@ SHELL:=/usr/bin/env bash
2020

2121
COLOR:=\\033[36m
2222
NOCOLOR:=\\033[0m
23+
HELP_WIDTH:=20
2324

24-
##@ Verify
25+
.PHONY: help
26+
help: ## Display this help
27+
@awk \
28+
-v "col=${COLOR}" -v "nocol=${NOCOLOR}" \
29+
' \
30+
BEGIN { \
31+
FS = ":.*##" ; \
32+
printf "\nUsage:\n make %s<target>%s\n", col, nocol \
33+
} \
34+
/^[a-zA-Z_-]+:.*?##/ { \
35+
printf " %s%-${HELP_WIDTH}s%s %s\n", col, $$1, nocol, $$2 \
36+
} \
37+
/^##@/ { \
38+
printf "\n%s\n", substr($$0, 5) \
39+
} \
40+
' $(MAKEFILE_LIST)
2541

26-
.PHONY: verify verify-boilerplate verify-build verify-dependencies verify-go-mod verify-package-specs
42+
##@ Verify:
2743

44+
.PHONY: verify
2845
verify: release-tools verify-boilerplate verify-build verify-dependencies verify-go-mod verify-package-specs ## Runs verification scripts to ensure correct execution
2946

47+
.PHONY: verify-boilerplate
3048
verify-boilerplate: ## Runs the file header check
3149
./hack/verify-boilerplate.sh
3250

51+
.PHONY: verify-build
3352
verify-build: ## Builds the project for a chosen set of platforms
3453
./hack/verify-build.sh
3554

55+
.PHONY: verify-dependencies
3656
verify-dependencies: ## Runs zeitgeist to verify dependency versions
3757
./hack/verify-dependencies.sh
3858

59+
.PHONY: verify-go-mod
3960
verify-go-mod: ## Runs the go module linter
4061
./hack/verify-go-mod.sh
4162

63+
.PHONY: verify-package-specs
4264
verify-package-specs: ## Runs the rpmlint on package specs
4365
./hack/verify-package-specs.sh
4466

45-
##@ Tests
67+
##@ Tests:
4668

4769
.PHONY: test
4870
test: test-go-unit test-sh ## Runs unit tests to ensure correct execution
@@ -59,22 +81,19 @@ test-go-integration: ## Runs golang integration tests
5981
test-sh: ## Runs all shellscript tests
6082
./hack/test-sh.sh
6183

62-
##@ Tools
84+
##@ Tools:
6385

6486
RELEASE_TOOLS ?=
6587

6688
.PHONY: release-tools
67-
6889
release-tools: ## Compiles a set of release tools, specified by $RELEASE_TOOLS
6990
./compile-release-tools $(RELEASE_TOOLS)
7091

71-
##@ Images
72-
73-
.PHONY: update-images
92+
##@ Images:
7493

75-
images := \
76-
k8s-cloud-builder
94+
images := k8s-cloud-builder
7795

96+
.PHONY: update-images
7897
update-images: $(addprefix image-,$(images)) ## Update all images in ./images/
7998
image-%:
8099
$(eval img := $(subst image-,,$@))
@@ -97,15 +116,16 @@ local-image-run: ## Run a locally build image to use the tools of this repositor
97116
-w /go/src/k8s.io/release \
98117
$(LOCALIMAGE_NAME) bash
99118

100-
##@ Dependencies
101-
102-
.SILENT: update-deps update-deps-go update-mocks
103-
.PHONY: update-deps update-deps-go update-mocks
119+
##@ Dependencies:
104120

121+
.SILENT: update-deps
122+
.PHONY: update-deps
105123
update-deps: update-deps-go ## Update all dependencies for this repo
106124
echo -e "${COLOR}Commit/PR the following changes:${NOCOLOR}"
107125
git status --short
108126

127+
.SILENT: update-deps-go
128+
.PHONY: update-deps-go
109129
update-deps-go: GO111MODULE=on
110130
update-deps-go: ## Update all golang dependencies for this repo
111131
go get -u -t ./...
@@ -114,6 +134,8 @@ update-deps-go: ## Update all golang dependencies for this repo
114134
$(MAKE) test-go-unit
115135
./hack/update-all.sh
116136

137+
.SILENT: update-mocks
138+
.PHONY: update-mocks
117139
update-mocks: ## Update all generated mocks
118140
go generate ./...
119141
for f in $(shell find . -name fake_*.go); do \
@@ -123,23 +145,3 @@ update-mocks: ## Update all generated mocks
123145
mv tmp $$f ;\
124146
fi \
125147
done
126-
127-
##@ Helpers
128-
129-
.PHONY: help
130-
131-
help: ## Display this help
132-
@awk \
133-
-v "col=${COLOR}" -v "nocol=${NOCOLOR}" \
134-
' \
135-
BEGIN { \
136-
FS = ":.*##" ; \
137-
printf "\nUsage:\n make %s<target>%s\n", col, nocol \
138-
} \
139-
/^[a-zA-Z_-]+:.*?##/ { \
140-
printf " %s%-15s%s %s\n", col, $$1, nocol, $$2 \
141-
} \
142-
/^##@/ { \
143-
printf "\n%s%s%s\n", col, substr($$0, 5), nocol \
144-
} \
145-
' $(MAKEFILE_LIST)

0 commit comments

Comments
 (0)