fix: Use go_run from common lib (#1793)

* fix: Use go_run from common lib

* chore: Set Bash options in name format

* Reflect shell suggestion for the direct changes
This commit is contained in:
David Simansky 2023-04-24 11:35:42 +02:00 committed by GitHub
parent 8c648379a4
commit 189592606e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -15,6 +15,8 @@
# limitations under the License.
set -o pipefail
set -o errexit
set -o nounset
source_dirs="cmd pkg test lib tools"
@ -25,7 +27,9 @@ else
ARGS=("$@")
fi
set -eu
# Tool version
readonly GOIMPORTS_VERSION="v0.7.0"
readonly GOLINT_VERSION="v1.52.0"
# Run build
run() {
@ -110,19 +114,19 @@ codegen() {
go_fmt() {
echo "🧹 ${S}Format"
find $(echo $source_dirs) -name "*.go" -print0 | xargs -0 gofmt -s -w
find $(echo "$source_dirs") -name "*.go" -print0 | xargs -0 gofmt -s -w
}
source_format() {
set +e
run_go_tool golang.org/x/tools/cmd/goimports goimports -w $(echo $source_dirs)
find $(echo $source_dirs) -name "*.go" -print0 | xargs -0 gofmt -s -w
go_run "golang.org/x/tools/cmd/goimports@${GOIMPORTS_VERSION}" -w $(echo "$source_dirs")
find $(echo "$source_dirs") -name "*.go" -print0 | xargs -0 gofmt -s -w
set -e
}
source_lint() {
echo "🔍 Lint"
run_go_tool github.com/golangci/golangci-lint/cmd/golangci-lint golangci-lint run || \
go_run "github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLINT_VERSION}" run || \
{ echo "--- FAIL: golangci-lint failed please fix the reported errors"; return 1; }
}