Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃尡 verify.sh: verify generate & modules (in CI) #2186

Merged
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
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,15 @@ clean-bin: ## Remove all generated binaries.
rm -rf hack/tools/bin

.PHONY: verify-modules
verify-modules: modules
@if !(git diff --quiet HEAD -- go.sum go.mod); then \
verify-modules: modules ## Verify go modules are up to date
@if !(git diff --quiet HEAD -- go.sum go.mod $(TOOLS_DIR)/go.mod $(TOOLS_DIR)/go.sum $(ENVTEST_DIR)/go.mod $(ENVTEST_DIR)/go.sum); then \
git diff; \
echo "go module files are out of date, please run 'make modules'"; exit 1; \
fi

.PHONY: verify-generate
verify-generate: generate ## Verify generated files are up to date
@if !(git diff --quiet HEAD); then \
git diff; \
echo "generated files are out of date, run make generate"; exit 1; \
fi
18 changes: 14 additions & 4 deletions hack/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,22 @@ cd "${REPO_ROOT}"
header_text "running generate"
make generate

header_text "running golangci-lint"
make lint
# Only run verify-generate in CI, otherwise running generate
# locally (which is a valid operation) causes `make test` to fail.
if [[ -n ${CI} ]]; then
header_text "verifying generate"
make verify-generate
fi

# Only run module verification in CI, otherwise updating
header_text "running modules"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flipped the order here so we first run go mod tidy before running the linter.

Depending on the state of the go.mod files the linter could fail because they are out-of-date.

make modules

# Only run verify-modules in CI, otherwise updating
# go module locally (which is a valid operation) causes `make test` to fail.
if [[ -n ${CI} ]]; then
header_text "verifying modules"
make modules verify-modules
make verify-modules
fi

header_text "running golangci-lint"
make lint