From 515b25189ffce456f749bbe8db71c687623ef46d Mon Sep 17 00:00:00 2001 From: tr00d Date: Thu, 3 Dec 2026 08:40:43 +0100 Subject: [PATCH 1/2] ci(quality-gate): say what stopped the gate when it exits without a report A bug in the gate made it exit with no output at all, and finding the cause took a debugging round. An EXIT trap now prints the command that failed and the last stage the gate reported. Usage and environment errors go through die and stay as they were. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/build-and-test.yml | 3 + scripts/quality-gate/README.md | 5 +- .../fixtures-unexpected-exit/run.sh | 85 +++++++++++++++++++ scripts/quality-gate/gate.sh | 13 +-- scripts/quality-gate/lib/common.sh | 24 ++++-- 5 files changed, 118 insertions(+), 12 deletions(-) create mode 100755 scripts/quality-gate/fixtures-unexpected-exit/run.sh diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e121d96b..6a42e11d 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -270,6 +270,9 @@ jobs: - name: Identify-changes tests run: ./scripts/quality-gate/fixtures-identify-changes/run.sh + - name: Unexpected-exit tests + run: ./scripts/quality-gate/fixtures-unexpected-exit/run.sh + - name: Mark-API-shipped tests run: ./scripts/quality-gate/fixtures-mark-api/run.sh diff --git a/scripts/quality-gate/README.md b/scripts/quality-gate/README.md index 2009009b..611a5bf1 100644 --- a/scripts/quality-gate/README.md +++ b/scripts/quality-gate/README.md @@ -47,7 +47,7 @@ Unit tests are the `Unit` and `Contract` categories. Packing also validates each | `--bypass-format` | stage 1b without failing | | `--overwrite-baseline` | also saves lower warning counts to the baseline | -Exit codes: 0 pass, 1 fail, 2 incomplete, 3 usage or environment error. The report is `/.gate/report.json`, with logs in `/.gate/logs/`. A failed build lists its errors; in CI, a failed gate job keeps `.gate/` as an artifact. +Exit codes: 0 pass, 1 fail, 2 incomplete, 3 usage or environment error. Any other stop is a bug in the gate: it prints the command that failed and writes no report. The report is `/.gate/report.json`, with logs in `/.gate/logs/`. A failed build lists its errors; in CI, a failed gate job keeps `.gate/` as an artifact. ## Configuration @@ -65,7 +65,7 @@ An intended API break is accepted with the `CompatibilitySuppressions.xml` from | `build-and-test.yml` | Gate (unit) | `--unit`; on a PR, compares coverage with master's; on master, saves coverage and the packages to release | | `build-and-test.yml` | Gate (E2E) | starts a local Supabase while building, then `--e2e` | | `build-and-test.yml` | Waiting for the test suite to finish | passes when both parts pass; the check to require | -| `build-and-test.yml` | Quality gate tests | the five test suites below, when `scripts/quality-gate/` changes | +| `build-and-test.yml` | Quality gate tests | the six test suites below, when `scripts/quality-gate/` changes | | `mutation.yml` | Mutation testing | Stryker on changed files, then `--mutation` | | `release.yml` | Publish tested packages | pushes the packages the gate built for the released commit | @@ -79,6 +79,7 @@ An intended API break is accepted with the `CompatibilitySuppressions.xml` from ./scripts/quality-gate/fixtures-compare-baselines/run.sh ./scripts/quality-gate/fixtures-compare-coverage/run.sh ./scripts/quality-gate/fixtures-identify-changes/run.sh +./scripts/quality-gate/fixtures-unexpected-exit/run.sh ./scripts/quality-gate/fixtures-mark-api/run.sh ``` diff --git a/scripts/quality-gate/fixtures-unexpected-exit/run.sh b/scripts/quality-gate/fixtures-unexpected-exit/run.sh new file mode 100755 index 00000000..8f0a0bdd --- /dev/null +++ b/scripts/quality-gate/fixtures-unexpected-exit/run.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +set -uo pipefail + +HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +LIB="$HERE/../lib" +GATE="$HERE/../gate.sh" +RUNROOT="${FIXTURE_RUNROOT:-${TMPDIR:-/tmp}/unexpected-exit-tests.$$}" + +if [[ -t 1 && -z "${NO_COLOR:-}" ]]; then + RED=$'\033[31m'; GRN=$'\033[32m'; DIM=$'\033[2m'; BLD=$'\033[1m'; OFF=$'\033[0m' +else RED=""; GRN=""; DIM=""; BLD=""; OFF=""; fi + +mkdir -p "$RUNROOT" +trap '[[ -n "${FIXTURE_KEEP:-}" ]] || rm -rf "$RUNROOT"' EXIT + +PASS=0; FAIL=0 + +script() { + cat <