1cb451a071
- Replaced `with { type: "file" }` worker imports with `isCompiledBinary()` hybrid: literal string for `--compile` static analysis, `new URL(import.meta.url)` for dev portability.
- Added worker entrypoints as explicit `--compile` args in `build-binary.ts` so Bun emits them into bunfs.
- Added `smokeTestSyncWorker` and `omp --smoke-test` to catch silent worker-load failures in compiled binaries (fixes #1011, #1027).
- Added `isCompiledBinary()` utility to `@oh-my-pi/pi-utils` detecting bunfs path markers.
112 lines
3.5 KiB
Bash
Executable File
112 lines
3.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/../.."
|
|
ROOT_DIR="$(pwd)"
|
|
WORK_DIR="$(mktemp -d)"
|
|
TMP_WORK_DIR="$WORK_DIR/tmp"
|
|
mkdir -p "$TMP_WORK_DIR"
|
|
export TMPDIR="$TMP_WORK_DIR"
|
|
trap 'rm -rf "$WORK_DIR"' EXIT
|
|
|
|
section() {
|
|
echo ""
|
|
echo "=== $1 ==="
|
|
}
|
|
|
|
smoke_cli() {
|
|
local omp_bin="$1"
|
|
local runtime_dir
|
|
runtime_dir="$(mktemp -d "$WORK_DIR/compiled-runtime.XXXXXX")"
|
|
XDG_DATA_HOME="$runtime_dir/xdg" HOME="$runtime_dir/home" "$omp_bin" --version
|
|
XDG_DATA_HOME="$runtime_dir/xdg" HOME="$runtime_dir/home" "$omp_bin" --help >/dev/null
|
|
XDG_DATA_HOME="$runtime_dir/xdg" HOME="$runtime_dir/home" "$omp_bin" stats --summary >/dev/null
|
|
# Spawns the stats sync worker via `new Worker(...)` and waits for a pong.
|
|
# Regression probe for #1011 (browser tab worker) and #1027 (stats sync
|
|
# worker) — both broke silently in compiled binaries because the `with
|
|
# { type: "file" }` import pattern only copies the worker as a raw asset
|
|
# without bundling its imports. `stats --summary` doesn't catch this on a
|
|
# fresh install (no session files = no Worker spawn).
|
|
XDG_DATA_HOME="$runtime_dir/xdg" HOME="$runtime_dir/home" "$omp_bin" --smoke-test
|
|
}
|
|
|
|
find_tarball() {
|
|
local pattern="$1"
|
|
local matches=()
|
|
shopt -s nullglob
|
|
matches=("$pattern")
|
|
shopt -u nullglob
|
|
|
|
if [ "${#matches[@]}" -ne 1 ]; then
|
|
echo "Expected exactly one tarball matching: $pattern"
|
|
exit 1
|
|
fi
|
|
|
|
echo "${matches[0]}"
|
|
}
|
|
|
|
section "Binary install smoke"
|
|
bun --cwd=packages/natives run build
|
|
bun --cwd=packages/coding-agent run build
|
|
|
|
BINARY_DIR="$WORK_DIR/binary-bin"
|
|
mkdir -p "$BINARY_DIR"
|
|
cp packages/coding-agent/dist/omp "$BINARY_DIR/omp"
|
|
smoke_cli "$BINARY_DIR/omp"
|
|
|
|
section "Source install smoke"
|
|
SOURCE_BUN_HOME="$WORK_DIR/bun-source"
|
|
(
|
|
export BUN_INSTALL="$SOURCE_BUN_HOME"
|
|
export PATH="$BUN_INSTALL/bin:$PATH"
|
|
bun --cwd="$ROOT_DIR/packages/coding-agent" link
|
|
smoke_cli "$BUN_INSTALL/bin/omp"
|
|
)
|
|
|
|
section "Tarball install smoke"
|
|
TARBALL_DIR="$WORK_DIR/tarballs"
|
|
mkdir -p "$TARBALL_DIR"
|
|
for pkg in utils natives ai agent tui stats coding-agent; do
|
|
(
|
|
cd "$ROOT_DIR/packages/$pkg"
|
|
bun pm pack --destination "$TARBALL_DIR" --quiet >/dev/null
|
|
)
|
|
done
|
|
|
|
utils_tgz="$(find_tarball "$TARBALL_DIR"/oh-my-pi-pi-utils-*.tgz)"
|
|
natives_tgz="$(find_tarball "$TARBALL_DIR"/oh-my-pi-pi-natives-*.tgz)"
|
|
ai_tgz="$(find_tarball "$TARBALL_DIR"/oh-my-pi-pi-ai-*.tgz)"
|
|
agent_tgz="$(find_tarball "$TARBALL_DIR"/oh-my-pi-pi-agent-core-*.tgz)"
|
|
tui_tgz="$(find_tarball "$TARBALL_DIR"/oh-my-pi-pi-tui-*.tgz)"
|
|
stats_tgz="$(find_tarball "$TARBALL_DIR"/oh-my-pi-omp-stats-*.tgz)"
|
|
coding_agent_tgz="$(find_tarball "$TARBALL_DIR"/oh-my-pi-pi-coding-agent-*.tgz)"
|
|
|
|
TARBALL_APP_DIR="$WORK_DIR/tarball-install"
|
|
mkdir -p "$TARBALL_APP_DIR"
|
|
(
|
|
cd "$TARBALL_APP_DIR"
|
|
bun init -y >/dev/null
|
|
|
|
# Write overrides so bun resolves inter-package deps from tarballs, not the registry
|
|
# (version 12.x.y hasn't been published yet when CI runs pre-release)
|
|
node -e "
|
|
const pkg = JSON.parse(require('fs').readFileSync('package.json', 'utf8'));
|
|
pkg.overrides = {
|
|
'@oh-my-pi/pi-utils': '$utils_tgz',
|
|
'@oh-my-pi/pi-natives': '$natives_tgz',
|
|
'@oh-my-pi/pi-ai': '$ai_tgz',
|
|
'@oh-my-pi/pi-agent-core': '$agent_tgz',
|
|
'@oh-my-pi/pi-tui': '$tui_tgz',
|
|
'@oh-my-pi/omp-stats': '$stats_tgz',
|
|
'@oh-my-pi/pi-coding-agent': '$coding_agent_tgz'
|
|
};
|
|
require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2));
|
|
"
|
|
|
|
bun add "$utils_tgz" "$natives_tgz" "$ai_tgz" "$agent_tgz" "$tui_tgz" "$stats_tgz" "$coding_agent_tgz"
|
|
smoke_cli ./node_modules/.bin/omp
|
|
)
|
|
|
|
echo ""
|
|
echo "All install method smoke tests passed"
|