bazel check: silent env for cleaner output (#1898)

* explicitly ignore pkgs for cleaner output

* do not ignore but redirect stderr

* silent env var to silent stderr

* add silent env var to vuln,lint,tf

* fix golangci silent

* Update bazel/ci/terraform.sh.in

Co-authored-by: Malte Poll <1780588+malt3@users.noreply.github.com>

* Update bazel/ci/golicenses.sh.in

Co-authored-by: Malte Poll <1780588+malt3@users.noreply.github.com>

* Update bazel/ci/govulncheck.sh.in

Co-authored-by: Malte Poll <1780588+malt3@users.noreply.github.com>

* Update bazel/ci/golangci_lint.sh.in

Co-authored-by: Malte Poll <1780588+malt3@users.noreply.github.com>

---------

Co-authored-by: Malte Poll <1780588+malt3@users.noreply.github.com>
This commit is contained in:
Adrian Stobbe 2023-06-14 13:58:21 +02:00 committed by GitHub
parent 7a1c70d7e5
commit c1f9d86cd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 170 additions and 136 deletions

View File

@ -27,6 +27,7 @@ excludeMods=(
"hack/tools"
)
check() {
echo "The following Go modules are excluded and won't be linted with golangci-lint:"
for exclude in "${excludeMods[@]}"; do
for i in "${!modules[@]}"; do
@ -42,7 +43,15 @@ statuscode=0
echo "Linting the following Go modules with golangci-lint:"
for mod in "${modules[@]}"; do
echo " ${mod}"
PATH="$(dirname "${go}"):${PATH}" GOROOT=$(${go} env GOROOT) GOPATH=$(${go} env GOPATH) GOCACHE=$(${go} env GOCACHE) CGO_ENABLED=0 ${golangcilint} run --timeout=15m "${mod}/..." || statuscode=$?
PATH="$(dirname "${go}"):${PATH}" GOROOT=$(${go} env GOROOT) GOPATH=$(${go} env GOPATH) GOCACHE=$(${go} env GOCACHE) CGO_ENABLED=0 ${golangcilint} run --timeout=15m "${mod}/..." >&2
statuscode=$?
done
exit "${statuscode}"
}
if test -v SILENT; then
check > /dev/null
else
check
fi

View File

@ -27,15 +27,12 @@ not_allowed() {
err=1
}
${go} mod download
err=0
license_report() {
PATH="$(dirname "${go}"):${PATH}" \
GOROOT=$(${go} env GOROOT) \
GOPATH=$(${go} env GOPATH) \
GOCACHE=$(${go} env GOCACHE) \
${golicenses} csv ./... | {
${golicenses} report ./... | {
while read -r line; do
pkg=${line%%,*}
@ -89,3 +86,14 @@ GOCACHE=$(${go} env GOCACHE) \
done
exit "${err}"
}
}
${go} mod download
err=0
if test -v SILENT; then
license_report 2> /dev/null
else
license_report
fi

View File

@ -24,6 +24,7 @@ submodules=$(${go} list -f '{{.Dir}}' -m)
PATH=$(dirname "${go}"):${PATH}
check() {
err=0
echo "Scanning Go vulnerability DB for knwon vulnerabilities in modules:"
@ -39,3 +40,11 @@ for mod in ${submodules}; do
done
exit "${err}"
}
if test -v SILENT; then
check > /dev/null
else
check
fi

View File

@ -39,6 +39,7 @@ excludeDirs=(
"build"
)
check() {
echo "The following Terraform modules are excluded and won't be tidied:"
for exclude in "${excludeDirs[@]}"; do
for i in "${!terraformModules[@]}"; do
@ -94,3 +95,10 @@ case ${mode} in
exit 1
;;
esac
}
if test -v SILENT; then
check > /dev/null
else
check
fi