Skip to content

Commit c55698a

Browse files
authored
chore(ci): fail closed on missing test Redis in CI and skip unused pg16 service (#8938)
- readTestRedisUrl throws when CI is set and TEST_REDIS_URL is missing, so Redis-gated integration suites can no longer pass by skipping - start the postgres:16 service only on integration (push, 1/4), the one job whose step uses it - move the two env-gated smoke files that no workflow enables to *.live.test.ts and shrink the test-patterns baseline accordingly
1 parent ba998b6 commit c55698a

7 files changed

Lines changed: 19 additions & 30 deletions

File tree

‎.claude/rules/sim-testing.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ contracts, and demonstrated regressions.
3333
| Suffix | Needs | Run with | In CI |
3434
|--------|-------|----------|-------|
3535
| `*.test.ts(x)` | nothing; global mocks from `vitest.setup.ts` | `bun run --cwd <workspace> test` | `test` jobs |
36-
| `*.integration.ts` | real PostgreSQL (`TEST_DATABASE_URL`), optionally Redis (`TEST_REDIS_URL`) | `bun run --cwd <workspace> test --mode integration` | `integration` jobs, by glob (sharded per provisioning path) |
36+
| `*.integration.ts` | real PostgreSQL (`TEST_DATABASE_URL`), Redis (`TEST_REDIS_URL`; optional locally, required in CI) | `bun run --cwd <workspace> test --mode integration` | `integration` jobs, by glob (sharded per provisioning path) |
3737
| `*.live.test.ts` | provider APIs, hosted sandboxes, local runtimes, or sibling checkouts | `bun run --cwd apps/sim test --mode live <file>` | never |
3838
| `apps/desktop/e2e/*.spec.ts` | the packaged Electron app | Playwright | desktop E2E workflow |
3939
| `apps/sim/scripts/test-*-e2e.ts` | a running app over HTTP | its `package.json` script when one exists (`bun run test:scim:e2e`; `test:workflow-version-compare:e2e` adds `--no-env-file`), else `bun scripts/test-<suite>-e2e.ts` from apps/sim | `e2e` jobs (`.github/scripts/http-e2e.sh`) |

‎.cursor/rules/sim-testing.mdc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ contracts, and demonstrated regressions.
3131
| Suffix | Needs | Run with | In CI |
3232
|--------|-------|----------|-------|
3333
| `*.test.ts(x)` | nothing; global mocks from `vitest.setup.ts` | `bun run --cwd <workspace> test` | `test` jobs |
34-
| `*.integration.ts` | real PostgreSQL (`TEST_DATABASE_URL`), optionally Redis (`TEST_REDIS_URL`) | `bun run --cwd <workspace> test --mode integration` | `integration` jobs, by glob (sharded per provisioning path) |
34+
| `*.integration.ts` | real PostgreSQL (`TEST_DATABASE_URL`), Redis (`TEST_REDIS_URL`; optional locally, required in CI) | `bun run --cwd <workspace> test --mode integration` | `integration` jobs, by glob (sharded per provisioning path) |
3535
| `*.live.test.ts` | provider APIs, hosted sandboxes, local runtimes, or sibling checkouts | `bun run --cwd apps/sim test --mode live <file>` | never |
3636
| `apps/desktop/e2e/*.spec.ts` | the packaged Electron app | Playwright | desktop E2E workflow |
3737
| `apps/sim/scripts/test-*-e2e.ts` | a running app over HTTP | its `package.json` script when one exists (`bun run test:scim:e2e`; `test:workflow-version-compare:e2e` adds `--no-env-file`), else `bun scripts/test-<suite>-e2e.ts` from apps/sim | `e2e` jobs (`.github/scripts/http-e2e.sh`) |

‎.github/workflows/checks.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ jobs:
4949
--health-interval 5s
5050
--health-timeout 5s
5151
--health-retries 10
52+
# Only push/1 runs the PostgreSQL 16 step below; an empty image skips the service elsewhere.
5253
postgres-legacy:
53-
image: postgres:16-alpine
54+
image: ${{ matrix.provision == 'push' && matrix.shard == 1 && 'postgres:16-alpine' || '' }}
5455
env:
5556
POSTGRES_USER: postgres
5657
POSTGRES_PASSWORD: postgres

apps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts renamed to apps/sim/lib/mothership/agent-cli/csv-workflow-execution.live.test.ts

File renamed without changes.
File renamed without changes.

‎packages/db/testing/test-infrastructure.ts‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
22
* Environment contract for the real-infrastructure test layer (`*.integration.ts`).
33
*
4-
* `TEST_DATABASE_URL` names a disposable PostgreSQL database and `TEST_REDIS_URL` an optional
5-
* disposable Redis. Both must use a loopback host, and the database name must contain a `test`
6-
* segment (`sim_test`, `sim_test_knowledge`, `sim_workflow_test`), so a stray shell variable can
7-
* never point destructive fixtures at a real database. Every integration run's setup file calls
8-
* these readers before any suite loads.
4+
* `TEST_DATABASE_URL` names a disposable PostgreSQL database and `TEST_REDIS_URL` a disposable
5+
* Redis (optional locally, required in CI). Both must use a loopback host, and the database name
6+
* must contain a `test` segment (`sim_test`, `sim_test_knowledge`, `sim_workflow_test`), so a stray
7+
* shell variable can never point destructive fixtures at a real database. Every integration run's
8+
* setup file calls these readers before any suite loads.
99
*/
1010
const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]'])
1111
const DISPOSABLE_DATABASE_NAME = /(^|_)test(_|$)/
@@ -39,15 +39,23 @@ export function readTestDatabaseUrl(): string {
3939
}
4040

