Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/scripts/ci/run-quality-groups.sh
T

95 lines
2.5 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd -- "$SCRIPT_DIR/../.." && pwd)"
cd "$REPO_ROOT"
if [[ ! -f package.json || ! -d apps || ! -d packages || ! -d prisma ]]; then
echo "[quality-groups] repository workspace is incomplete" >&2
exit 1
fi
# Web typechecking normally generates the tracked Prisma client. Complete that
# single writer before any Vitest reader starts, then run the remaining
# typecheck commands explicitly inside the parallel group below.
echo "[quality-groups] PREPARE prisma-client"
pnpm run db:generate
echo "[quality-groups] READY prisma-client"
run_typecheck_lint() {
pnpm --filter @hivegrid/portal-domain-controller typecheck
pnpm --filter @hivegrid/web typegen
(
cd apps/web
node ../../scripts/typecheck-web.mjs
)
pnpm lint
}
run_foundation_packages() {
# The CI host also builds six Docker targets in parallel. Bound both the
# Vitest pool and pnpm's recursive package fan-out so this job cannot starve
# BuildKit (or push the shared runner back into swap) while retaining the
# three-way overlap with typecheck/lint and the core suite.
pnpm run test:foundation --maxWorkers=2
PNPM_CONFIG_WORKSPACE_CONCURRENCY=2 pnpm run test:packages --maxWorkers=1
}
run_core_tests() {
pnpm run test --maxWorkers=4
}
declare -a QUALITY_GROUP_NAMES=()
declare -a QUALITY_GROUP_PIDS=()
start_group() {
local name="$1"
local function_name="$2"
(
set -euo pipefail
echo "[quality-groups] START $name"
"$function_name"
) &
QUALITY_GROUP_NAMES+=("$name")
QUALITY_GROUP_PIDS+=("$!")
}
terminate_groups() {
trap - HUP INT TERM
for pid in "${QUALITY_GROUP_PIDS[@]:-}"; do
kill -TERM "$pid" 2>/dev/null || true
done
for pid in "${QUALITY_GROUP_PIDS[@]:-}"; do
wait "$pid" 2>/dev/null || true
done
echo "[quality-groups] interrupted; child groups terminated" >&2
exit 130
}
trap terminate_groups HUP INT TERM
start_group "typecheck-lint" run_typecheck_lint
start_group "foundation-packages" run_foundation_packages
start_group "core-tests" run_core_tests
QUALITY_FAILED=0
for index in "${!QUALITY_GROUP_PIDS[@]}"; do
name="${QUALITY_GROUP_NAMES[$index]}"
pid="${QUALITY_GROUP_PIDS[$index]}"
if wait "$pid"; then
echo "[quality-groups] PASS $name"
else
status=$?
echo "[quality-groups] FAIL $name (exit $status)" >&2
QUALITY_FAILED=1
fi
done
if [[ "$QUALITY_FAILED" -ne 0 ]]; then
echo "[quality-groups] one or more groups failed" >&2
exit "$QUALITY_FAILED"
fi
echo "[quality-groups] PASS all groups"