mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-11-13 00:50:38 -05:00
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:
parent
7a1c70d7e5
commit
c1f9d86cd3
4 changed files with 170 additions and 136 deletions
|
|
@ -27,22 +27,31 @@ excludeMods=(
|
|||
"hack/tools"
|
||||
)
|
||||
|
||||
echo "The following Go modules are excluded and won't be linted with golangci-lint:"
|
||||
for exclude in "${excludeMods[@]}"; do
|
||||
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
|
||||
if [[ ${modules[i]} == "${BUILD_WORKSPACE_DIRECTORY}/${exclude}" ]]; then
|
||||
echo " ${modules[i]}"
|
||||
unset 'modules[i]'
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
statuscode=0
|
||||
statuscode=0
|
||||
|
||||
echo "Linting the following Go modules with golangci-lint:"
|
||||
for mod in "${modules[@]}"; do
|
||||
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=$?
|
||||
done
|
||||
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}"
|
||||
exit "${statuscode}"
|
||||
}
|
||||
|
||||
if test -v SILENT; then
|
||||
check > /dev/null
|
||||
else
|
||||
check
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -27,15 +27,12 @@ not_allowed() {
|
|||
err=1
|
||||
}
|
||||
|
||||
${go} mod download
|
||||
|
||||
err=0
|
||||
|
||||
PATH="$(dirname "${go}"):${PATH}" \
|
||||
GOROOT=$(${go} env GOROOT) \
|
||||
GOPATH=$(${go} env GOPATH) \
|
||||
GOCACHE=$(${go} env GOCACHE) \
|
||||
${golicenses} csv ./... | {
|
||||
license_report() {
|
||||
PATH="$(dirname "${go}"):${PATH}" \
|
||||
GOROOT=$(${go} env GOROOT) \
|
||||
GOPATH=$(${go} env GOPATH) \
|
||||
GOCACHE=$(${go} env GOCACHE) \
|
||||
${golicenses} report ./... | {
|
||||
while read -r line; do
|
||||
|
||||
pkg=${line%%,*}
|
||||
|
|
@ -88,4 +85,15 @@ 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
|
||||
|
|
|
|||
|
|
@ -24,10 +24,11 @@ submodules=$(${go} list -f '{{.Dir}}' -m)
|
|||
|
||||
PATH=$(dirname "${go}"):${PATH}
|
||||
|
||||
err=0
|
||||
check() {
|
||||
err=0
|
||||
|
||||
echo "Scanning Go vulnerability DB for knwon vulnerabilities in modules:"
|
||||
for mod in ${submodules}; do
|
||||
echo "Scanning Go vulnerability DB for knwon vulnerabilities in modules:"
|
||||
for mod in ${submodules}; do
|
||||
echo " ${mod}"
|
||||
echo -n " "
|
||||
CGO_ENABLED=0 ${govulncheck} "${mod}/..." |
|
||||
|
|
@ -36,6 +37,14 @@ for mod in ${submodules}; do
|
|||
sed s/" your code and"// &&
|
||||
printf "\n" ||
|
||||
err=$?
|
||||
done
|
||||
done
|
||||
|
||||
exit "${err}"
|
||||
exit "${err}"
|
||||
|
||||
}
|
||||
|
||||
if test -v SILENT; then
|
||||
check > /dev/null
|
||||
else
|
||||
check
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -39,18 +39,19 @@ excludeDirs=(
|
|||
"build"
|
||||
)
|
||||
|
||||
echo "The following Terraform modules are excluded and won't be tidied:"
|
||||
for exclude in "${excludeDirs[@]}"; do
|
||||
check() {
|
||||
echo "The following Terraform modules are excluded and won't be tidied:"
|
||||
for exclude in "${excludeDirs[@]}"; do
|
||||
for i in "${!terraformModules[@]}"; do
|
||||
if [[ ${terraformModules[i]} == "${BUILD_WORKSPACE_DIRECTORY}/${exclude}"* ]]; then
|
||||
echo " ${terraformModules[i]}"
|
||||
unset 'terraformModules[i]'
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
case ${mode} in
|
||||
"check")
|
||||
case ${mode} in
|
||||
"check")
|
||||
echo "Checking validity and format of the following Terraform modules:"
|
||||
for script in "${terraformModules[@]}"; do
|
||||
echo " ${script}"
|
||||
|
|
@ -64,7 +65,7 @@ case ${mode} in
|
|||
done
|
||||
;;
|
||||
|
||||
"format")
|
||||
"format")
|
||||
echo "Formatting the following Terraform modules:"
|
||||
for module in "${terraformModules[@]}"; do
|
||||
echo " ${module}"
|
||||
|
|
@ -72,7 +73,7 @@ case ${mode} in
|
|||
done
|
||||
;;
|
||||
|
||||
"generate")
|
||||
"generate")
|
||||
echo "Formatting and generating lock files for the following Terraform modules:"
|
||||
for script in "${terraformModules[@]}"; do
|
||||
echo " ${script}"
|
||||
|
|
@ -89,8 +90,15 @@ case ${mode} in
|
|||
done
|
||||
;;
|
||||
|
||||
*)
|
||||
*)
|
||||
echo "Error: unknown mode \"${mode}\""
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
}
|
||||
|
||||
if test -v SILENT; then
|
||||
check > /dev/null
|
||||
else
|
||||
check
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue