Skip to content

Commit

Permalink
feat(hack): add add fmt and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bostrt committed Jun 30, 2022
1 parent 41b1617 commit 93b4160
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
16 changes: 16 additions & 0 deletions hack/go-imports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
# Example: ./hack/go-imports.sh pkg/
if [ "$IS_CONTAINER" != "" ]; then
go install golang.org/x/tools/cmd/goimports@latest
for TARGET in "${@}"; do
find "${TARGET}" -name '*.go' ! -name 'bindata.go' ! -path '*/vendor/*' ! -path '*/.build/*' -exec goimports -w {} \+
done
git diff --exit-code
else
podman run --rm \
--env IS_CONTAINER=TRUE \
--volume "${PWD}:/go/src/github.com/openshift/provider-certification-tool:z" \
--workdir /go/src/github.com/openshift/provider-certification-tool \
docker.io/golang:1.17 \
./hack/go-imports.sh "${@}"
fi
14 changes: 14 additions & 0 deletions hack/go-staticcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
# Example: ./hack/go-staticcheck.sh ./...

if [ "$IS_CONTAINER" != "" ]; then
go install honnef.co/go/tools/cmd/staticcheck@latest
staticcheck "${@}"
else
podman run --rm \
--env IS_CONTAINER=TRUE \
--volume "${PWD}:/go/src/github.com/openshift/provider-certification-tool:z" \
--workdir /go/src/github.com/openshift/provider-certification-tool \
docker.io/golang:1.17 \
./hack/go-staticcheck.sh "${@}"
fi

0 comments on commit 93b4160

Please sign in to comment.