#!/bin/sh # hack/seed/run.sh # # Runs the two seed exporters inside a scratch rastrillo worktree at # the seed commit and writes their output into this checkout: the examples, the # manifest, the fixtures, the language files and the datetime tables. # Fiesta never imports rastrillo, so the exporters live under # hack/seed/_rastrillo/ (the leading _ keeps Go's tools out) and are # copied into the worktree for the run. # # The worktree goes under $TMPDIR, which must be set: this runs on a # shared machine, and /tmp is not scratch there. A worktree already at # that path belongs to another run and is left alone. Once this run # has made its own, the trap removes it and the two copied files # whether the run passed, failed or was interrupted. # # FIESTA_SEED_DRYRUN=1 hack/seed/run.sh ~/src/rastrillo e14b745a7c08d0efa3bf221a8b6a5e75de15c46f # # writes nothing and prints the state labels that need copy review. set -eu if [ $# -ne 2 ]; then echo "usage: $0 " >&2 exit 2 fi if [ -z "${TMPDIR:-}" ]; then echo "run.sh: TMPDIR is unset; set it to scratch space on disk, not /tmp" >&2 exit 2 fi checkout=$1 seed=$2 here=$(cd "$(dirname "$0")" && pwd) fiesta=$(cd "$here/../.." && pwd) wt="$TMPDIR/rastrillo-seed" if [ -e "$wt" ]; then echo "run.sh: $wt already exists; another run may be using it. Remove it by hand if not." >&2 exit 1 fi # cleanup runs from the EXIT trap, installed only once the worktree # below is ours. It keeps the run's own exit status, and a worktree # that could not be removed is reported and makes the run fail rather # than being hidden; prune runs either way. cleanup() { status=$? rm -f "$wt/internal/designsystem/designsystem_fiestaseed_test.go" "$wt/ui/ui_fiestaseed_test.go" if ! git -C "$checkout" worktree remove --force "$wt"; then echo "run.sh: could not remove the scratch worktree $wt; remove it by hand" >&2 if [ "$status" -eq 0 ]; then status=1 fi fi git -C "$checkout" worktree prune exit "$status" } git -C "$checkout" worktree add --detach "$wt" "$seed" trap cleanup EXIT # A signal exits, and the EXIT trap then cleans up. trap 'exit 130' INT TERM cp "$here/_rastrillo/designsystem_fiestaseed_test.go" "$wt/internal/designsystem/" cp "$here/_rastrillo/ui_fiestaseed_test.go" "$wt/ui/" cd "$wt" GOFLAGS=-mod=mod FIESTA_SEED_OUT="$fiesta" go test -tags 'fiestaseed,browser' -run '^TestFiestaSeed$' ./internal/designsystem/ ./ui/ -count=1 -v