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.

fix(ci): gate native-json tests by label (#105879)

Raúl Negrón-Oterocae27336d7ad
diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.yml
index 185981ab4ced..1f93332cca53 100644
--- a/.depot/workflows/ci-backend.yml
+++ b/.depot/workflows/ci-backend.yml
@@ -54,9 +54,9 @@
# - Workflow-name expressions remain literal, so the role cannot switch names through a
# variable; the cutover renames the workflow in a plain edit. The gate's hand-off `&&`
# is safe only while its status remains optional.
-# - events_json variants: run on every shadow run, matching canonical. Gated behind a label,
-# a routed PR that changed SQL passed here and then failed the merge queue (always on
-# GitHub), which runs both schemas in check mode and cannot regenerate snapshots it lacks
+# - events_json variants: gated on the test-new-events-schema label only; canonical also
+# doubles the matrices on workflow_dispatch, but shadow dispatches stay legacy-only so
+# trial runs match handed-off PR runs
# - per-segment split plans (.test_durations.core/.temporal): the restore steps mirror
# canonical but miss until the depot timing refresher saves those files to Depot Cache;
# shards fall back to the union .test_durations
@@ -1040,10 +1040,9 @@ jobs:
id: build
env:
PRODUCT_MATRIX_JSON: ${{ needs.turbo-discover.outputs.matrix }}
- # The new-events-schema variants double the matrix. They run on every shadow
- # run, like canonical, so a routed PR cannot pass here and then fail the
- # merge queue's check-mode run on snapshots it never regenerated.
- RUN_NEW_EVENTS_SCHEMA: 'true'
+ # The new-events-schema variants double the matrix, so run them only on
+ # opted-in PRs.
+ RUN_NEW_EVENTS_SCHEMA: ${{ contains(github.event.pull_request.labels.*.name, 'test-new-events-schema') }}
run: |
if [[ "$RUN_NEW_EVENTS_SCHEMA" == "true" ]]; then
schema_modes='[false, true]'
@@ -2405,10 +2404,9 @@ jobs:
IS_DRAFT: ${{ github.event.pull_request.draft && !startsWith(github.head_ref, 'trunk-merge/') }}
IS_PR_RUN: ${{ github.event_name == 'pull_request' && !startsWith(github.head_ref, 'trunk-merge/') }}
FORCE_FULL: ${{ contains(github.event.pull_request.labels.*.name, 'run-ci-backend') }}
- # The new-events-schema variants double the matrix. They run on every shadow
- # run, like canonical, so a routed PR cannot pass here and then fail the
- # merge queue's check-mode run on snapshots it never regenerated.
- RUN_NEW_EVENTS_SCHEMA: 'true'
+ # The new-events-schema variants double the matrix, so run them only on
+ # opted-in PRs.
+ RUN_NEW_EVENTS_SCHEMA: ${{ contains(github.event.pull_request.labels.*.name, 'test-new-events-schema') }}
run: |
# :NOTE: Keep shard counts/group ranges in sync with historical Django matrix tuning.
# Consult #team-devex before changing.
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 3001c3f7b8e5..03724592060b 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -60,6 +60,7 @@
<!-- Definition of done (agents): not done until each gate below holds. Verify against the named artifact or skill — don't assume. Add gates as the PR touches more areas.
- No duplicate: when this PR fixes something believed to be live on master, no open PR already fixes it. A broken master attracts parallel agents, so search before opening — `gh pr list --state open --search "<keywords>" --limit 20`, which lists drafts too, and most agent PRs start as drafts. Say here which PR you found and why this one is still needed, or that the search found nothing.
- Patch coverage: the lines this PR changed are covered, or the uncovered ones are justified under "How did you test this code?". Don't pad untouched code to lift the number. Check the "🧪 Backend test coverage" PR comment (and its patch-coverage artifact).
+ - New events schema: classify the diff before opening the PR. Add `test-new-events-schema` for event ingestion or cleaning, event or property reads, generated event-table SQL, and schema-specific snapshots. Apply it while draft before ready-for-review. If the PR must open ready, apply it immediately and push another commit because label events do not start Backend CI. State the result under "How did you test this code?".
- Public artifact: nothing in this PR — code, fixtures and sample data, comments, commit messages, or this description — carries material from the agent session that isn't already public. If the work drew on a customer conversation, ticket, or log, say so here and state that the committed data is invented. Renaming people, hosts, and identifiers does not clear real material; see AGENTS.md "Public open source repo guidance".
-->
diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml
index 1c87a044edce..4622a5315136 100644
--- a/.github/workflows/ci-backend.yml
+++ b/.github/workflows/ci-backend.yml
@@ -36,9 +36,9 @@ on:
# so every unrelated label re-ran these matrices against a commit CI had
# already covered. A label here takes effect from the next push, or from
# ready_for_review.
- # Every run doubles the test matrices to cover both events schemas
- # (CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA off and on); the switch is
- # RUN_NEW_EVENTS_SCHEMA on the two matrix builders.
+ # The `test-new-events-schema` label opts a PR into the doubled matrices that
+ # cover both events schemas. Apply it before a push or ready_for_review because
+ # label events do not start this workflow. Manual dispatches also run both modes.
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
@@ -856,10 +856,9 @@ jobs:
id: build
env:
PRODUCT_MATRIX_JSON: ${{ needs.turbo-discover.outputs.matrix }}
- # The new-events-schema variants double the matrix. They run on every PR
- # and master run so a change that breaks the native-JSON events table
- # fails before it merges; set this to 'false' to pause them.
- RUN_NEW_EVENTS_SCHEMA: 'true'
+ # The new-events-schema variants double the matrix, so run them only on
+ # opted-in PRs and manual dispatches.
+ RUN_NEW_EVENTS_SCHEMA: ${{ contains(github.event.pull_request.labels.*.name, 'test-new-events-schema') || github.event_name == 'workflow_dispatch' }}
run: |
if [[ "$RUN_NEW_EVENTS_SCHEMA" == "true" ]]; then
schema_modes='[false, true]'
@@ -2634,10 +2633,9 @@ jobs:
IS_DRAFT: ${{ github.event.pull_request.draft && !startsWith(github.head_ref, 'trunk-merge/') }}
IS_PR_RUN: ${{ github.event_name == 'pull_request' && !startsWith(github.head_ref, 'trunk-merge/') }}
FORCE_FULL: ${{ contains(github.event.pull_request.labels.*.name, 'run-ci-backend') }}
- # The new-events-schema variants double the matrix. They run on every PR
- # and master run so a change that breaks the native-JSON events table
- # fails before it merges; set this to 'false' to pause them.
- RUN_NEW_EVENTS_SCHEMA: 'true'
+ # The new-events-schema variants double the matrix, so run them only on
+ # opted-in PRs and manual dispatches.
+ RUN_NEW_EVENTS_SCHEMA: ${{ contains(github.event.pull_request.labels.*.name, 'test-new-events-schema') || github.event_name == 'workflow_dispatch' }}
run: |
# :NOTE: Keep shard counts/group ranges in sync with historical Django matrix tuning.
# Consult #team-devex before changing.
diff --git a/AGENTS.md b/AGENTS.md
index 3543a86b6cc3..2e24d8832f48 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -137,6 +137,7 @@ Examples:
- CI uploads test results to Trunk Flaky Tests; the `trunk` MCP server in `.mcp.json` queries per-test flakiness on a PR or `master` (authenticate via `/mcp`, or a `TRUNK_API_TOKEN` bearer header when headless) — see `/debugging-ci-failures` and `/fixing-flaky-tests`
- **A workflow edit reaches every open PR before those branches rebase.** It runs against the PR merged with master, but a companion change — a new dependency, file, or config — only arrives when the branch rebases. A workflow that starts requiring something unrebased branches lack fails every in-flight PR before its tests run. Make the new behavior degrade gracefully, or gate it. This has broken CI repeatedly.
- Mechanical workflow rules (`timeout-minutes`, concurrency, dispatch budget, path filters, gate hygiene) are enforced by `hogli lint:workflows` and actionlint, which are the source of truth. `/authoring-ci-workflows` explains the reasoning behind each.
+- **Agents must classify every PR for native-JSON event-table coverage before opening it.** Add `test-new-events-schema` when a diff changes event ingestion or cleaning, event or property reads, generated SQL over events, or schema-specific snapshots. Add the label while the PR is a draft so `ready_for_review` starts the run. If the PR must open ready, label it immediately and push another commit because label events do not start Backend CI. Leave unrelated PRs unlabeled because the label doubles the backend test matrices.
- **A pull request never publishes a package or release.** `[lint: github-actions-publish-on-pull-request]` A published version is public forever, and a pull request run executes code its author controls. Publish only from a `push` to `master`, a release tag, or a `workflow_dispatch` on `master`. A pull request run only builds and validates, for example with `--dry-run`. The semgrep rule cannot see a publisher inside a reusable workflow, so gate that job in the called workflow too. Never run a publish command by hand from a pull request branch. [`build-hogql-parser-npm.yml`](.github/workflows/build-hogql-parser-npm.yml) is the reference shape.
## Security