Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/opencode/test/altimate/drivers-docker-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ import { createConnection } from "net"

const HAS_CI_SERVICES = !!(process.env.TEST_MYSQL_HOST || process.env.TEST_MSSQL_HOST || process.env.TEST_REDSHIFT_HOST)

// Only run Docker tests when explicitly opted in via DRIVER_E2E_DOCKER=1
// or when CI services are configured. This prevents the TypeScript CI job
// (which has Docker but no test databases) from trying to start containers.
const DOCKER_OPT_IN = process.env.DRIVER_E2E_DOCKER === "1"

function isDockerAvailable(): boolean {
if (HAS_CI_SERVICES) return true // CI services replace Docker
if (HAS_CI_SERVICES) return true
if (!DOCKER_OPT_IN) return false // Skip unless explicitly opted in
try {
execSync("docker info", { stdio: "ignore", timeout: 3000 })
return true
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/test/altimate/drivers-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function isBetterSqlite3Available(): boolean {

function isDockerAvailable(): boolean {
if (process.env.TEST_PG_HOST) return true // CI services replace Docker
if (!process.env.DRIVER_E2E_DOCKER) return false // Skip unless opted in
Copy link

Choose a reason for hiding this comment

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

Bug: The check for DRIVER_E2E_DOCKER is a loose truthy check, not a strict === "1" check, causing it to run tests even when a user explicitly opts out with a value like "0".
Severity: MEDIUM

Suggested Fix

Update the condition in drivers-e2e.test.ts to match the strict check used in other test files. Change the check from if (!process.env.DRIVER_E2E_DOCKER) to if (process.env.DRIVER_E2E_DOCKER !== "1") to ensure that tests only run when the variable is explicitly set to "1".

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: packages/opencode/test/altimate/drivers-e2e.test.ts#L37

Potential issue: The check for the `DRIVER_E2E_DOCKER` environment variable is
inconsistent between two test files. In `drivers-e2e.test.ts`, the condition
`!process.env.DRIVER_E2E_DOCKER` is used to skip Docker tests. This is a truthy check,
meaning if a developer sets `DRIVER_E2E_DOCKER=0` or `DRIVER_E2E_DOCKER=false` to
explicitly opt-out, the check `!"0"` evaluates to `false`, and the tests will
incorrectly proceed to run with Docker. This contradicts the behavior in
`drivers-docker-e2e.test.ts`, which uses a strict `=== "1"` check. This inconsistency
can cause unexpected test execution and failures in local development environments.

Did we get this right? 👍 / 👎 to inform future reviews.

try {
execSync("docker info", { stdio: "ignore", timeout: 3000 })
return true
Expand Down
Loading