kube-explorer/scripts/validate
Yuxing Deng a5e53f2b17 feat: Support for nginx ingress path prefix
And validate should failed if git tree is dirty
2024-07-29 15:07:34 +08:00

32 lines
960 B
Bash
Executable File

#!/bin/bash
set -e
source $(dirname $0)/version
cd "$(dirname $0)/.."
if ! command -v golangci-lint; then
echo Running: go fmt
echo Skipping validation: no golangci-lint available test -z "$(go fmt ./... | tee /dev/stderr)"
exit
fi
echo Running: golangci-lint
golangci-lint run
echo Tidying up modules
go mod tidy
echo Verifying modules
go mod verify
dirty_files="$(git status --porcelain --untracked-files=no)"
if [ -n "$dirty_files" ]; then
echo "Encountered dirty repo! Aborting."
echo "If you're seeing this, it means there are uncommitted changes in the repo."
echo "If you're seeing this in CI, it probably means that your Go modules aren't tidy, or more generally that running"
echo "validation would result in changes to the repo. Make sure you're up to date with the upstream branch and run"
echo "'go mod tidy' and commit the changes, if any. The offending changed files are as follows:"
echo "$dirty_files"
exit 1
fi