Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ repos:
entry: make schema-chart
language: system
files: "^charts/cluster-api-runtime-extensions-nutanix/values.yaml$"
- id: go-generate
name: go-generate
entry: make go-generate
language: system
files: "(.*\\.go|go.mod|go.sum|go.mk)$"
pass_filenames: false
- id: golangci-lint
name: golangci-lint
entry: make go-generate lint
entry: make lint
language: system
files: "(.*\\.go|go.mod|go.sum|go.mk)$"
pass_filenames: false
Expand Down
25 changes: 19 additions & 6 deletions make/go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,23 @@ endif

.PHONY: lint.%
lint.%: ## Runs golangci-lint for a specific module
lint.%: ; $(info $(M) linting $* module)
$(if $(filter-out root,$*),cd $* && )golines -w $$(GOWORK=off go list -tags e2e ./... | grep -v external | sed "s|^$$(GOWORK=off go list -m)|.|")
lint.%: golines.% ; $(info $(M) linting $* module)
$(if $(filter-out root,$*),cd $* && )golangci-lint run --fix --config=$(GOLANGCI_CONFIG_FILE)
$(if $(filter-out root,$*),cd $* && )golines -w $$(GOWORK=off go list -tags e2e ./... | grep -v external | sed "s|^$$(GOWORK=off go list -m)|.|")
$(MAKE) golines.$*

.PHONY: golines
golines: ## Runs golines for all modules in repository
ifneq ($(wildcard $(REPO_ROOT)/go.mod),)
golines: golines.root
endif
ifneq ($(words $(GO_SUBMODULES_NO_DOCS)),0)
golines: $(addprefix golines.,$(GO_SUBMODULES_NO_DOCS:/go.mod=))
endif

.PHONY: golines.%
golines.%: ## Runs golines for a specific module
golines.%:
$(if $(filter-out root,$*),cd $* && )golines -w --ignored-dirs external $$(GOWORK=off go list -tags e2e ./... | sed "s|^$$(GOWORK=off go list -m)|.|")

.PHONY: mod-tidy
mod-tidy: ## Run go mod tidy for all modules
Expand Down Expand Up @@ -185,9 +198,9 @@ go-fix: $(addprefix go-fix.,$(GO_SUBMODULES_NO_DOCS:/go.mod=))
endif

.PHONY: go-fix.%
go-fix.%: ## Runs golangci-lint for a specific module
go-fix.%: ## Runs go fix for a specific module
go-fix.%: ; $(info $(M) go fixing $* module)
$(if $(filter-out root,$*),cd $* && )go fix ./...
$(if $(filter-out root,$*),cd $* && )go fix $$(GOWORK=off go list ./... | sed "s|^$$(GOWORK=off go list -m)|.|" | grep -v external)

.PHONY: go-generate
go-generate: ## Runs go generate
Expand All @@ -210,7 +223,7 @@ go-generate: ; $(info $(M) running go generate)
yq --inplace \
--from-file=hack/update-webhook-configurations.yq \
charts/cluster-api-runtime-extensions-nutanix/templates/webhooks.yaml
#$(MAKE) go-fix
$(MAKE) go-fix golines
$(MAKE) configure-csi-providers
# Update anyOf schemas for resource.Quantity fields to only accept strings
# until CAPI ClusterClass variables support anyOf schemas.
Expand Down
1 change: 1 addition & 0 deletions make/make.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-builtin-variables
MAKEFLAGS += --no-print-directory
Loading