Merge pull request #118404 from pohly/verify-failures
better JUnit failure messages for golangci-lint and verify in general
This commit is contained in:
@@ -127,10 +127,10 @@ function run-cmd {
|
||||
local tr
|
||||
|
||||
if ${SILENT}; then
|
||||
juLog -output="${output}" -class="verify" -name="${testname}" "$@" &> /dev/null
|
||||
juLog -output="${output}" -class="verify" -name="${testname}" -fail="^ERROR: " "$@" &> /dev/null
|
||||
tr=$?
|
||||
else
|
||||
juLog -output="${output}" -class="verify" -name="${testname}" "$@"
|
||||
juLog -output="${output}" -class="verify" -name="${testname}" -fail="^ERROR: " "$@"
|
||||
tr=$?
|
||||
fi
|
||||
return ${tr}
|
||||
|
@@ -18,7 +18,6 @@
|
||||
# golangci-lint. It does nothing when invoked as part of a normal "make
|
||||
# verify".
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
@@ -29,9 +28,12 @@ fi
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
|
||||
# include shell2junit library
|
||||
source "${KUBE_ROOT}/third_party/forked/shell2junit/sh2ju.sh"
|
||||
|
||||
# TODO (https://github.com/kubernetes/test-infra/issues/17056):
|
||||
# take this additional artifact and convert it to GitHub annotations
|
||||
# to make it easier to see these problems during a PR review.
|
||||
#
|
||||
# -g "${ARTIFACTS}/golangci-lint-githubactions.log"
|
||||
"${KUBE_ROOT}/hack/verify-golangci-lint.sh" -r "${PULL_BASE_SHA}" -s
|
||||
juLog -output="${ARTIFACTS:-/tmp/results}" -class="golangci" -name="golangci-strict-pr" -fail="^ERROR: " "${KUBE_ROOT}/hack/verify-golangci-lint.sh" -r "${PULL_BASE_SHA}" -s
|
||||
|
@@ -97,6 +97,19 @@ if [ "${golangci_config}" ]; then
|
||||
golangci+=(--config="${golangci_config}")
|
||||
fi
|
||||
|
||||
# Below the output of golangci-lint is going to be piped into sed to add
|
||||
# a prefix to each output line. This helps make the output more visible
|
||||
# in the Prow log viewer ("error" is a key word there) and ensures that
|
||||
# only those lines get included as failure message in a JUnit file
|
||||
# by "make verify".
|
||||
#
|
||||
# The downside is that the automatic detection whether to colorize output
|
||||
# doesn't work anymore, so here we force it ourselves when connected to
|
||||
# a tty.
|
||||
if tty -s; then
|
||||
golangci+=(--color=always)
|
||||
fi
|
||||
|
||||
if [ "$base" ]; then
|
||||
# Must be a something that git can resolve to a commit.
|
||||
# "git rev-parse --verify" checks that and prints a detailed
|
||||
@@ -139,15 +152,15 @@ res=0
|
||||
run () {
|
||||
if [[ "${#targets[@]}" -gt 0 ]]; then
|
||||
echo "running ${golangci[*]} ${targets[*]}" >&2
|
||||
"${golangci[@]}" "${targets[@]}" >&2 || res=$?
|
||||
"${golangci[@]}" "${targets[@]}" 2>&1 | sed -e 's;^;ERROR: ;' >&2 || res=$?
|
||||
else
|
||||
echo "running ${golangci[*]} ./..." >&2
|
||||
"${golangci[@]}" ./... >&2 || res=$?
|
||||
"${golangci[@]}" ./... 2>&1 | sed -e 's;^;ERROR: ;' >&2 || res=$?
|
||||
for d in staging/src/k8s.io/*; do
|
||||
MODPATH="staging/src/k8s.io/$(basename "${d}")"
|
||||
echo "running ( cd ${KUBE_ROOT}/${MODPATH}; ${golangci[*]} --path-prefix ${MODPATH} ./... )"
|
||||
pushd "${KUBE_ROOT}/${MODPATH}" >/dev/null
|
||||
"${golangci[@]}" --path-prefix "${MODPATH}" ./... >&2 || res=$?
|
||||
"${golangci[@]}" --path-prefix "${MODPATH}" ./... 2>&1 | sed -e 's;^;ERROR: ;' >&2 || res=$?
|
||||
popd >/dev/null
|
||||
done
|
||||
fi
|
||||
|
Reference in New Issue
Block a user