Skip to content

Commit b70b349

Browse files
Makefile: add a target to run the auto-fixer (Azure#4247)
* Makefile: correctly depend on tools The entire point of having per-tool Makefile targets is so that each top-level target that requires some tool can ensure that the tools it uses are installed as necessary. Having a top-level `install-tools` target is fine, if you need to do it, but using it exclusively loses the whole point of incremental installs and revalidations from Make. Signed-off-by: Steve Kuznetsov <stekuznetsov@microsoft.com> * Makefile: add a target to run the auto-fixer The --fix argument to the linter will automatically update the AST where possible to make the codebase conformant. Signed-off-by: Steve Kuznetsov <stekuznetsov@microsoft.com> --------- Signed-off-by: Steve Kuznetsov <stekuznetsov@microsoft.com>
1 parent 3c9df36 commit b70b349

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ validate-go: validate-imports
283283
go test -tags e2e -run ^$$ ./test/e2e/...
284284

285285
.PHONY: validate-go-action
286-
validate-go-action: validate-imports
286+
validate-go-action: validate-imports validate-lint-go-fix
287287
go run ./hack/licenses -validate -ignored-go vendor,pkg/client,.git -ignored-python python/client,python/az/aro/azext_aro/aaz,vendor,.git
288288
@[ -z "$$(ls pkg/util/*.go 2>/dev/null)" ] || (echo error: go files are not allowed in pkg/util, use a subpackage; exit 1)
289289
@[ -z "$$(find -name "*:*")" ] || (echo error: filenames with colons are not allowed on Windows, please rename; exit 1)
@@ -307,6 +307,18 @@ unit-test-go-coverpkg: $(GOTESTSUM)
307307
lint-go: $(GOLANGCI_LINT)
308308
$(GOLANGCI_LINT) run --verbose
309309

310+
.PHONY: lint-go-fix
311+
lint-go-fix: $(GOLANGCI_LINT)
312+
$(GOLANGCI_LINT) run --verbose --fix
313+
314+
.PHONY: validate-lint-go-fix
315+
validate-lint-go-fix: lint-go-fix
316+
if ! git diff --quiet HEAD; then \
317+
git diff; \
318+
echo "You need to run 'make lint-go-fix' to update the codebase and commit the changes"; \
319+
exit 1; \
320+
fi
321+
310322
.PHONY: lint-admin-portal
311323
lint-admin-portal:
312324
docker build --platform=linux/amd64 --build-arg REGISTRY=$(REGISTRY) --build-arg BUILDER_REGISTRY=$(BUILDER_REGISTRY) -f Dockerfile.portal_lint . -t linter:latest --no-cache

0 commit comments

Comments
 (0)