Skip to content

Commit

Permalink
lint: Check that 'go mod tidy' was run (#951)
Browse files Browse the repository at this point in the history
In #948, we noticed that some `go.sum` files were outdated. To avoid
this in the future, add a `lint` check that verifies that `go mod tidy`
does not cause any changes.

This will fail with a dirty working tree as well, but in CI, we don't
expect that.
  • Loading branch information
abhinav committed May 25, 2021
1 parent 756fb2a commit 4110cb4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Makefile
Expand Up @@ -33,6 +33,12 @@ lint: $(GOLINT) $(STATICCHECK)
@echo "Checking for license headers..."
@./checklicense.sh | tee -a lint.log
@[ ! -s lint.log ]
@echo "Checking 'go mod tidy'..."
@make tidy
@if ! git diff --quiet; then \
echo "'go mod tidy' resulted in changes or working tree is dirty:"; \
git --no-pager diff; \
fi

$(GOLINT):
cd tools && go install golang.org/x/lint/golint
Expand Down Expand Up @@ -61,3 +67,7 @@ bench:
updatereadme:
rm -f README.md
cat .readme.tmpl | go run internal/readme/readme.go > README.md

.PHONY: tidy
tidy:
@$(foreach dir,$(MODULE_DIRS),(cd $(dir) && go mod tidy) &&) true

0 comments on commit 4110cb4

Please sign in to comment.