Skip to content

Commit 46274c4

Browse files
committed
fix: make global-install-smoke work under GHA CI skip
Isolated smoke now forces postinstall and clears CI env vars so five host receipts are written when GITHUB_ACTIONS is set. Lifecycle tests cover CI+global no-op versus FORCE execute so local green cannot hide the GHA failure mode.
1 parent 9a08130 commit 46274c4

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

‎scripts/lib/npm-lifecycle-adapter.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ function classifyNpmLifecycleInstall(options = {}) {
110110
if (!isPostinstall) return noOp('not-postinstall')
111111
if (truthy(env.DEVCODEX_SKIP_POSTINSTALL)) return noOp('skip-env')
112112
if (truthy(env.DEVCODEX_POSTINSTALL_CHILD)) return noOp('child-process')
113+
// CI skip is intentional for workspace/CI jobs so runners do not mutate host homes.
114+
// Real global install on CI is also skipped unless DEVCODEX_POSTINSTALL_FORCE=1
115+
// (global-install-smoke must set force + clear CI vars in its isolated env).
113116
if (!force && ci) return noOp('ci')
114117
if (globalInstall) {
115118
return {

‎scripts/test-global-install-smoke.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,15 @@ function runCommand(command, args, options = {}) {
7171
}
7272

7373
function isolatedHostEnv(home) {
74+
// Global postinstall skips when CI/GITHUB_ACTIONS is truthy (see npm-lifecycle-adapter).
75+
// Smoke inherits process.env from GHA; force + clear CI vars so isolated receipts are written.
7476
return {
7577
DEVCODEX_TEST_HOME: home,
78+
DEVCODEX_POSTINSTALL_FORCE: '1',
79+
CI: '',
80+
GITHUB_ACTIONS: '',
81+
BUILDKITE: '',
82+
TF_BUILD: '',
7683
CODEX_HOME: path.join(home, '.codex'),
7784
CLAUDE_CONFIG_DIR: path.join(home, '.claude'),
7885
GEMINI_CLI_HOME: path.join(home, 'gemini-cli-home'),

‎scripts/test-npm-lifecycle-adapter.js‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,34 @@ assert.strictEqual(classify({ DEVCODEX_SKIP_POSTINSTALL: '1' }).reason, 'skip-en
193193
assert.strictEqual(classify({ DEVCODEX_POSTINSTALL_CHILD: '1' }).reason, 'child-process')
194194
assert.strictEqual(classify({}, transitiveWorkspace).reason, 'transitive-or-indirect')
195195

196+
// CI skip runs before globalInstall (S-a): real GHA postinstall stays no-op unless forced.
197+
// Prevents global-install-smoke from going green locally while red under GITHUB_ACTIONS.
198+
const ciGlobalDecision = classify({ CI: 'true', npm_config_global: 'true', INIT_CWD: workspace })
199+
assert.strictEqual(ciGlobalDecision.action, 'noop')
200+
assert.strictEqual(ciGlobalDecision.reason, 'ci')
201+
assert.strictEqual(ciGlobalDecision.globalInstall, true)
202+
const ghaGlobalDecision = classify({ GITHUB_ACTIONS: 'true', npm_config_global: 'true', INIT_CWD: workspace })
203+
assert.strictEqual(ghaGlobalDecision.action, 'noop')
204+
assert.strictEqual(ghaGlobalDecision.reason, 'ci')
205+
const ciGlobalWithTestHome = classify({
206+
CI: 'true',
207+
npm_config_global: 'true',
208+
DEVCODEX_TEST_HOME: path.join(tmp, 'isolated-home'),
209+
INIT_CWD: workspace
210+
})
211+
assert.strictEqual(ciGlobalWithTestHome.action, 'noop', 'DEVCODEX_TEST_HOME alone must not bypass CI skip')
212+
assert.strictEqual(ciGlobalWithTestHome.reason, 'ci')
213+
const ciGlobalForced = classify({
214+
CI: 'true',
215+
GITHUB_ACTIONS: 'true',
216+
npm_config_global: 'true',
217+
DEVCODEX_POSTINSTALL_FORCE: '1',
218+
INIT_CWD: workspace
219+
})
220+
assert.strictEqual(ciGlobalForced.action, 'execute')
221+
assert.strictEqual(ciGlobalForced.reason, 'global-install-postinstall')
222+
assert.strictEqual(ciGlobalForced.scope, 'global-install')
223+
196224
const sourceGlobalDecision = classify({ npm_config_global: 'true', INIT_CWD: workspace }, workspace, sourceRoot)
197225
assert.strictEqual(sourceGlobalDecision.action, 'execute')
198226
assert.strictEqual(sourceGlobalDecision.scope, 'global-install')

0 commit comments

Comments
 (0)