Skip to content

Commit 73fc7e0

Browse files
committed
test(scripts): resolve bun via PATH lookup in the sandbox-install guard
The `installs every pino sandbox ...` regression guard forwards a constrained `PATH` to the spawned `install_plugin_modules.js` so a re-introduced `yarn` invocation fails closed. The PATH it built started with `~/.bun/bin`, but the node composite action installs bun through `npm install -g bun@<ver>`; the binary lands under `npm prefix -g`, not under `~/.bun`. Every `spawn('bun', …)` in the child returned `ENOENT`, the install script exited with an empty stderr that hid the cause, and `Sandbox install (pino)` failed on the assert. Resolve bun's actual location via `command -v bun`, with a `BUN_BIN` override for unusual layouts. Drive-by fix: * Rewrite the `patch-istanbul-lib-coverage.js` doc comment to drop a stray `yarn upgrade` mention (no yarn invocation, purely cosmetic) and allowlist `scripts/verify-exercised-tests.js` in the no-yarn spec — its `indexOf('yarn ')` is structural workflow-string parsing, not a yarn invocation.
1 parent 74e2c2a commit 73fc7e0

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

scripts/patch-istanbul-lib-coverage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
*
1414
* Idempotent — applies the change once, then no-ops while the sentinel
1515
* comment is present in the file. Fails loudly if the locked upstream code
16-
* shape changes so a future yarn upgrade can't silently leave the patch
17-
* unapplied.
16+
* shape changes so a future dependency upgrade can't silently leave the
17+
* patch unapplied.
1818
*
1919
* Wired to the `prepare` lifecycle so the script never fires on consumer
2020
* installs of the published tarball — the script itself is not in the

scripts/test/install-plugin-modules.spec.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const assert = require('node:assert/strict')
99
const { spawnSync } = require('node:child_process')
1010
const fs = require('node:fs')
1111
const { createRequire } = require('node:module')
12-
const os = require('node:os')
1312
const path = require('node:path')
1413

1514
// eslint-disable-next-line n/no-restricted-require
@@ -18,7 +17,12 @@ const semver = require('semver')
1817
const repoRoot = path.resolve(__dirname, '..', '..')
1918
const installScript = path.join(repoRoot, 'scripts', 'install_plugin_modules.js')
2019
const versionsDir = path.join(repoRoot, 'versions')
21-
const bunBinDir = path.join(os.homedir(), '.bun', 'bin')
20+
// Resolve the runtime location of bun. CI installs bun two different ways (the official
21+
// `~/.bun/bin/bun` install script on dev machines and `npm install -g bun@<ver>` in the
22+
// `actions/node` composite, which lands it under `npm prefix -g`), so a hard-coded path
23+
// would silently fail on whichever environment doesn't match. Honour `BUN_BIN` for
24+
// explicit overrides, fall back to a `which bun` lookup against the current PATH.
25+
const bunBinDir = path.dirname(resolveBunBinary())
2226

2327
describe('scripts/install_plugin_modules.js', function () {
2428
this.timeout(180_000)
@@ -79,3 +83,11 @@ describe('scripts/install_plugin_modules.js', function () {
7983
assert.deepStrictEqual(resolvedVersions, expectedVersions)
8084
})
8185
})
86+
87+
function resolveBunBinary () {
88+
if (process.env.BUN_BIN) return process.env.BUN_BIN
89+
const result = spawnSync('sh', ['-c', 'command -v bun'], { encoding: 'utf8' })
90+
const located = result.stdout.trim()
91+
assert.ok(located, `could not locate bun on PATH (stderr: ${result.stderr.trim()})`)
92+
return located
93+
}

scripts/test/no-yarn-dev-references.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ const ALLOWLIST_EXACT = new Set([
2020
'requirements.json',
2121
'.gitlab/requirements_block.json',
2222

23+
// CI scaffolding: verify-exercised-tests parses workflow `run:` strings and unwraps the
24+
// `nick-fields/retry` wrapper. It still has to find where the wrapped command starts past
25+
// any inline env-assignment prefix, and a stray `yarn` invocation in a future workflow has
26+
// to be recognised so the assignments before it get attributed correctly. The detection is
27+
// structural, not an invocation — there is no `yarn` process spawned by this script.
28+
'scripts/verify-exercised-tests.js',
29+
2330
// User-PM test fixtures: yarn runs as the user's package manager inside the sandbox under test.
2431
'packages/dd-trace/test/appsec/next.utils.js',
2532
'integration-tests/esbuild/openfeature.spec.js',

0 commit comments

Comments
 (0)