Skip to content

Fix CI test failures from Bun.spawn in vitest - #1821

Merged
firecow merged 1 commit into
masterfrom
fix/gcl-env-split-test-bun-spawn
Apr 3, 2026
Merged

Fix CI test failures from Bun.spawn in vitest#1821
firecow merged 1 commit into
masterfrom
fix/gcl-env-split-test-bun-spawn

Conversation

@firecow

@firecow firecow commented Apr 3, 2026

Copy link
Copy Markdown
Owner
  • Replace Bun.spawn with child_process.execFile in gcl-env-variable-split tests
  • Bun global is unavailable when vitest runs in Node.js worker threads
  • Also includes typecheck fix: cast yparser.getOptions() which lacks type definitions

Fixes test and typecheck failures introduced by #1778.


Summary by cubic

Fix CI test failures by replacing Bun.spawn with child_process.execFile in the gcl-env-variable-split integration tests, since Bun isn’t available under vitest Node worker threads. Also adds a small type fix for yparser.getOptions().

  • Bug Fixes
    • Introduced a runCli helper using execFile to invoke bun src/index.ts with env vars.
    • Preserves stdout and exit code behavior; tests now pass in CI and Node-only environments.
    • Casts yparser.getOptions() to address missing type definitions.

Written for commit cd5f5e3. Summary will update on new commits.

Bun global is not available when vitest runs tests in Node.js worker
threads, causing ReferenceError in CI.
@firecow firecow self-assigned this Apr 3, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tests/test-cases/gcl-env-variable-split/integration.test.ts">

<violation number="1" location="tests/test-cases/gcl-env-variable-split/integration.test.ts:196">
P2: `runCli` can incorrectly report `exitCode: 0` when `execFile` fails with a non-numeric error code. Treat non-exit errors as failures instead of coercing them to success.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment on lines +196 to +197
resolve({stdout, exitCode: typeof error?.code === "number" ? error.code : 0});
});

@cubic-dev-ai cubic-dev-ai Bot Apr 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: runCli can incorrectly report exitCode: 0 when execFile fails with a non-numeric error code. Treat non-exit errors as failures instead of coercing them to success.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/test-cases/gcl-env-variable-split/integration.test.ts, line 196:

<comment>`runCli` can incorrectly report `exitCode: 0` when `execFile` fails with a non-numeric error code. Treat non-exit errors as failures instead of coercing them to success.</comment>

<file context>
@@ -186,63 +187,32 @@ test("GCL_VARIABLE env split reaches handler as separate variables", async () =>
+            env: {...process.env, ...envVars},
+        }, (error, stdout) => {
+            if (error && error.code === undefined) return reject(error);
+            resolve({stdout, exitCode: typeof error?.code === "number" ? error.code : 0});
+        });
+    });
</file context>
Suggested change
resolve({stdout, exitCode: typeof error?.code === "number" ? error.code : 0});
});
if (error) {
if (typeof error.code === "number") {
return resolve({stdout, exitCode: error.code});
}
return reject(error);
}
resolve({stdout, exitCode: 0});
Fix with Cubic

@sonarqubecloud

sonarqubecloud Bot commented Apr 3, 2026

Copy link
Copy Markdown

@firecow
firecow merged commit 1febd88 into master Apr 3, 2026
16 checks passed
@firecow
firecow deleted the fix/gcl-env-split-test-bun-spawn branch April 3, 2026 09:05
kevingerman pushed a commit to kevingerman/gitlab-ci-local that referenced this pull request Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant