Skip to content

Commit 41bd032

Browse files
committed
Merge remote-tracking branch 'origin/fix/bun-ci-script-not-found' into feat/external-idempotency-key
2 parents 968f30a + 9ad6512 commit 41bd032

2 files changed

Lines changed: 76 additions & 1 deletion

File tree

.github/workflows/ts-sdk.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,21 @@ jobs:
5353
cache-dependency-path: sdk/typescript/pnpm-lock.yaml
5454
- uses: oven-sh/setup-bun@v2
5555
- run: pnpm install --frozen-lockfile
56-
- run: bun --bun pnpm test
56+
# Build first: the smoke check imports the emitted bundle, which is what a
57+
# Bun user actually installs.
58+
- run: pnpm build
59+
# A plain Bun script, not `vitest` under `--bun`.
60+
#
61+
# This step used to be `bun --bun pnpm test`. Bun resolves the first
62+
# argument as a package.json script or a node_modules/.bin entry, and
63+
# pnpm/action-setup v6 installs pnpm globally instead, so it died with
64+
# `Script not found "pnpm"` on every commit from 2026-05-13 onward.
65+
#
66+
# Fixing the invocation revealed why it was worth fixing: vitest under the
67+
# Bun runtime cannot resolve zod's named export, so every suite failed on
68+
# `z.object`. That is a property of vitest's module runner, not of this
69+
# SDK — it says nothing about whether the package works for a Bun user,
70+
# which is the only question this job exists to answer. So ask that
71+
# question directly.
72+
- run: bun run scripts/bun-smoke.ts
5773
working-directory: sdk/typescript/packages/cloud
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Does @jamjet/cloud actually work on the Bun runtime?
3+
*
4+
* Imports the BUILT bundle — what a user installs — rather than the sources, and
5+
* exercises real behaviour rather than only checking that the module loads.
6+
*
7+
* A plain script, not a test-runner file, on purpose. This job used to run
8+
* `vitest` under `--bun`; vitest drives its own module runner, and its
9+
* interop with Bun is a property of vitest, not of this SDK. A failure there
10+
* says nothing about whether the package works for a Bun user, which is the
11+
* only question this job exists to answer.
12+
*
13+
* Merely importing the bundle is itself a real check: `config.ts` builds its
14+
* zod schemas at module scope, so a broken ESM/CJS interop fails here.
15+
*/
16+
import assert from 'node:assert/strict'
17+
18+
import { VERSION, redact, estimateCost, ConfigError, PolicyEvaluator } from '../dist/index.js'
19+
20+
const checks: [string, () => void][] = [
21+
['VERSION is published', () => {
22+
assert.equal(typeof VERSION, 'string')
23+
assert.match(VERSION, /^\d+\.\d+\.\d+/)
24+
}],
25+
['zod-backed config module loaded', () => {
26+
// ConfigError comes from config.ts, whose zod schemas are built at module
27+
// scope. If zod's named export did not resolve under Bun, the import above
28+
// has already thrown; this pins the symbol as well.
29+
assert.equal(typeof ConfigError, 'function')
30+
assert.ok(new ConfigError('x') instanceof Error)
31+
}],
32+
['redaction behaves', () => {
33+
assert.equal(redact('contact alice@example.com please'), 'contact [EMAIL_ADDRESS] please')
34+
assert.equal(redact('call 555-123-4567'), 'call [PHONE_NUMBER]')
35+
}],
36+
['cost estimation behaves', () => {
37+
const c = estimateCost('gpt-4o', 100, 50)
38+
assert.ok(Math.abs(c - 0.00075) < 1e-8, `expected ~0.00075, got ${c}`)
39+
}],
40+
['classes construct', () => {
41+
assert.equal(typeof PolicyEvaluator, 'function')
42+
}],
43+
]
44+
45+
let failed = 0
46+
for (const [name, run] of checks) {
47+
try {
48+
run()
49+
console.log(`ok - ${name}`)
50+
} catch (err) {
51+
failed++
52+
console.error(`not ok - ${name}`)
53+
console.error(err instanceof Error ? err.stack : String(err))
54+
}
55+
}
56+
57+
const bun = (globalThis as { Bun?: { version: string } }).Bun
58+
console.log(`\n${checks.length - failed}/${checks.length} passed on ${bun ? `Bun ${bun.version}` : process.version}`)
59+
if (failed > 0) process.exit(1)

0 commit comments

Comments
 (0)