aienos.com
Source of www.aienos.com, served from my own hardware
Brought by drakestapleton
aienos.com / om / allen-page / speed-check.sh
| 1 | #!/bin/sh |
| 2 | # Regenerate public/js/aien-speed.js (the AienSpeed component) from speed-js.om |
| 3 | # with the pinned arm64 omc vendored for the Hive page; its pin is recorded once, |
| 4 | # in ../hive-page/omc.sha256. CI on x86_64 checks the committed script against |
| 5 | # aien-speed.js.sha256. OMEGA_OMC overrides the compiler path, never its pin. |
| 6 | # OMEGA_ACCEPT_CHANGE=1 accepts a rewritten script; otherwise stale output exits 4. |
| 7 | # Exit 2: missing compiler; 3: wrong pin; 4: stale artifact rewritten; |
| 8 | # 5: nondeterministic output; 6: empty output. Compile/run failures propagate. |
| 9 | set -eu |
| 10 | cd "$(dirname "$0")" |
| 11 | omc=${OMEGA_OMC:-$PWD/../hive-page/omc} |
| 12 | pin=$(tr -d ' \n' < ../hive-page/omc.sha256) |
| 13 | if [ ! -f "$omc" ]; then |
| 14 | printf 'No compiler at %s; set OMEGA_OMC to the pinned omc (%s)\n' "$omc" "$pin" >&2 |
| 15 | exit 2 |
| 16 | fi |
| 17 | have=$(sha256sum "$omc" | cut -d' ' -f1) |
| 18 | if [ "$have" != "$pin" ]; then |
| 19 | printf 'Compiler sha256 mismatch: recorded %s, found %s\n' "$pin" "$have" >&2 |
| 20 | exit 3 |
| 21 | fi |
| 22 | work=$(mktemp -d "${TMPDIR:-/tmp}/aien-speed.XXXXXX") |
| 23 | trap 'rm -rf "$work"' EXIT HUP INT TERM |
| 24 | "$omc" < speed-js.om > "$work/speed" |
| 25 | chmod +x "$work/speed" |
| 26 | "$work/speed" > "$work/first.js" |
| 27 | "$work/speed" > "$work/second.js" |
| 28 | artifact=../../public/js/aien-speed.js |
| 29 | if ! cmp -s "$work/first.js" "$work/second.js"; then |
| 30 | printf '%s: generator output differs between runs\n' "$artifact" >&2 |
| 31 | exit 5 |
| 32 | fi |
| 33 | if [ ! -s "$work/first.js" ]; then |
| 34 | printf '%s: generator wrote nothing\n' "$artifact" >&2 |
| 35 | exit 6 |
| 36 | fi |
| 37 | stale=0 |
| 38 | if [ ! -f "$artifact" ] || ! cmp -s "$artifact" "$work/first.js"; then |
| 39 | stale=1 |
| 40 | fi |
| 41 | cp "$work/first.js" "$artifact" |
| 42 | hash=$(sha256sum "$artifact" | cut -d' ' -f1) |
| 43 | printf '%s %s\n' "$hash" "$artifact" > aien-speed.js.sha256 |
| 44 | printf '%s %s bytes sha256 %s\n' "$artifact" "$(wc -c < "$artifact" | tr -d ' ')" "$hash" |
| 45 | printf 'omc sha256 %s\n' "$have" |
| 46 | if [ "$stale" = 1 ]; then |
| 47 | printf 'Generated script was rewritten; commit it with speed-js.om\n' >&2 |
| 48 | if [ "${OMEGA_ACCEPT_CHANGE:-0}" != 1 ]; then |
| 49 | exit 4 |
| 50 | fi |
| 51 | fi |