: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(ci): run the hourly events_json leg every third hour (#106831)
Raúl Negrón-Otero52f9faa68a92
diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.ymlindex aa23210d0cd9..d5d139aae087 100644--- a/.depot/workflows/ci-backend.yml+++ b/.depot/workflows/ci-backend.yml@@ -45,7 +45,8 @@# turbo-discover / get_clickhouse_versions). A sampling trial must not run on a timer, so# the schedule trigger and canonical's per-commit-vs-scheduled splits (the `!= 'schedule'`# gates on check-migrations / check-openapi-types / repo-checks, report-test-timings' push-# exclusion, and the paths-filter schedule skip) are depot-exempt.+# exclusion, the paths-filter schedule skip, and build_django_matrix's RUN_JSON_TARGETS+# check of the EVENTS_JSON_SCHEDULE cron) are depot-exempt.# - mirror-schema-cache: canonical's master run copies the migrated schema dump out of the# migrated-schema artifact into GitHub Actions Cache, so fork PRs (which run without# secrets and cannot authenticate to Depot Cache) prime instead of migrating from scratch.diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.ymlindex 200376c3d5e8..2caf699b7a9e 100644--- a/.github/workflows/ci-backend.yml+++ b/.github/workflows/ci-backend.yml@@ -12,7 +12,11 @@ on:# longer run the test matrices per commit — the merge queue's trunk-merge/**# run already gated every commit before it landed — so this is where master's# matrix coverage, flaky-test baseline, and per-test timing data come from.- - cron: '23 * * * *'+ # Only the every-third-hour cron runs the events_json leg. The merge queue+ # already runs that leg before every commit lands, and this cadence still gives+ # Trunk's master monitors enough runs. EVENTS_JSON_SCHEDULE in env repeats this string.+ - cron: '23 */3 * * *'+ - cron: '23 1,2,4,5,7,8,10,11,13,14,16,17,19,20,22,23 * * *'workflow_dispatch:inputs:clickhouseServerVersion:@@ -36,8 +40,8 @@ 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.- # The events_json leg runs wherever the legacy tests run, the hourly master run- # included: the paths in .github/new-events-schema-targets.txt rerun against the+ # The events_json leg runs wherever the legacy tests run, and on every third+ # hourly master run: the paths in .github/new-events-schema-targets.txt rerun against the# native-JSON events table, all of them on full runs and the reached ones on# narrowed runs. A PR whose product-only change forced the full run reruns only# that product's paths, because the merge queue runs the whole list before merge.@@ -83,6 +87,9 @@ env:# The root conftest ends a green pytest session with os._exit once every report is written.# That also hides a crash during interpreter teardown, so the hourly schedule exits normally.POSTHOG_PYTEST_HARD_EXIT: ${{ github.event_name == 'schedule' && '0' || '1' }}+ # The on.schedule cron whose runs keep the events_json leg. GitHub cannot reference a cron+ # from an expression, so this copy must match it.+ EVENTS_JSON_SCHEDULE: '23 */3 * * *'CLICKHOUSE_SERVER_IMAGE_VERSION: ${{ github.event.inputs.clickhouseServerVersion || '' }}CLICKHOUSE_COMPAT_PYTEST_TARGETS: 'posthog/clickhouse ee/clickhouse'OBJECT_STORAGE_ENABLED: 'True'@@ -2664,6 +2671,7 @@ jobs:# that takes the whole list.JSON_TARGETS_FILES: ${{ fromJSON(needs.turbo-discover.outputs.selection || '{}').json_targets_files }}JSON_TARGETS_SHARDS: ${{ fromJSON(needs.turbo-discover.outputs.selection || '{}').json_targets_shards }}+ RUN_JSON_TARGETS: ${{ github.event_name != 'schedule' || github.event.schedule == env.EVENTS_JSON_SCHEDULE }}# Same rule as the django job's condition: the suite runs for a legacy# edit, for a product change that reaches legacy code, and when discovery# failed, which leaves run_legacy empty. Without it only the events_json@@ -2979,6 +2987,11 @@ jobs:json_targets_count="${JSON_TARGETS_SHARDS:-0}"fi+ if [[ "$RUN_JSON_TARGETS" != "true" ]]; then+ echo "Skipping the events_json rows on this hourly run"+ json_targets_count=0+ fi+# The events_json rows: Core jobs over the listed paths with the# native-JSON events table. They keep Core's person-on-events default.json_targets=$(jq -cn --arg image "$OLDEST_SUPPORTED_IMAGE" --argjson n "$json_targets_count" 'diff --git a/tools/workflow-plan/tests/workflows.test.ts b/tools/workflow-plan/tests/workflows.test.tsindex 3dfe40637fd2..fd0e7132ff86 100644--- a/tools/workflow-plan/tests/workflows.test.ts+++ b/tools/workflow-plan/tests/workflows.test.ts@@ -543,6 +543,20 @@ describe('.github/workflows run plans', () => {expect(testStep?.run).toMatch(/\bgo test\s+-count=1\b/)})+ it('Backend CI runs once every hour and keeps the events_json leg on one of its crons', () => {+ const backend = workflow('ci-backend.yml')+ const crons = (backend.on as { schedule: { cron: string }[] }).schedule.map((entry) => entry.cron)+ const cronHours = (field: string): number[] =>+ field.startsWith('*/')+ ? [...Array(24).keys()].filter((hour) => hour % Number(field.slice(2)) === 0)+ : field.split(',').map(Number)++ expect(crons).toContain(backend.env?.EVENTS_JSON_SCHEDULE)+ expect(crons.flatMap((cron) => cronHours(cron.split(' ')[1])).sort((a, b) => a - b)).toEqual([+ ...Array(24).keys(),+ ])+ })+it.each([['master schedule', schedule(), 'success', true],['same-repo PR', pullRequest(), 'success', false],