beffroi-reporting/scripts/check-components.sh

58 lines
2.4 KiB
Bash

#!/usr/bin/env bash
# Run the checks owned by the pinned components in separate environments.
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
command -v uv >/dev/null 2>&1 || {
echo 'uv is required to prepare isolated component test environments.' >&2
exit 1
}
for component in diagnostics reporter; do
if [[ ! -f "$component/requirements.txt" || ! -f "$component/tests/test_contract.py" ]]; then
echo "Missing $component checks. Run: git submodule update --init --recursive" >&2
exit 1
fi
done
command -v typst >/dev/null 2>&1 || {
echo 'Typst is required for Reportist rendering checks.' >&2
exit 1
}
typst --version
uv --version
for component in diagnostics reporter; do
echo "Checking $component ($(git -C "$component" rev-parse HEAD))"
environment=".venv/component-checks/$component"
uv venv --python 3.11 --allow-existing "$environment"
uv pip sync --python "$environment/bin/python" "$component/requirements.txt"
"$environment/bin/python" --version
"$environment/bin/python" -m unittest discover -s "$component/tests" -p 'test_*.py' -v
done
echo "Checking reports ($(git -C reports rev-parse HEAD))"
DIAGNOSTIC_VALIDATOR="$(pwd)/diagnostics/tools/validate.py" \
REPORT_VALIDATOR="$(pwd)/reporter/tools/validate.py" \
BRANDING="$(pwd)/reports/config/branding/default.json" \
BRANDING_ROOT="$(pwd)/reports" \
BRANDING_DIRECTORY="$(pwd)/reports/config/branding" \
.venv/component-checks/reporter/bin/python -m unittest discover \
-s reports/tests -p 'test_*.py' -v
pipeline_check_parent="$(mktemp -d "${TMPDIR:-/tmp}/beffroi-pipeline-check.XXXXXX")"
trap 'rm -rf -- "$pipeline_check_parent"' EXIT
pipeline_check_root="$pipeline_check_parent/run"
bash scripts/workflow.sh all \
diagnostics/tests/fixtures/legacy/windiagnostics-v1.json \
diagnostics/tests/fixtures/legacy \
"$pipeline_check_root" \
2026-09-15T12:00:00Z \
'Synthetic diagnostic draft' 'CI Test' 2026-09-15
.venv/component-checks/diagnostics/bin/python -c \
'import json,sys; d=json.load(open(sys.argv[1], encoding="utf-8")); assert d["findings"][0]["id"] == "event-service-control-manager-7000"; assert d["findings"][0]["evidence"] == ["event-recent_system_errors-1"]' \
"$pipeline_check_root/diagnostic.json"
test "$(head -c 5 "$pipeline_check_root/report.pdf")" = '%PDF-'
echo 'Raw-capture analysis, adapter, and PDF pipeline passed. Native collection and non-event health checks remain.'