Files
solvecraft/scripts/fetch-solids.sh
T
bherbruck 543289917c site: track solids (primitives built/passing), corpus placeholder
The primitives example takes --json <path> and records per shape whether it
built, the blocker (unit + upstream symbol), and each check (manifold, Euler,
counts, volume, area, bbox) with expected/actual/rel. error. The checks run
independently (evaluate); check() keeps its first-failure messages, and the
human-readable output is unchanged.

CI's test job runs it and, on pushes to main, uploads solids-report;
scripts/fetch-solids.sh fetches it with fetch-reports.sh's provenance rule
and the Pages build uses it. New Solids page (headline count, table of
primitives with checks and blockers, Corpus (real models) placeholder) and an
overview tile; both say "no data yet" without the report.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-22 22:55:47 -04:00

46 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Fetches the solids report (reports/solids/solids.json) of main's latest CI run.
#
# The report is the primitives example's --json output (crates/solidcore/examples/
# primitives); it is not committed: the CI test job on every push to main uploads it as
# the artifact `solids-report`. This downloads the newest one, taken only from a push run
# of this repo's own .github/workflows/ci.yml on main (same provenance rule as
# scripts/fetch-reports.sh), into reports/solids/. Exits 1 if none is available; the site
# then shows "no data yet". Needs `gh` with read access to Actions (GH_TOKEN in CI).
# Locally: cargo run -p solidcore --example primitives -- --json reports/solids/solids.json
#
# scripts/fetch-solids.sh [DEST] # DEST defaults to reports/solids
set -euo pipefail
root=$(git rev-parse --show-toplevel)
dest=${1:-$root/reports/solids}
repo=${GITHUB_REPOSITORY:-tangency-labs/solidcore}
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
command -v gh >/dev/null || { echo "fetch-solids: gh not found" >&2; exit 1; }
# Trust only push runs of this repo's own .github/workflows/ci.yml on main. Never
# select by branch name alone: a fork PR can name its branch "main" too.
runs=$(gh api "repos/$repo/actions/workflows/ci.yml/runs?branch=main&event=push&per_page=20" \
-q ".workflow_runs[]
| select(.event == \"push\" and .path == \".github/workflows/ci.yml\"
and .head_branch == \"main\"
and .repository.full_name == \"$repo\"
and .head_repository.full_name == \"$repo\")
| .id" 2>/dev/null | head -n 10 || true)
for id in $runs; do
art=$(gh api "repos/$repo/actions/runs/$id/artifacts?name=solids-report" \
-q '.artifacts[] | select(.expired | not) | .id' 2>/dev/null | head -n 1 || true)
[ -n "$art" ] || continue
if gh run download "$id" -R "$repo" -n solids-report -D "$tmp/run" >/dev/null 2>&1 \
&& [ -s "$tmp/run/solids.json" ]; then
mkdir -p "$dest"
mv "$tmp/run/solids.json" "$dest/solids.json"
echo "fetch-solids: solids.json -> ${dest#"$root"/} (CI run $id)"
exit 0
fi
rm -rf "$tmp/run"
done
echo "fetch-solids: no solids-report artifact from main's CI" >&2
exit 1