#!/usr/bin/env bash # The real run behind the "reporting as code" video. Copies the Kestrel project from the # homepage (also served at www.bino.bi/showcase/files), runs every command the video shows # in a fresh git repo, and writes the output to session/. # ./session.sh [path/to/homepage/showcase] # Needs bino (0.104.0 was used), git, pdftoppm. set -uo pipefail cd "$(dirname "$0")" SRC="$(cd "${1:-../../homepage/showcase}" && pwd)" OUT="$PWD/session" WORK="$(mktemp -d)" trap 'rm -rf "$WORK"' EXIT rm -rf "$OUT"; mkdir -p "$OUT" unset REPORT_MONTH # fixed timestamps in the PDF, so two builds of the same files are byte-identical export SOURCE_DATE_EPOCH=1767225600 cd "$WORK" cp -R "$SRC"/{bino.toml,data,datasources,datasets,components,pages,reports,styles} . git init -q && git add . && git -c user.name=demo -c user.email=demo@example.com commit -qm "Kestrel report" bino version > "$OUT/version.txt" find . -path ./.git -prune -o -type f -print | sed 's|^\./||' | sort > "$OUT/tree.txt" # the files the video shows, as they were before the change mkdir -p "$OUT/files" cp datasources/kestrel.yaml datasets/region_ytd.yaml components/region_chart.yaml "$OUT/files/" head -n 13 data/kestrel_2025.csv > "$OUT/files/kestrel_2025.head.csv" # 0. lint bino lint --no-color > "$OUT/lint.txt" 2>&1 # 1. the first build bino build --artefact kestrel --no-color > "$OUT/build-1.txt" 2>&1 && shasum -a 256 dist/kestrel-2025.pdf > "$OUT/sha-1.txt" pdftoppm -png -r 110 dist/kestrel-2025.pdf "$OUT/page" # 2. the same files again: same bytes rm -rf dist bino build --artefact kestrel --no-color > "$OUT/build-again.txt" 2>&1 && shasum -a 256 dist/kestrel-2025.pdf > "$OUT/sha-2.txt" # 3. the question changes: against plan instead of last year sed -i.bak -e 's/chartTitle: Regions against last year/chartTitle: Regions against plan/' \ -e 's/scenarios: \[pp1, ac1\]/scenarios: [pl1, ac1]/' \ -e 's/variances: \[dac1_pp1_pos, drac1_pp1_pos\]/variances: [dac1_pl1_pos, drac1_pl1_pos]/' components/region_chart.yaml rm components/region_chart.yaml.bak git --no-pager diff --no-color > "$OUT/change.diff" bino build --artefact kestrel --no-color > "$OUT/build-2.txt" 2>&1 pdftoppm -png -r 110 -f 2 -l 2 -singlefile dist/kestrel-2025.pdf "$OUT/page-2-plan" git -c user.name=demo -c user.email=demo@example.com commit -qam "Compare regions against plan" git --no-pager log --format=%s --no-color > "$OUT/log.txt" # 4. one wrong letter in the SQL stops the build rm -rf dist sed -i.bak 's/SUM(revenue_pl)/SUM(revenue_pln)/' datasets/region_ytd.yaml && rm datasets/region_ytd.yaml.bak bino build --artefact kestrel --no-color > "$OUT/build-error.txt" 2>&1 echo "exit code $?" >> "$OUT/build-error.txt" ls dist 2>/dev/null | grep '\.pdf$' > "$OUT/build-error-pdfs.txt" grep -n 'revenue_pln' datasets/region_ytd.yaml > "$OUT/typo-line.txt" git checkout -q datasets ls "$OUT"