Skip to content

Commit f73da3b

Browse files
author
sapcc-bot
committed
Run go-makefile-maker
1 parent 3c07213 commit f73da3b

File tree

1 file changed

+36
-22
lines changed

1 file changed

+36
-22
lines changed

Makefile

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ endif
1515
default: FORCE
1616
@echo 'There is nothing to build, use `make check` for running the test suite or `make help` for a list of available targets.'
1717

18-
prepare-static-check: FORCE
18+
install-golangci-lint: FORCE
1919
@if ! hash golangci-lint 2>/dev/null; then printf "\e[1;36m>> Installing golangci-lint (this may take a while)...\e[0m\n"; go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; fi
20+
21+
install-go-licence-detector: FORCE
2022
@if ! hash go-licence-detector 2>/dev/null; then printf "\e[1;36m>> Installing go-licence-detector...\e[0m\n"; go install go.elastic.co/go-licence-detector@latest; fi
23+
24+
install-addlicense: FORCE
2125
@if ! hash addlicense 2>/dev/null; then printf "\e[1;36m>> Installing addlicense...\e[0m\n"; go install github.com/google/addlicense@latest; fi
2226

27+
prepare-static-check: FORCE install-golangci-lint install-go-licence-detector install-addlicense
28+
2329
install-controller-gen: FORCE
2430
@if ! hash controller-gen 2>/dev/null; then printf "\e[1;36m>> Installing controller-gen...\e[0m\n"; go install sigs.k8s.io/controller-tools/cmd/controller-gen@latest; fi
2531

@@ -51,7 +57,7 @@ generate: install-controller-gen
5157
@controller-gen crd rbac:roleName=go-pmtud webhook paths="./..." output:crd:artifacts:config=crd
5258
@controller-gen object paths="./..."
5359

54-
run-golangci-lint: FORCE prepare-static-check
60+
run-golangci-lint: FORCE install-golangci-lint
5561
@printf "\e[1;36m>> golangci-lint\e[0m\n"
5662
@golangci-lint run
5763

@@ -72,15 +78,19 @@ tidy-deps: FORCE
7278
go mod tidy
7379
go mod verify
7480

