From fa12d14e5b7b517e14912c654593604ad91b7e31 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 16 Sep 2026 23:40:25 +0000 Subject: [PATCH] Report hard lint failures even when another chart only warns lint_and_record kept the first non-zero status it saw. A warning returns 255, and the Buildkite lint step soft-fails on exit 255, so a warning in an earlier chart downgraded a genuine lint failure in a later chart into a soft fail and the build went green. Track warnings and hard failures separately so severity, not order, decides the exit status: any chart that fails to lint exits with that status, warnings alone still exit 255, and a chart that both warns and fails is reported as a failure. Add a per-chart summary so every chart's outcome is visible in the CI log. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01PjWHybsdqCvNqGoYDRCdah --- scripts/ci/lint.sh | 51 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/scripts/ci/lint.sh b/scripts/ci/lint.sh index 13a7d277..053d131c 100755 --- a/scripts/ci/lint.sh +++ b/scripts/ci/lint.sh @@ -2,6 +2,18 @@ set -euf -o pipefail +# Exit status used to signal "lint succeeded but emitted warnings". The Buildkite +# lint step soft-fails on this status, so it must never be used to report a chart +# that actually failed to lint. +WARNING_EXIT_STATUS=255 + +# Highest-severity outcome seen so far. A hard lint failure always wins over a +# warning, so a warning in an earlier chart can never downgrade a later failure +# into a soft fail. +hard_status=0 +warned=0 +results=() + ### Run the helm tests function lint_chart() { local chart_path="$1" @@ -19,34 +31,61 @@ function lint_chart() { printf "\n\n===== Lint Output: %s =====\n%s\n" "${chart_path}" "${lint_output}" + # A chart that failed to lint is reported as a failure even if it also emitted + # warnings, otherwise the failure would be masked by the soft-failed status. + if [ "${lint_status}" -ne 0 ]; then + printf "Helm lint failed for %s\n" "${chart_path}" >&2 + return "${lint_status}" + fi + if grep -qi "warning" <<<"${lint_output}"; then printf "Helm lint emitted warnings for %s\n" "${chart_path}" >&2 - return 255 + return "${WARNING_EXIT_STATUS}" fi - return "${lint_status}" + return 0 } function lint_and_record() { + local chart_path="$1" local chart_status if lint_chart "$@"; then + results+=("PASS ${chart_path}") return 0 else chart_status=$? fi - if [ "${exit_status}" -eq 0 ]; then - exit_status="${chart_status}" + if [ "${chart_status}" -eq "${WARNING_EXIT_STATUS}" ]; then + warned=1 + results+=("WARNING ${chart_path}") + else + results+=("FAIL ${chart_path} (helm lint exited ${chart_status})") + if [ "${hard_status}" -eq 0 ]; then + hard_status="${chart_status}" + fi fi return 0 } -exit_status=0 lint_and_record "charts/sourcegraph" lint_and_record "charts/sourcegraph-migrator" lint_and_record "charts/sourcegraph-executor/k8s" --set "executor.queueName=batches" lint_and_record "charts/sourcegraph-executor/dind" --set "executor.queueName=batches" -exit "${exit_status}" +printf "\n\n===== Lint Summary =====\n" +printf "%s\n" "${results[@]}" + +if [ "${hard_status}" -ne 0 ]; then + printf "\nOne or more charts failed to lint\n" >&2 + exit "${hard_status}" +fi + +if [ "${warned}" -ne 0 ]; then + printf "\nOne or more charts emitted lint warnings\n" >&2 + exit "${WARNING_EXIT_STATUS}" +fi + +exit 0