Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

ci(backend): isolate batch-exports + add test kill switch (#62479)

Raúl Negrón-Otero5b23bab10199
diff --git a/.github/scripts/turbo-discover.js b/.github/scripts/turbo-discover.js
index 81b7eb4f3c30..cef82874b677 100644
--- a/.github/scripts/turbo-discover.js
+++ b/.github/scripts/turbo-discover.js
@@ -12,6 +12,7 @@
// Products under SMALL_THRESHOLD duration get grouped into one matrix entry
// to avoid spinning up a full Docker stack for a handful of tests.
// Durations come from .test_durations (maintained by pytest-split).
+// DEDICATED_BUCKET_PRODUCTS opt out of grouping and always run alone.
//
// Input: LEGACY_CHANGED env var ("true"/"false")
// SCHEMA_CHANGED env var ("true"/"false") — when set and LEGACY_CHANGED
@@ -40,6 +41,10 @@ const PRODUCT_SAFETY_FACTOR = 1.3
// Tests under these paths need special infrastructure (Temporal server, etc.)
// and are handled by Django CI's dedicated segments — exclude from duration estimates
const EXCLUDED_PATH_SEGMENTS = ['/temporal/']
+// Products that always get their own matrix entry instead of being packed with
+// others — isolates a flaky/hang-prone product so it can't cancel bucket-mates
+// at the job timeout. Trade-off: a dedicated runner.
+const DEDICATED_BUCKET_PRODUCTS = new Set(['batch-exports'])
// --- Django shard auto-sizing (Amdahl's law) ---
// wall_clock = overhead + (total_from_durations_file / shards)
@@ -296,6 +301,13 @@ function buildMatrix(products, durations) {
pytest_args: `-- --splits ${shards} --group ${i} --splitting-algorithm duration_based_chunks`,
})
}
+ } else if (DEDICATED_BUCKET_PRODUCTS.has(product)) {
+ console.error(` ${product}: ${(raw / 60).toFixed(1)} min raw → dedicated bucket (never packed)`)
+ matrix.push({
+ group: product,
+ filters: `--filter=@posthog/products-${product}`,
+ pytest_args: '',
+ })
} else {
packable.push(product)
}
@@ -407,6 +419,26 @@ if (legacyChanged) {
}
}
+// Kill switch: products named in the SKIP_PRODUCT_TESTS repo variable (comma-
+// separated) are dropped from the matrix without a code change — use it to stop
+// running, and blocking on, a product whose tests are temporarily too flaky.
+const skipProducts = new Set((process.env.SKIP_PRODUCT_TESTS || '').split(',').map((p) => p.trim()).filter(Boolean))
+if (skipProducts.size > 0) {
+ // Warn loudly on a name that matches no real product (checked against the
+ // full product list, not just the affected ones) — catches the dash/
+ // underscore mixup where the dir is batch_exports but the product is
+ // batch-exports, which would otherwise silently skip nothing.
+ const allProductSet = new Set(allProducts)
+ for (const name of skipProducts) {
+ if (!allProductSet.has(name)) {
+ console.error(`::warning::SKIP_PRODUCT_TESTS: unknown product '${name}' — use the dashed name (e.g. 'batch-exports'), not the directory form`)
+ }
+ }
+ const before = products.length
+ products = products.filter((p) => !skipProducts.has(p))
+ console.error(`SKIP_PRODUCT_TESTS=${[...skipProducts].join(',')} — dropped ${before - products.length} product(s)`)
+}
+
console.error(`Products to test: ${JSON.stringify(products)}`)
console.error(`Run legacy (Django): ${runLegacy}`)
diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml
index 5fb79d9f69e0..a1b3352f47c1 100644
--- a/.github/workflows/ci-backend.yml
+++ b/.github/workflows/ci-backend.yml
@@ -416,6 +416,8 @@ jobs:
SCHEMA_CHANGED: ${{ github.event_name != 'pull_request' || needs.changes.outputs.schema }}
TURBO_SCM_BASE: ${{ github.event_name == 'pull_request' && format('origin/{0}', github.event.pull_request.base.ref) || '' }}
TURBO_SCM_HEAD: ${{ github.sha }}
+ # Kill switch — drop comma-separated products from the matrix; empty = run all.
+ SKIP_PRODUCT_TESTS: ${{ vars.SKIP_PRODUCT_TESTS || '' }}
run: |
# turbo-discover.js uses Turbo's Git affectedness to detect
# changed products. Non-isolated product changes trigger the