Skip to content

feat(mermaid): add terminal diagram renderer #682

feat(mermaid): add terminal diagram renderer

feat(mermaid): add terminal diagram renderer #682

name: Native Benchmark Smoke
on:
pull_request:
branches: [main]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
BUN_VERSION: 1.3.14
ZIG_VERSION: 0.16.0
jobs:
bench-native-smoke:
name: Native Benchmark Smoke
runs-on: blacksmith-12vcpu-macos-15
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Setup Zig
uses: mlugg/setup-zig@v2
with:
version: ${{ env.ZIG_VERSION }}
use-cache: false
- name: Restore Zig cache
uses: actions/cache@v5
with:
path: .zig-cache
key: zig-v1-${{ runner.os }}-${{ env.ZIG_VERSION }}-${{ github.run_id }}-${{ github.job }}
restore-keys: zig-v1-${{ runner.os }}-${{ env.ZIG_VERSION }}-
- name: Install dependencies
run: bun install
- name: Run native benchmark smoke tests
working-directory: packages/core
run: |
set -euo pipefail
utf8_output="$(bun run bench:native --mem --filter "UTF-8 Operations" --bench "isAsciiOnly: ASCII text (1KB)" --json)"
image_output="$(bun run bench:native --mem --filter "Terminal Image" --bench "Kitty cover placement" --json)"
printf '%s\n' "$utf8_output"
printf '%s\n' "$image_output"
UTF8_OUTPUT="$utf8_output" IMAGE_OUTPUT="$image_output" bun -e '
const cases = [
{
output: process.env.UTF8_OUTPUT ?? "",
benchmark: "UTF-8 Operations",
result: "isAsciiOnly: ASCII text (1KB)",
requiresConfidence: false,
},
{
output: process.env.IMAGE_OUTPUT ?? "",
benchmark: "Terminal Image",
result: "Kitty cover placement",
requiresConfidence: true,
},
]
for (const expected of cases) {
const lines = expected.output.split(/\r?\n/)
let jsonLine = ""
for (let i = lines.length - 1; i >= 0; i--) {
const line = lines[i].trim()
if (line.startsWith("{")) {
jsonLine = line
break
}
}
if (!jsonLine) {
throw new Error(`${expected.benchmark} benchmark smoke test produced no JSON output`)
}
const data = JSON.parse(jsonLine)
if (data.benchmark !== expected.benchmark) {
throw new Error(`Unexpected benchmark category: ${data.benchmark}`)
}
if (!Array.isArray(data.results) || data.results.length !== 1) {
throw new Error(`Expected exactly one ${expected.benchmark} benchmark result, got ${data.results?.length ?? 0}`)
}
const result = data.results[0]
if (result.name !== expected.result) {
throw new Error(`Unexpected ${expected.benchmark} benchmark result: ${result.name}`)
}
if (expected.requiresConfidence && (!Number.isFinite(result.stddev_ns) || !Number.isFinite(result.rme_95))) {
throw new Error(`Benchmark result is missing confidence fields: ${JSON.stringify(result)}`)
}
}
'