beffroi-reporting/scripts/check-components.sh

53 lines
2.0 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 reports; do
if [[ ! -f "$component/requirements.txt" || ! -d "$component/tests" || ! -f "$component/Makefile" ]]; 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))"
make -C "$component" test
done
echo "Checking reports ($(git -C reports rev-parse HEAD))"
DIAGNOSTIC_VALIDATOR="$(pwd)/diagnostics/tools/validate.sh" \
REPORT_VALIDATOR="$(pwd)/reporter/tools/validate.sh" \
BRANDING="$(pwd)/reports/config/branding/default.json" \
BRANDING_ROOT="$(pwd)/reports" \
BRANDING_DIRECTORY="$(pwd)/reports/config/branding" \
make -C reports test
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
cp scripts/check-diagnostic.typ "$pipeline_check_root/check-diagnostic.typ"
typst query --root "$pipeline_check_root" --input diagnostic=diagnostic.json \
"$pipeline_check_root/check-diagnostic.typ" '<valid>' --field value --one >/dev/null
test "$(head -c 5 "$pipeline_check_root/report.pdf")" = '%PDF-'
echo 'Component suites and the raw-capture-to-PDF integration pipeline passed.'