From ea49da9d39cf74c6e94fea9a8882d5d05eaf9be5 Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Wed, 26 Aug 2026 23:04:33 -0600 Subject: [PATCH 1/2] Fix CI lint script to lint all charts - lint_chart exited the whole script after the first chart, so only charts/sourcegraph was ever linted; migrator and executor were skipped - charts/sourcegraph-executor is a parent directory of two charts (k8s, dind), not a chart, so its lint line would have failed anyway - Lint each executor chart directly, with --set executor.queueName so the templates render instead of warning on empty metadata.name - Lint every chart even after a failure, report per-chart results, and exit with the first failing status Amp-Thread-ID: https://ampcode.com/threads/T-01a04192-5b1d-7040-9dc3-76f8d5a10ab0 Co-authored-by: Amp --- scripts/ci/lint.sh | 51 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/scripts/ci/lint.sh b/scripts/ci/lint.sh index bf72b289c..13a7d2771 100755 --- a/scripts/ci/lint.sh +++ b/scripts/ci/lint.sh @@ -4,20 +4,49 @@ set -euf -o pipefail ### Run the helm tests function lint_chart() { - echo "Linting chart $1" - LINT_OUTPUT=$(helm lint charts/$1) - ORG_STATUS=$? + local chart_path="$1" + local lint_output + local lint_status - printf "\n\n===== Lint Output =====\n$LINT_OUTPUT\n" + shift - LINT_OUTPUT_LOWER=$(echo "$LINT_OUTPUT" | awk '{print tolower($0)}') - if grep -q "warning" <<<"$LINT_OUTPUT_LOWER"; then - exit 255 + echo "Linting chart ${chart_path}" + if lint_output=$(helm lint "${chart_path}" "$@" 2>&1); then + lint_status=0 else - exit $ORG_STATUS + lint_status=$? fi + + printf "\n\n===== Lint Output: %s =====\n%s\n" "${chart_path}" "${lint_output}" + + if grep -qi "warning" <<<"${lint_output}"; then + printf "Helm lint emitted warnings for %s\n" "${chart_path}" >&2 + return 255 + fi + + return "${lint_status}" } -lint_chart "sourcegraph" -lint_chart "sourcegraph-migrator" -lint_chart "sourcegraph-executor" +function lint_and_record() { + local chart_status + + if lint_chart "$@"; then + return 0 + else + chart_status=$? + fi + + if [ "${exit_status}" -eq 0 ]; then + exit_status="${chart_status}" + 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}" From ecfad31187728da5c29106ac373f3f0266a3039f Mon Sep 17 00:00:00 2001 From: Michael Lin Date: Mon, 21 Sep 2026 16:10:16 -0700 Subject: [PATCH 2/2] Report hard lint failures even when another chart only warns (#944) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stacked on top of [#930](https://github.com/sourcegraph/deploy-sourcegraph-helm/pull/930) — targets `marc/fix-ci-lint-script`, so the diff here is only the follow-up fix. `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 (`.buildkite/pipeline.yaml`), 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. Now that the script lints all four charts instead of stopping at the first, that masking is reachable. This tracks warnings and hard failures separately so severity — not order — decides the exit status: - any chart that fails to lint exits with that status (build fails) - warnings alone still exit 255 (soft fail, unchanged) - a chart that both warns and fails is reported as a failure - a per-chart `Lint Summary` is printed so every chart's outcome is visible in the log ### Checklist - [x] Follow the [manual testing process](https://github.com/sourcegraph/deploy-sourcegraph-helm/blob/main/TEST.md) - [ ] Update [changelog](https://github.com/sourcegraph/deploy-sourcegraph-helm/blob/main/charts/sourcegraph/CHANGELOG.md) - [ ] Update [Kubernetes update doc](https://docs.sourcegraph.com/admin/updates/kubernetes) CI-only change, no chart templates or values touched, so no changelog or update-doc entry. ### Test plan Real run against all four charts with helm 3.16.3 — exits 0: ``` ===== Lint Summary ===== PASS charts/sourcegraph PASS charts/sourcegraph-migrator PASS charts/sourcegraph-executor/k8s PASS charts/sourcegraph-executor/dind ``` Failure modes exercised with a stub `helm` on `$PATH` that emits warnings / errors per chart: | scenario | before (PR #930 head) | after | | --- | --- | --- | | chart A warns, chart B fails | `255` → soft fail, **build green** | `1` → build fails | | chart A fails, chart B warns | `1` | `1` | | warnings only | `255` → soft fail | `255` → soft fail | | one chart both warns and fails | `255` → soft fail | `1` → build fails | | all clean | `0` | `0` | Summary output for the first (previously masked) case: ``` ===== Lint Summary ===== WARNING chart-warn FAIL chart-err (helm lint exited 1) One or more charts failed to lint ``` `bash -n scripts/ci/lint.sh` passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01PjWHybsdqCvNqGoYDRCdah --- _Generated by [Claude Code](https://claude.ai/code/session_01PjWHybsdqCvNqGoYDRCdah)_ Co-authored-by: Claude --- 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 13a7d2771..053d131ca 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