refactor: expose renderer at repository root
Reportist CI All report validation and rendering checks passed.
Beffroi/reportist/pipeline/head This commit looks good Details

This commit is contained in:
Dandaedre 2026-09-16 02:13:26 +02:00
parent fe421e4ffa
commit d5ad5bb0e6
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
11 changed files with 15 additions and 15 deletions

2
Jenkinsfile vendored
View File

@ -12,7 +12,7 @@ pipeline {
}
stage('Test') {
steps { sh './test.sh' }
steps { sh './tests/test.sh' }
}
}

View File

@ -7,7 +7,7 @@ integration repository or diagnostic tools.
## Render one report
```bash
bash tools/render.sh examples/example-report.yaml --output report.pdf
./render.sh examples/example-report.yaml --output report.pdf
```
The renderer validates the input, loads an optional report-relative logo, and

View File

@ -6,11 +6,11 @@ authoring are documented in the main [README](../README.md) and
## Test environment
Tests require uv and Typst. `test.sh` creates `.venv` and synchronizes the pinned
Tests require uv and Typst. `tests/test.sh` creates `.venv` and synchronizes the pinned
packages from `requirements.txt`, and invokes Python only from that environment.
```bash
./test.sh
./tests/test.sh
```
Poppler's `pdfinfo` and `pdftotext` enable additional pagination and extracted

View File

@ -11,10 +11,10 @@ Typst and Bash are required at runtime. From this component checkout:
```bash
bash tools/validate.sh examples/example-report.yaml
bash tools/validate.sh examples/example-report.json
./test.sh
./tests/test.sh
```
`./test.sh` creates and synchronizes `.venv` with uv before invoking Python.
`./tests/test.sh` creates and synchronizes `.venv` with uv before invoking Python.
Python is not used by validation or rendering. Validation needs no sibling repositories and works
from any working directory using explicit paths. It writes no files. Exit codes:
0 valid, 1 invalid/unreadable input or missing dependencies, 2 CLI usage error.
@ -25,7 +25,7 @@ Errors identify the offending JSON path; unsupported file extensions are rejecte
After installing Typst:
```bash
bash tools/render.sh examples/example-report.yaml --output output/report.pdf
./render.sh examples/example-report.yaml --output output/report.pdf
```
Validation always runs before Typst. Relative branding assets resolve from the

View File

@ -2,7 +2,7 @@
# Render a Reportist v1 YAML/JSON document without a Python runtime.
set -euo pipefail
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
root=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)
usage() { echo "Usage: $0 INPUT [--output PDF] [--typst COMMAND] [--force]" >&2; exit 2; }
fail() { echo "error: $*" >&2; exit 1; }

View File

@ -1,5 +1,5 @@
# Pinned dependencies for the Python test oracle.
# Update versions here intentionally, then run ./test.sh.
# Update versions here intentionally, then run ./tests/test.sh.
attrs==26.1.0
# via
# jsonschema

View File

@ -5,7 +5,7 @@ import subprocess
ROOT = Path(__file__).resolve().parents[1]
def render(input_path, output_path, typst="typst", force=False):
command = ["bash", str(ROOT / "tools/render.sh"), str(input_path), "--output", str(output_path), "--typst", str(typst)]
command = ["bash", str(ROOT / "render.sh"), str(input_path), "--output", str(output_path), "--typst", str(typst)]
if force:
command.append("--force")
result = subprocess.run(command, text=True, capture_output=True)

View File

@ -11,7 +11,7 @@ try:
from jsonschema import Draft202012Validator, FormatChecker
import yaml
except ImportError:
raise SystemExit("Prepare test dependencies with: ./test.sh")
raise SystemExit("Prepare test dependencies with: ./tests/test.sh")
SCHEMA = json.loads((Path(__file__).resolve().parents[1] / "schema/report.schema.json").read_text())
Draft202012Validator.check_schema(SCHEMA)

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
cd "$(dirname "${BASH_SOURCE[0]}")/.."
uv venv --python 3.11 --allow-existing .venv
uv pip sync --python .venv/bin/python requirements.txt
.venv/bin/python -m unittest discover -s tests -p 'test_*.py' -v

View File

@ -93,7 +93,7 @@ class RenderTests(unittest.TestCase):
def test_cli_runs_outside_repository(self):
output = self.work / "outside-cwd.pdf"
result = subprocess.run([
"bash", str(ROOT / "tools" / "render.sh"),
"bash", str(ROOT / "render.sh"),
str(ROOT / "examples" / "minimal-report.json"), "--output", str(output),
], cwd=self.work, text=True, capture_output=True)
self.assertEqual(result.returncode, 0, result.stderr)
@ -133,7 +133,7 @@ class RenderTests(unittest.TestCase):
".git", ".ci-venv", "__pycache__", "*.pyc"))
output = self.work / "standalone.pdf"
result = subprocess.run([
"bash", str(standalone / "tools" / "render.sh"),
"bash", str(standalone / "render.sh"),
str(standalone / "examples" / "example-report.yaml"),
"--output", str(output), "--typst", TYPST,
], cwd=self.work, text=True, capture_output=True)

View File

@ -10,7 +10,7 @@ count=0
while IFS= read -r -d '' input; do
relative=${input#"$input_dir/"}; output="$output_dir/$relative.pdf"; mkdir -p "$(dirname "$output")"
arguments=(--output "$output"); [[ "$force" == false ]]||arguments+=(--force); [[ -z "$typst_command" ]]||arguments+=(--typst "$typst_command")
"$root/tools/render.sh" "$input" "${arguments[@]}"; ((count+=1))
"$root/render.sh" "$input" "${arguments[@]}"; ((count+=1))
done < <(find "$input_dir" -type f \( -name '*.json' -o -name '*.yaml' -o -name '*.yml' \) -print0 | sort -z)
((count > 0))||{ echo "$input_dir: no YAML or JSON reports found" >&2; exit 1; }
echo "Rendered $count reports into $output_dir"