-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add go mod tidy clean verifier to CI (#1689)
Signed-off-by: Ken Sipe <kensipe@gmail.com> Co-authored-by: Jan Schlicht <jan@d2iq.com>
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
##### | ||
# Used to ensure that running `go mod tidy` results in a non-dirty repository. | ||
# Used to verify that dependency changes have been cleaned | ||
##### | ||
|
||
set -o nounset | ||
set -o pipefail | ||
# intentionally not setting 'set -o errexit' because we want to print custom error messages | ||
|
||
# versions of tools | ||
echo "$(go version)" | ||
|
||
# make sure make generate can be invoked | ||
go mod tidy | ||
RETVAL=$? | ||
if [[ ${RETVAL} != 0 ]]; then | ||
echo "Invoking 'go mod tidy' ends with non-zero exit code." | ||
exit 1 | ||
fi | ||
|
||
git diff --exit-code --quiet | ||
RETVAL=$? | ||
|
||
if [[ ${RETVAL} != 0 ]]; then | ||
echo "Running 'go mod tidy' produces changes to the current git status. Maybe you forgot to clean go.mod after changing dependencies?" | ||
echo "The current diff:" | ||
git diff | ||
exit 1 | ||
fi | ||
|
||
echo "Verifying 'go mod tidy' was successful! ヽ(•‿•)ノ" | ||
exit 0 |