Skip to content
Open
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ TOP = .
# include the checks target
include $(TOP)/checks.mk

# Define all Go module directories
GO_MODULES := . integration token/services/storage/db/kvs/hashicorp cmd/artifactgen cmd/tokengen cmd/token_validation_service cmd/profiler
# Discover all Go module directories dynamically from go.mod files
GO_MODULES := $(shell find . -name "go.mod" -not -path "./tools/*" | sed 's|/go.mod||' | sed 's|^\./||' | sort)
TIDY_GO_MODULES := $(GO_MODULES) tools

# include fabricx target
Expand Down
20 changes: 19 additions & 1 deletion checks.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: checks
checks: licensecheck gofmt goimports govet gofix misspell ineffassign staticcheck protos-lint buf-format
checks: licensecheck gofmt goimports govet gofix misspell ineffassign staticcheck protos-lint buf-format tidy-check

.PHONY: licensecheck
licensecheck:
Expand Down Expand Up @@ -128,3 +128,21 @@ protos-lint:
buf-format:
@echo "Checking protobuf formatting..."
@buf format -d --exit-code

.PHONY: tidy-check
# check that go modules are tidy (run 'make tidy' to fix)
tidy-check:
@echo "Checking Go modules are tidy..."
@for dir in $(TIDY_GO_MODULES); do \
echo " Checking module: $$dir"; \
(cd $$dir && go mod tidy) || exit 1; \
done
@if git diff --name-only | grep -qE '(go\.mod|go\.sum)'; then \
echo ""; \
echo "The following go.mod/go.sum files are not tidy:"; \
git diff --name-only | grep -E '(go\.mod|go\.sum)'; \
echo ""; \
echo "Run 'make tidy' to fix this."; \
exit 1; \
fi
@echo "✓ All Go modules are tidy."
Loading