Skip to content

Commit 0d84507

Browse files
byapparovclaude
andcommitted
build: make package.json the only Bun version source (#226 review)
- bun-node Dockerfile: drop the BUN_VERSION default and fail fast without the build arg that packages/containers/script/build.ts derives from packageManager - pin oven-sh/setup-bun to the v2.2.0 commit SHA in ci and publish - RELEASING: list every consumer of packageManager and how to re-measure time to first response and RSS; CHANGELOG names the enforcing checks - test: workflows read bun-version-file package.json and the image has no Bun version of its own Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015nwvfUHdM3bgMgD9Zpz7Mj
1 parent 68c5c2a commit 0d84507

6 files changed

Lines changed: 51 additions & 9 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v6
14-
- uses: oven-sh/setup-bun@v2
14+
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
1515
with:
1616
bun-version-file: package.json
1717

‎.github/workflows/publish.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
id-token: write
1414
steps:
1515
- uses: actions/checkout@v6
16-
- uses: oven-sh/setup-bun@v2
16+
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
1717
with:
1818
bun-version-file: package.json
1919

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
### Internal
1414

15-
- **One Bun version for CI, releases and local builds** — The root `package.json` pins `packageManager` to `[email protected]`, and the CI and publish workflows read it with `bun-version-file: package.json` instead of installing `latest`. 0.5.1 shipped Bun 1.4.3 while CI and local builds could use other versions; a local 1.3.10 build of the same commit was about 85 ms slower to first response and used about 85 MB more RSS. The pre-push hook and build scripts now require Bun 1.4.3 or a later 1.x.
15+
- **One Bun version for CI, releases and local builds** — The root `package.json` pins `packageManager` to `[email protected]`, and the CI and publish workflows read it with `bun-version-file: package.json` instead of installing `latest`. 0.5.1 shipped Bun 1.4.3 while CI and local builds could use other versions; a local 1.3.10 build of the same commit was about 85 ms slower to first response and used about 85 MB more RSS. The pre-push hook and `@aictrl/script` (used by the build) check the local Bun against `packageManager`, so they now require Bun 1.4.3 or a later 1.x. The `bun-node` container image no longer has its own default `BUN_VERSION` and takes the `packageManager` version from its build script.
1616

1717
## 0.5.1 (2026-10-18)
1818

‎RELEASING.md‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,19 @@
4141

4242
The compiled binary embeds the Bun runtime that built it, so the Bun version is
4343
part of the release. The root `package.json` `packageManager` field is the only
44-
place it is set: CI and the publish workflow read it through
45-
`bun-version-file: package.json`, and the pre-push hook and build scripts check
46-
the local Bun against it.
44+
place it is set:
45+
46+
- CI and the publish workflow read it through `bun-version-file: package.json`.
47+
- `.husky/pre-push` and `@aictrl/script` (imported by
48+
`packages/cli/script/build.ts`) reject a local Bun outside `^<version>`.
49+
- `packages/containers/script/build.ts` passes it to the `bun-node` image as
50+
`BUN_VERSION`; the Dockerfile has no default.
4751

4852
Bump it deliberately, in its own PR, never as a side effect of another change.
49-
Before merging the bump, re-measure time to first response and RSS against the
50-
previous Bun. Bun 1.3.10 to 1.4.3 alone moved them by about 85 ms and 85 MB.
53+
Before merging the bump, build the binary with the old and the new Bun and
54+
compare time to first response and RSS: run a one-turn `aictrl run` against a
55+
stub model in a fresh, CPU- and memory-limited container, several times each.
56+
Moving from Bun 1.3.10 to 1.4.3 alone changed them by about 85 ms and 85 MB.
5157

5258
## 0.5.1 candidate
5359

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { expect, test } from "bun:test"
2+
import path from "path"
3+
4+
// The compiled binary embeds the Bun that built it, so every toolchain entry
5+
// point must take the version from the root package.json `packageManager`.
6+
const root = path.resolve(import.meta.dir, "../../../..")
7+
const read = (file: string) => Bun.file(path.join(root, file)).text()
8+
9+
test("packageManager pins an exact Bun version", async () => {
10+
const pkg = JSON.parse(await read("package.json"))
11+
expect(pkg.packageManager).toMatch(/^bun@\d+\.\d+\.\d+$/)
12+
})
13+
14+
test.each([".github/workflows/ci.yml", ".github/workflows/publish.yml"])(
15+
"%s installs Bun from package.json",
16+
async (file) => {
17+
const workflow = Bun.YAML.parse(await read(file)) as {
18+
jobs: Record<string, { steps: { uses?: string; with?: Record<string, string> }[] }>
19+
}
20+
const setups = Object.values(workflow.jobs)
21+
.flatMap((job) => job.steps)
22+
.filter((step) => step.uses?.startsWith("oven-sh/setup-bun@"))
23+
expect(setups.length).toBeGreaterThan(0)
24+
for (const step of setups) {
25+
expect(step.with).toEqual({ "bun-version-file": "package.json" })
26+
}
27+
},
28+
)
29+
30+
test("bun-node image has no Bun version of its own", async () => {
31+
const dockerfile = await read("packages/containers/bun-node/Dockerfile")
32+
expect(dockerfile).toMatch(/^ARG BUN_VERSION$/m)
33+
})

‎packages/containers/bun-node/Dockerfile‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ FROM ${REGISTRY}/build/base:24.04
44
SHELL ["/bin/bash", "-lc"]
55

66
ARG NODE_VERSION=24.4.0
7-
ARG BUN_VERSION=1.4.3
7+
# No default: packages/containers/script/build.ts passes the root package.json
8+
# packageManager version, the single source of the Bun version.
9+
ARG BUN_VERSION
810

911
ENV BUN_INSTALL=/opt/bun
1012
ENV PATH=/opt/bun/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
@@ -18,6 +20,7 @@ RUN set -euo pipefail; \
1820
corepack enable
1921

2022
RUN set -euo pipefail; \
23+
: "${BUN_VERSION:?pass --build-arg BUN_VERSION (packages/containers/script/build.ts reads it from package.json packageManager)}"; \
2124
curl -fsSL https://bun.sh/install | bash -s -- "bun-v${BUN_VERSION}"; \
2225
bun --version; \
2326
node --version; \

0 commit comments

Comments
 (0)