@@ -42,15 +42,97 @@ TOOLS_BIN_DIR := $(CURDIR)/bin
4242
4343# SECTION Development
4444.PHONY : verify # HELP To verify the code
45- verify : tidy fmt vet lint
45+ verify :
46+ @echo " Running verification checks..."
47+ @errors=0; \
48+ warnings=0; \
49+ failed_steps=" " ; \
50+ echo " 1/4 Running 'make tidy'..." ; \
51+ if ! $( MAKE) tidy; then \
52+ echo " ERROR: 'make tidy' failed" ; \
53+ errors=$$((errors+1 ) ); \
54+ failed_steps=" $$ failed_steps tidy" ; \
55+ else \
56+ echo " SUCCESS: 'make tidy' passed" ; \
57+ fi ; \
58+ echo " " ; \
59+ echo " 2/4 Running 'fmt'..." ; \
60+ if [ -n " $$ PROW_JOB_ID" ]; then \
61+ echo " (Prow CI environment detected, using fmt-without-fix)" ; \
62+ if ! $( MAKE) fmt-without-fix; then \
63+ echo " ERROR: 'make fmt-without-fix' failed" ; \
64+ errors=$$((errors+1 ) ); \
65+ failed_steps=" $$ failed_steps fmt" ; \
66+ else \
67+ echo " SUCCESS: 'make fmt-without-fix' passed" ; \
68+ fi ; \
69+ else \
70+ echo " (Local environment, using fmt with auto-fix)" ; \
71+ files_before=$$(find . -name '*.go' -not -path './vendor/*' -not -path './pkg/bindata/*' -exec gofmt -l {} \; ) ; \
72+ if ! $( MAKE) fmt; then \
73+ echo " ERROR: 'make fmt' failed" ; \
74+ errors=$$((errors+1 ) ); \
75+ failed_steps=" $$ failed_steps fmt" ; \
76+ elif [ -n " $$ files_before" ]; then \
77+ echo " WARNING: 'make fmt' auto-fixed files. Don't forget to commit these changes!" ; \
78+ warnings=1; \
79+ else \
80+ echo " SUCCESS: 'make fmt' passed" ; \
81+ fi ; \
82+ fi ; \
83+ echo " " ; \
84+ echo " 3/4 Running 'make vet'..." ; \
85+ if ! $( MAKE) vet; then \
86+ echo " ERROR: 'make vet' failed" ; \
87+ errors=$$((errors+1 ) ); \
88+ failed_steps=" $$ failed_steps vet" ; \
89+ else \
90+ echo " SUCCESS: 'make vet' passed" ; \
91+ fi ; \
92+ echo " " ; \
93+ echo " 4/4 Running 'make lint'..." ; \
94+ if ! $( MAKE) lint; then \
95+ echo " ERROR: 'make lint' failed" ; \
96+ errors=$$((errors+1 ) ); \
97+ failed_steps=" $$ failed_steps lint" ; \
98+ else \
99+ echo " SUCCESS: 'make lint' passed" ; \
100+ fi ; \
101+ echo " " ; \
102+ echo " Verification completed with $$ errors error(s)" ; \
103+ if [ $$ errors -gt 0 ]; then \
104+ echo " FAILED: The following verification check(s) failed:$$ failed_steps" ; \
105+ exit 1; \
106+ elif [ $$ warnings -gt 0 ]; then \
107+ echo " WARNING: All verification checks passed, but some files were auto-fixed. Don't forget to commit!" ; \
108+ else \
109+ echo " SUCCESS: All verification checks passed" ; \
110+ fi
46111
47112.PHONY : tidy # HELP Run go mod tidy.
48113tidy :
49114 go mod tidy
50115
51116.PHONY : fmt
52117fmt : # HELP Run go fmt against code.
53- go fmt ./...
118+ @files=$$(find . -name '*.go' -not -path './vendor/*' -not -path './pkg/bindata/*' -exec gofmt -l {} \; ) ; \
119+ go fmt ./...; \
120+ if [ -n " $$ files" ]; then \
121+ echo " " ; \
122+ echo " Files have been formatted. Don't forget to commit these changes!" ; \
123+ fi
124+
125+ .PHONY : fmt-without-fix
126+ fmt-without-fix : # HELP Run go fmt against code.
127+ @files=$$(find . -name '*.go' -not -path './vendor/*' -not -path './pkg/bindata/*' -exec gofmt -l {} \; ) ; \
128+ if [ -n " $$ files" ]; then \
129+ echo " Files that need formatting:" ; \
130+ echo " $$ files" ; \
131+ echo " " ; \
132+ echo " To fix formatting, run:" ; \
133+ echo " make fmt" ; \
134+ exit 1; \
135+ fi
54136
55137.PHONY : vet
56138vet : # HELP Run go vet against code.
0 commit comments