75-
license-headers: FORCE prepare-static-check
81+
force-license-headers: FORCE install-addlicense
82+
@printf "\e[1;36m>> addlicense\e[0m\n"
83+
echo -n $(patsubst $(shell awk '$$1 == "module" {print $$2}' go.mod)%,.%/*.go,$(shell go list ./...)) | xargs -d" " -I{} bash -c 'year="$$(rg -P "Copyright (....) SAP SE" -Nor "\$$1" {})"; awk -i inplace '"'"'{if (display) {print} else {!/^\/\*/ && !/^\*/ && !/^\$$/}}; /^package /{print;display=1}'"'"' {}; addlicense -c "SAP SE" -s -y "$$year" -- {}'
84+
85+
license-headers: FORCE install-addlicense
7686
@printf "\e[1;36m>> addlicense\e[0m\n"
77-
@addlicense -c "SAP SE" -- $(patsubst $(shell awk '$$1 == "module" {print $$2}' go.mod)%,.%/*.go,$(shell go list ./...))
87+
@addlicense -c "SAP SE" -s -- $(patsubst $(shell awk '$$1 == "module" {print $$2}' go.mod)%,.%/*.go,$(shell go list ./...))
7888

79-
check-license-headers: FORCE prepare-static-check
89+
check-license-headers: FORCE install-addlicense
8090
@printf "\e[1;36m>> addlicense --check\e[0m\n"
8191
@addlicense --check -- $(patsubst $(shell awk '$$1 == "module" {print $$2}' go.mod)%,.%/*.go,$(shell go list ./...))
8292

83-
check-dependency-licenses: FORCE prepare-static-check
93+
check-dependency-licenses: FORCE install go-licence-detector
8494
@printf "\e[1;36m>> go-licence-detector\e[0m\n"
8595
@go list -m -mod=readonly -json all | go-licence-detector -includeIndirect -rules .license-scan-rules.json -overrides .license-scan-overrides.jsonl
8696

@@ -98,27 +108,31 @@ help: FORCE
98108
@printf " make \e[36m<target>\e[0m\n"
99109
@printf "\n"
100110
@printf "\e[1mGeneral\e[0m\n"
101-
@printf " \e[36mvars\e[0m Display values of relevant Makefile variables.\n"
102-
@printf " \e[36mhelp\e[0m Display this help.\n"
111+
@printf " \e[36mvars\e[0m Display values of relevant Makefile variables.\n"
112+
@printf " \e[36mhelp\e[0m Display this help.\n"
103113
@printf "\n"
104114
@printf "\e[1mPrepare\e[0m\n"
105-
@printf " \e[36mprepare-static-check\e[0m Install any tools required by static-check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
106-
@printf " \e[36minstall-controller-gen\e[0m Install controller-gen required by static-check and build-all. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
107-
@printf " \e[36minstall-setup-envtest\e[0m Install setup-envtest required by check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
115+
@printf " \e[36minstall-golangci-lint\e[0m Install golangci-lint required by run-golangci-lint/static-check\n"
116+
@printf " \e[36minstall-go-licence-detector\e[0m Install go-licence-detector required by check-dependency-licenses/static-check\n"
117+
@printf " \e[36minstall-addlicense\e[0m Install addlicense required by check-license-headers/license-headers/static-check\n"
118+
@printf " \e[36mprepare-static-check\e[0m Install any tools required by static-check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
119+
@printf " \e[36minstall-controller-gen\e[0m Install controller-gen required by static-check and build-all. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
120+
@printf " \e[36minstall-setup-envtest\e[0m Install setup-envtest required by check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
108121
@printf "\n"
109122
@printf "\e[1mTest\e[0m\n"
110-
@printf " \e[36mcheck\e[0m Run the test suite (unit tests and golangci-lint).\n"
111-
@printf " \e[36mgenerate\e[0m Generate code for Kubernetes CRDs and deepcopy.\n"
112-
@printf " \e[36mrun-golangci-lint\e[0m Install and run golangci-lint. Installing is used in CI, but you should probably install golangci-lint using your package manager.\n"
113-
@printf " \e[36mbuild/cover.out\e[0m Run tests and generate coverage report.\n"
114-
@printf " \e[36mbuild/cover.html\e[0m Generate an HTML file with source code annotations from the coverage report.\n"
115-
@printf " \e[36mstatic-check\e[0m Run static code checks\n"
123+
@printf " \e[36mcheck\e[0m Run the test suite (unit tests and golangci-lint).\n"
124+
@printf " \e[36mgenerate\e[0m Generate code for Kubernetes CRDs and deepcopy.\n"
125+
@printf " \e[36mrun-golangci-lint\e[0m Install and run golangci-lint. Installing is used in CI, but you should probably install golangci-lint using your package manager.\n"
126+
@printf " \e[36mbuild/cover.out\e[0m Run tests and generate coverage report.\n"
127+
@printf " \e[36mbuild/cover.html\e[0m Generate an HTML file with source code annotations from the coverage report.\n"
128+
@printf " \e[36mstatic-check\e[0m Run static code checks\n"
116129
@printf "\n"
117130
@printf "\e[1mDevelopment\e[0m\n"
118-
@printf " \e[36mtidy-deps\e[0m Run go mod tidy and go mod verify.\n"
119-
@printf " \e[36mlicense-headers\e[0m Add license headers to all non-vendored source code files.\n"
120-
@printf " \e[36mcheck-license-headers\e[0m Check license headers in all non-vendored .go files.\n"
121-
@printf " \e[36mcheck-dependency-licenses\e[0m Check all dependency licenses using go-licence-detector.\n"
122-
@printf " \e[36mclean\e[0m Run git clean.\n"
131+
@printf " \e[36mtidy-deps\e[0m Run go mod tidy and go mod verify.\n"
132+
@printf " \e[36mforce-license-headers\e[0m Remove and re-add all license headers to all non-vendored source code files.\n"
133+
@printf " \e[36mlicense-headers\e[0m Add license headers to all non-vendored source code files.\n"
134+
@printf " \e[36mcheck-license-headers\e[0m Check license headers in all non-vendored .go files.\n"
135+
@printf " \e[36mcheck-dependency-licenses\e[0m Check all dependency licenses using go-licence-detector.\n"
136+
@printf " \e[36mclean\e[0m Run git clean.\n"
123137

124138
.PHONY: FORCE

0 commit comments

Comments
 (0)