diff --git a/README.md b/README.md index 3f17901..0c8b477 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,21 @@ commit them with the reports submodule update, and run: ./beffroi.sh all build/publication ``` +Converted Reportist JSON is temporary and removed after a successful build. +Use `--keep-intermediates` to retain it for troubleshooting: + +```bash +./beffroi.sh all build/publication --keep-intermediates +``` + +Use `--include-json` to place the structured report JSON beside report PDFs and +the original diagnostic JSON beside diagnostic PDFs. Packaging includes these +JSON files, which is useful for downstream automation: + +```bash +./beffroi.sh all build/publication --include-json +``` + Jenkins runs the same build and publishes AES-encrypted `Reports.zip` and `Diagnostics.zip` archives from `main` into the dedicated `work_reports` destination. @@ -53,7 +68,7 @@ destination. ./beffroi.sh report INPUT OUTPUT.pdf ./beffroi.sh diagnostic-pdf CAPTURE OUTPUT.pdf ./beffroi.sh diagnostic CAPTURE EVIDENCE_ROOT OUTPUT_DIR REFERENCE_TIME TITLE AUTHOR DATE -./beffroi.sh all NEW_OUTPUT_DIR +./beffroi.sh all NEW_OUTPUT_DIR [--keep-intermediates] [--include-json] ./beffroi.sh package BUILD_DIR ARTIFACT_DIR ./beffroi.sh test ./beffroi.sh bootstrap diff --git a/beffroi.sh b/beffroi.sh index 0b537fe..a765a6c 100755 --- a/beffroi.sh +++ b/beffroi.sh @@ -8,7 +8,7 @@ Usage: ./beffroi.sh report INPUT OUTPUT.pdf ./beffroi.sh diagnostic-pdf CAPTURE OUTPUT.pdf ./beffroi.sh diagnostic CAPTURE EVIDENCE_ROOT OUTPUT_DIR REFERENCE_TIME TITLE AUTHOR DATE - ./beffroi.sh all NEW_OUTPUT_DIR + ./beffroi.sh all NEW_OUTPUT_DIR [--keep-intermediates] [--include-json] ./beffroi.sh package BUILD_DIR ARTIFACT_DIR ./beffroi.sh test ./beffroi.sh bootstrap @@ -41,8 +41,8 @@ case "$command_name" in scripts/workflow.sh all "$@" ;; all) - [[ $# -eq 1 ]]||usage 2; require git typst - scripts/build-publication.sh "$1" + (($# >= 1))||usage 2; require git typst + scripts/build-publication.sh "$@" ;; package) [[ $# -eq 2 ]]||usage 2; require uv diff --git a/scripts/build-publication.sh b/scripts/build-publication.sh index 65351d1..9f17124 100755 --- a/scripts/build-publication.sh +++ b/scripts/build-publication.sh @@ -1,15 +1,51 @@ #!/usr/bin/env bash set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")/.." +usage() { + echo "Usage: $0 NEW_OUTPUT_ROOT [--keep-intermediates] [--include-json]" >&2 + exit 2 +} + output_root=${1:-} -[[ -n "$output_root" && $# -eq 1 ]]||{ echo "Usage: $0 NEW_OUTPUT_ROOT" >&2; exit 2; } +[[ -n "$output_root" ]] || usage +shift + +keep_intermediates=false +include_json=false +while (($#)); do + case $1 in + --keep-intermediates) keep_intermediates=true ;; + --include-json) include_json=true ;; + *) usage ;; + esac + shift +done + [[ ! -e "$output_root" ]]||{ echo "$output_root: output root already exists" >&2; exit 1; } mkdir -p "$output_root/reports" "$output_root/diagnostics" -reports/tools/convert-legacy-reports.sh reports/reports "$output_root/reports/sources" -reporter/tools/validate-all.sh "$output_root/reports/sources" -reporter/tools/render-all.sh "$output_root/reports/sources" --output-dir "$output_root/reports/pdfs" + +if [[ "$keep_intermediates" == true ]]; then + intermediate_dir=$output_root/reports/intermediates +else + intermediate_dir=$(mktemp -d "${TMPDIR:-/tmp}/beffroi-report-sources.XXXXXXXX") + trap 'rm -rf "$intermediate_dir"' EXIT +fi + +reports/tools/convert-legacy-reports.sh reports/reports "$intermediate_dir" +reporter/tools/validate-all.sh "$intermediate_dir" +reporter/tools/render-all.sh "$intermediate_dir" --output-dir "$output_root/reports/pdfs" reporter/render-diagnostics.sh reports/diagnostics \ --output-dir "$output_root/diagnostics" \ --author "${DIAGNOSTICS_AUTHOR:-Beffroi}" \ --logo reports/assets/beffroi.png + +if [[ "$include_json" == true ]]; then + cp -R "$intermediate_dir/." "$output_root/reports/pdfs/" + while IFS= read -r -d '' source; do + relative=${source#reports/diagnostics/} + mkdir -p "$output_root/diagnostics/$(dirname "$relative")" + cp "$source" "$output_root/diagnostics/$relative" + done < <(find reports/diagnostics -type f -name '*.json' -print0) +fi + echo "Built publishable reports under $output_root" diff --git a/scripts/check-components.sh b/scripts/check-components.sh index 4439d8e..a138f2b 100755 --- a/scripts/check-components.sh +++ b/scripts/check-components.sh @@ -52,8 +52,9 @@ bash scripts/workflow.sh all \ 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" '' --field value --one >/dev/null +typst eval --root "$pipeline_check_root" --input diagnostic=diagnostic.json \ + --in "$pipeline_check_root/check-diagnostic.typ" \ + 'query().first().value' >/dev/null test "$(head -c 5 "$pipeline_check_root/report.pdf")" = '%PDF-' echo 'Component suites and the raw-capture-to-PDF integration pipeline passed.' diff --git a/scripts/package-reports.sh b/scripts/package-reports.sh index 67bdca4..b611a36 100755 --- a/scripts/package-reports.sh +++ b/scripts/package-reports.sh @@ -25,6 +25,7 @@ for category in ("Reports", "Diagnostics"): source_dir = build_root / category.lower() pdfs = sorted(path for path in source_dir.rglob("*.pdf") if path.is_file()) + jsons = sorted(path for path in source_dir.rglob("*.json") if path.is_file()) if not pdfs: raise SystemExit(f"No PDFs for {category}") for pdf in pdfs: @@ -37,8 +38,8 @@ for category in ("Reports", "Diagnostics"): ) as output: output.setpassword(password) output.setencryption(pyzipper.WZ_AES, nbits=256) - for pdf in pdfs: - output.write(pdf, pdf.relative_to(source_dir)) + for member in sorted(pdfs + jsons): + output.write(member, member.relative_to(source_dir)) with pyzipper.AESZipFile(archive) as check: check.setpassword(password)