4141
/**
42-
* Returns the validated `TEST_REDIS_URL`, or undefined when the run has no Redis.
42+
* Returns the validated `TEST_REDIS_URL`, or undefined when a local run has no Redis. In CI a
43+
* missing value throws: every Redis-gated suite would otherwise pass by skipping.
4344
*
4445
* Any query string is rejected, not just `username`/`password` params: Redis clients read
4546
* connection options (credentials, TLS, sentinels) from it, so an allowlist would have to track
4647
* each client's option set, and a local disposable Redis never needs one.
4748
*/
4849
export function readTestRedisUrl(): string | undefined {
4950
const value = process.env.TEST_REDIS_URL
50-
if (!value) return undefined
51+
if (!value) {
52+
if (process.env.CI) {
53+
throw new Error(
54+
'Set TEST_REDIS_URL in CI: Redis-gated integration suites would silently skip'
55+
)
56+
}
57+
return undefined
58+
}
5159
const url = new URL(value)
5260
if (
5361
url.protocol !== 'redis:' ||

‎scripts/test-patterns-baseline.json‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,6 @@
4949
"local-factory\tapps/sim/executor/execution/block-executor.test.ts\t@/lib/logs/execution/pii-redaction",
5050
"local-factory\tapps/sim/executor/utils/output-filter.test.ts\t@/blocks",
5151
"local-factory\tapps/sim/lib/mcp/workflow-mcp-sync.test.ts\t@/lib/mcp/pubsub",
52-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/api/server/routes/v2-api-key-auth",
53-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/core/rate-limiter",
54-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/execution/preprocessing",
55-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/execution/remote-sandbox",
56-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/internal/principals/executor",
57-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/logs/execution/logging-session",
58-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/public-shares/share-manager",
59-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/uploads/contexts/workspace",
60-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/uploads/contexts/workspace/workspace-file-manager",
61-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/uploads/core/storage-service",
62-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/uploads/server/metadata",
63-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/uploads/utils/file-utils.server",
64-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/users/queries",
65-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/workflows/application/context",
66-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/workflows/custom-blocks/operations",
67-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/workflows/executor/human-in-the-loop-manager",
68-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/workflows/persistence/utils",
69-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/workflows/utils",
70-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@/lib/workspaces/application/workspace-context",
71-
"local-factory\tapps/sim/lib/mothership/agent-cli/csv-workflow-execution.test.ts\t@sim/platform-authz/workspace",
7252
"local-factory\tapps/sim/lib/mothership/chat/application/use-cases.test.ts\t@/lib/core/application/workspace-authorization",
7353
"local-factory\tapps/sim/lib/mothership/chat/payload.test.ts\t@/tools/utils",
7454
"local-factory\tapps/sim/lib/mothership/request/application/recover-stream.test.ts\t@/lib/core/application/workspace-authorization",

0 commit comments

Comments
 (0)