Files
Waleed 003c3527b1 improvement(ci): run affected suites and reuse production builds (#9297)
* improvement(ci): reuse E2E builds and rebalance integration runners

* improvement(ci): use free integration runners and shard browser viewports

* improvement(ci): share production builds across HTTP and Electron suites

* improvement(ci): select affected task groups with Turborepo

* improvement(ci): scope type checks and right-size hosted runners

* improvement(ci): partition macOS desktop smoke coverage

* fix(ci): retain integration coverage for shared UI and harness changes

* fix(ci): preserve landing dependencies and favor integration latency

* docs(ci): clarify paired provider benchmark count

* ci: retain free GitHub integration runners

* docs(ci): clarify push and manual check selection

* fix(ci): preserve hosted SCIM entitlement coverage
2026-10-22 11:05:50 -07:00

46 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# The `ci` job's verdict: the single required check, so it must never pass a run whose checks did
# not all pass. Reads the job's `needs` context (`toJSON(needs)`) from $NEEDS and exits non-zero,
# naming each offending job, unless every job succeeded or was skipped as `changes` intended.
#
# A skip passes only for a gated job whose `changes` flag is exactly `false`:
#
# Each job maps to its own explicit selection flag below. No inferred skip is accepted.
#
# Every other skip fails: an ungated job (lint, `changes` itself), a gated job whose flag is
# `true`, missing, or anything else (a failed or skipped `changes` leaves no outputs). A failure
# or a cancellation always fails.
#
# Usage: NEEDS='<toJSON(needs)>' ci-gate.sh
set -euo pipefail
needs=${NEEDS:-}
if ! jq -e 'type == "object"' <<< "$needs" > /dev/null 2>&1; then
echo "::error::The needs context is not a JSON object: '$needs'"
exit 1
fi
failed="$(jq -r '
{"integration": "integration", "e2e": "http", "e2e-build": "e2e_build", "e2e-production": "production", "test": "test",
"test-types": "test_app", "build": "build", "desktop-live": "desktop_live"} as $gate
| . as $needs
| (($gate | keys) + ["changes", "lint"]) as $required
| ($required - keys) as $missing
| if ($missing | length) > 0 then
$missing[] | "\(.): missing"
else
$needs
| (.changes.outputs // {}) as $flags
| to_entries[]
| select(.value.result != "success")
| select(.value.result != "skipped" or $gate[.key] == null or $flags[$gate[.key]] != "false")
| "\(.key): \(.value.result)"
end
' <<< "$needs")"
if [ -n "$failed" ]; then
echo "::error::Checks did not pass:"
echo "$failed"
exit 1
fi
echo "All checks passed."