ci: add GitHub Actions workflow; runner: prefer PyVM in selfhost paths; stage3: add LLVM + bridge acceptance smokes; docs: update env flags

This commit is contained in:
Selfhosting Dev
2025-09-17 01:20:15 +09:00
parent 5c9213cd03
commit adbfbb2c76
11 changed files with 212 additions and 20 deletions

View File

@ -0,0 +1,60 @@
#!/usr/bin/env bash
set -euo pipefail
[[ "${NYASH_CLI_VERBOSE:-0}" == "1" ]] && set -x
ROOT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
BIN="$ROOT_DIR/target/release/nyash"
if [[ ! -x "$BIN" ]]; then
(cd "$ROOT_DIR" && cargo build --release >/dev/null)
fi
pass() { echo "$1" >&2; }
fail() { echo "$1" >&2; echo "$2" >&2; exit 1; }
run_json_expect_code() {
local name="$1"; shift
local json="$1"; shift
local expect_code="$1"; shift
set +e
# Feed JSON v0 directly via pipe. Prefer PyVM for parity.
OUT=$(printf '%s\n' "$json" | NYASH_PIPE_USE_PYVM=${NYASH_PIPE_USE_PYVM:-1} "$BIN" --ny-parser-pipe --backend vm 2>&1)
CODE=$?
set -e
if [[ "$CODE" == "$expect_code" ]]; then pass "$name"; else fail "$name" "$OUT"; fi
}
# A) try/catch/finally acceptance (degrade path unless NYASH_BRIDGE_TRY_ENABLE=1); final return 0
JSON_A='{"version":0,"kind":"Program","body":[
{"type":"Try","try":[{"type":"Local","name":"x","expr":{"type":"Int","value":1}}],
"catches":[{"param":"e","typeHint":"Error","body":[{"type":"Local","name":"y","expr":{"type":"Int","value":2}}]}],
"finally":[{"type":"Local","name":"z","expr":{"type":"Int","value":3}}]
},
{"type":"Return","expr":{"type":"Int","value":0}}
]}'
run_json_expect_code "try/catch/finally (accept)" "$JSON_A" 0
# B) break acceptance under dead branch (ignored when not in loop)
JSON_B='{"version":0,"kind":"Program","body":[
{"type":"If","cond":{"type":"Bool","value":false},"then":[{"type":"Break"}]},
{"type":"Return","expr":{"type":"Int","value":0}}
]}'
run_json_expect_code "break in dead branch (accept)" "$JSON_B" 0
# C) continue acceptance under dead branch (ignored when not in loop)
JSON_C='{"version":0,"kind":"Program","body":[
{"type":"If","cond":{"type":"Bool","value":false},"then":[{"type":"Continue"}]},
{"type":"Return","expr":{"type":"Int","value":0}}
]}'
run_json_expect_code "continue in dead branch (accept)" "$JSON_C" 0
# D) throw acceptance as expression (degrade path unless NYASH_BRIDGE_THROW_ENABLE=1)
JSON_D='{"version":0,"kind":"Program","body":[
{"type":"Expr","expr":{"type":"Throw","expr":{"type":"Int","value":123}}},
{"type":"Return","expr":{"type":"Int","value":0}}
]}'
run_json_expect_code "throw (accept)" "$JSON_D" 0
echo "All Stage-3 bridge acceptance smokes PASS" >&2
exit 0

View File

@ -12,6 +12,10 @@ fi
TMP="$ROOT_DIR/tmp"
mkdir -p "$TMP"
# Default to PyVM reference unless explicitly disabled by caller
: "${NYASH_VM_USE_PY:=1}"
export NYASH_VM_USE_PY
pass() { echo "$1" >&2; }
fail() { echo "$1" >&2; echo "$2" >&2; exit 1; }

View File

@ -0,0 +1,40 @@
#!/usr/bin/env bash
set -euo pipefail
# Curated LLVM Stage-3 acceptance smoke (llvmlite harness)
# Usage: tools/smokes/curated_llvm_stage3.sh [--phi-off]
ROOT_DIR=$(cd "$(dirname "$0")/../.." && pwd)
BIN="$ROOT_DIR/target/release/nyash"
if ! [ -x "$BIN" ]; then
echo "[curated-llvm-stage3] building nyash (release, features=llvm)" >&2
cargo build --release --features llvm >/dev/null
fi
export NYASH_LLVM_USE_HARNESS=1
if [[ "${1:-}" == "--phi-off" ]]; then
export NYASH_MIR_NO_PHI=1
export NYASH_VERIFY_ALLOW_NO_PHI=1
echo "[curated-llvm-stage3] PHI-off (edge-copy) enabled" >&2
fi
run_ok() {
local path="$1"
echo "[curated-llvm-stage3] RUN --backend llvm: ${path}"
timeout 10s "$BIN" --backend llvm "$path" >/dev/null
}
# A) try/catch/finally without actual throw
run_ok "$ROOT_DIR/apps/tests/stage3_try_finally_basic.nyash"
# B) throw in dead branch (acceptance only)
run_ok "$ROOT_DIR/apps/tests/stage3_throw_dead_branch.nyash"
# C) repeat with trap disabled (robustness; should be no-op here)
NYASH_LLVM_TRAP_ON_THROW=0 run_ok "$ROOT_DIR/apps/tests/stage3_try_finally_basic.nyash"
NYASH_LLVM_TRAP_ON_THROW=0 run_ok "$ROOT_DIR/apps/tests/stage3_throw_dead_branch.nyash"
echo "[curated-llvm-stage3] OK"