: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
fix(ci): run django test shards on the pr merge commit (#105415)
Raúl Negrón-Otero8b7feada3adc
diff --git a/.depot/actions/commit-snapshots/action.yml b/.depot/actions/commit-snapshots/action.ymlindex 1d37fa23b324..439990b3d9fe 100644--- a/.depot/actions/commit-snapshots/action.yml+++ b/.depot/actions/commit-snapshots/action.yml@@ -80,6 +80,8 @@ runs:for file in $(git apply --numstat "$patch" | cut -f3); doif git apply --check --include="$file" "$patch" 2>/dev/null; thengit apply --index --include="$file" "$patch"+ elif git apply --reverse --check --include="$file" "$patch" 2>/dev/null; then+ echo "Skipping $file from $patch (already applied)"elif [[ "$file" == *.ambr ]] && [ -f "$file" ] \&& grep -F -A1 -- "diff --git a/$file b/$file" "$patch" | grep -q '^new file mode'; thenextract_dir=$(mktemp -d)@@ -89,7 +91,9 @@ runs:git add -- "$file"echo "Merged $file from $patch"else- echo "::warning::$file in $patch could not be applied — skipping that file"+ # marker: snapshot-conflict-exit. ci-backend.yml refuses a PR head whose copy of this action lacks it.+ echo "::error::$file in $patch could not be applied. Rebase onto master and push again."+ exit 1fidonefidiff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.ymlindex 5e44c3bd8735..ca17b2cb79b3 100644--- a/.depot/workflows/ci-backend.yml+++ b/.depot/workflows/ci-backend.yml@@ -1310,7 +1310,6 @@ jobs:# pytest-split flags must not leak from that shard onto its job-mates.env:PRODUCT_LEGS: ${{ toJSON(matrix.legs) }}- # Read only when an unrebased branch planned the pre-legs shape.LEGACY_FILTERS: ${{ matrix.filters }}LEGACY_PYTEST_ARGS: ${{ matrix.pytest_args }}CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA: ${{ matrix.new-events-schema && 'true' || 'false' }}@@ -1320,9 +1319,8 @@ jobs:# tested in the legacy joined mode, and its snapshots record SQL that no# recent project executes. Tests that need the legacy mode pin it# themselves with override_settings.- # marker: product-poe-default. The run block below greps the checked-out- # workflow for this token to tell a head that carries the flip from one- # that predates it.+ # marker: product-poe-default. The run block keeps legacy mode if the+ # checked-out workflow lacks this marker and its matching snapshots.PERSON_ON_EVENTS_V2_ENABLED: 'true'# products/tasks/backend/temporal moved here from the Django Temporal# segment, and its conftest and workflows talk to Modal. Injected only@@ -1350,24 +1348,17 @@ jobs:shell: bashrun: |set +e- # Open PR heads must have retry diagnostics before blanket retries are enabled.+ # Enable retries only when the checkout includes retry diagnostics.if grep -qF '"posthog.runner_name"' posthog/conftest.py; thenexport PYTEST_ADDOPTS="$PYTEST_ADDOPTS --force-reruns 1 --reruns-delay 1 -r fEsxXR"fioverall=0- # The job checks out the PR head while this workflow runs merged with- # master. A head that predates the person-on-events default lacks the- # snapshots regenerated under that mode, so keep it on the legacy mode- # until it rebases. Without this a fork or 'no-snapshot-update' PR, which- # checks snapshots rather than updating them, fails on queries it never- # changed. The marker sits on this step's env line in the checked-out copy.+ # A checkout without the matching snapshots must use legacy mode.if [[ "$PERSON_ON_EVENTS_V2_ENABLED" == "true" ]] && ! grep -qF "marker: product-poe-default" .github/workflows/ci-backend.yml; thenecho "::notice::Checked-out revision predates the person-on-events default, running product tests in legacy mode"export PERSON_ON_EVENTS_V2_ENABLED=falsefi- # A workflow edit reaches an open PR before the script edit does, so a- # branch that has not rebased still plans the flat {filters, pytest_args}- # shape. Normalize that into one leg rather than requiring the new key.+ # Accept a selector that returns the older flat matrix shape.if [ -z "$PRODUCT_LEGS" ] || [ "$PRODUCT_LEGS" = "null" ]; thenPRODUCT_LEGS=$(jq -cn --arg f "$LEGACY_FILTERS" --arg a "$LEGACY_PYTEST_ARGS" \'[{filters: $f, pytest_args: $a}]')@@ -2815,11 +2806,11 @@ jobs:matrix:include: ${{ fromJson(needs.build_django_matrix.outputs.include) }}steps:+ # The default ref, which is the PR merge commit. turbo-discover selects the test files+ # from this tree, so a checkout of any other ref can lack a file that the selection lists.- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:fetch-depth: 1- repository: ${{ github.event.pull_request.head.repo.full_name }}- ref: ${{ github.event.pull_request.head.ref }}lfs: trueclean: false- name: Install signal-fanout@@ -2872,11 +2863,7 @@ jobs:client-id: ${{ vars.GH_APP_POSTHOG_DEVEX_GENERAL_APP_ID }}private-key: ${{ secrets.GH_APP_POSTHOG_DEVEX_GENERAL_PRIVATE_KEY }}skip-token-revoke: true- # Tool cache steps inlined rather than the setup-python-cached composite:- # this job checks out the PR head ref, which cannot resolve a local- # action that only exists on master until the branch rebases. The- # restore sits before setup-python so the tool cache is warm when it- # starts.+ # Restore before setup-python so the tool cache is warm when it starts.- name: Restore Python tool cacheid: python-toolcacheuses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3@@ -2892,8 +2879,6 @@ jobs:with:python-version: ${{ matrix.python-version }}token: ${{ steps.setup-gh-token.outputs.token || github.token }}- # setup-sqlx-cli resolves from the PR head ref here, so an unrebased branch- # gets a version that installs no Rust. Delete once open branches rebase.- name: Install Rustif: needs.changes.outputs.backend == 'true'uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9@@ -3246,28 +3231,21 @@ jobs:run: |unset GITHUB_TOKEN # reserved var injected by Depot CI; can't override via env: (see workflow env note)set +e- # Open PR heads must have retry diagnostics before blanket retries are enabled.+ # Enable retries only when the checkout includes retry diagnostics.RETRY_ARGS=()if grep -qF '"posthog.runner_name"' posthog/conftest.py; thenRETRY_ARGS=(--force-reruns 1 --reruns-delay 1)fi- # Unrebased branches predate .github/coverage-core.cfg; an explicit --cov-config- # pointing at a missing file is a hard error, so drop coverage rather than fail.+ # A missing --cov-config file aborts pytest, so skip coverage if it is absent.if [[ -n "$COV_ARGS" && ! -f .github/coverage-core.cfg ]]; thenCOV_ARGS=""fi- # The job checks out the PR head while this workflow runs merged with- # master. A head that predates the person-on-events default lacks the- # test pins that came with it, so keep it on the legacy mode until it- # rebases. The marker sits on this step's env line in the checked-out copy.+ # A checkout without the matching test pins must use legacy mode.if [[ "$PERSON_ON_EVENTS_V2_ENABLED" == "true" ]] && ! grep -qF "marker: person-on-events-default" .github/workflows/ci-backend.yml; thenecho "::notice::Checked-out revision predates the person-on-events default, running Core in legacy mode"export PERSON_ON_EVENTS_V2_ENABLED=falsefi- # Pick the split algorithm and granularity at runtime: optimal_chunks + file- # granularity only when the installed pytest-split offers them, else- # duration_based_chunks / item. A workflow edit runs merged with master, so an- # unrebased PR on older pytest-split must not hit an unknown flag.+ # Unsupported pytest-split flags abort collection, so probe the installed plugin.SPLITTING_ALGORITHM=duration_based_chunksSPLIT_GRANULARITY=()if python -c "from pytest_split.algorithms import Algorithms; from pytest_split.plugin import PytestSplitFilePlugin; raise SystemExit(0 if 'optimal_chunks' in Algorithms.names() else 1)" 2>/dev/null; then@@ -3598,10 +3576,7 @@ jobs:if-no-files-found: ignoreretention-days: 1- # Exports TRUNK_CODEOWNERS_PATH for the uploads below, so Trunk attributes each test to- # the team that owns its file. The guard is for an unrebased branch: this job checks out- # the PR head ref, which may predate the script. Without it the uploader keeps reading- # .github/CODEOWNERS, as it did before.+ # The helper sets TRUNK_CODEOWNERS_PATH so Trunk attributes uploaded tests to their owners.- name: Build the Trunk ownership mapif: ${{ needs.wait-for-handoff.outputs.handed_off == 'true' && (!cancelled() && needs.changes.outputs.backend == 'true' && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' && vars.TRUNK_UPLOAD_ENABLED == 'true') }}shell: bash@@ -3661,32 +3636,22 @@ jobs:# Fully expanded compat matrix (version x shard group)compat_matrix: ${{ steps.read-versions.outputs.compat_matrix }}steps:- # Merge ref, for turbo-tests: it checks out the merge ref and mounts that config.xml.- - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- with:- sparse-checkout: .github/clickhouse-versions.json- sparse-checkout-cone-mode: false- # Head ref, for django: it checks out the PR head and mounts that config.xml. Reading- # its version from the merge ref instead would split an atomic version+config bump.+ # Merge ref: turbo-tests and django check out the merge ref and mount its config.xml.+ # Reading the version from another ref would split an atomic version+config bump.- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:- repository: ${{ github.event.pull_request.head.repo.full_name }}- ref: ${{ github.event.pull_request.head.ref }}sparse-checkout: .github/clickhouse-versions.jsonsparse-checkout-cone-mode: false- path: head-tree- name: Read ClickHouse versions from JSONid: read-versions- env:- DJANGO_VERSIONS: head-tree/.github/clickhouse-versions.jsonrun: |compat_shards="2"echo "Using $compat_shards shard(s) per compat version"# Oldest supported version for main Django tests (for max compatibility)- oldest_supported=$(jq -r '.oldest_supported' "$DJANGO_VERSIONS")+ oldest_supported=$(jq -r '.oldest_supported' .github/clickhouse-versions.json)if [ -z "$oldest_supported" ] || [ "$oldest_supported" = "null" ]; then- echo "::error::No oldest_supported version found in $DJANGO_VERSIONS"+ echo "::error::No oldest_supported version found in .github/clickhouse-versions.json"exit 1fiecho "oldest_supported_image=$oldest_supported" >> $GITHUB_OUTPUT@@ -3702,15 +3667,15 @@ jobs:echo "Local dev/hobby image for product tests: $local_image"# Read all unique versions so we can derive compat coverage.- all=$(jq -c '[.[]] | unique' "$DJANGO_VERSIONS")+ all=$(jq -c '[.[]] | unique' .github/clickhouse-versions.json)if [ "$all" = "[]" ] || [ -z "$all" ]; then- echo "::error::No versions found in $DJANGO_VERSIONS"+ echo "::error::No versions found in .github/clickhouse-versions.json"exit 1fiecho "All CH versions found: $all"# Compat coverage is only needed for non-oldest versions.- compat_versions=$(jq -c --arg oldest "$oldest_supported" '[.[]] | unique | map(select(. != $oldest))' "$DJANGO_VERSIONS")+ compat_versions=$(jq -c --arg oldest "$oldest_supported" '[.[]] | unique | map(select(. != $oldest))' .github/clickhouse-versions.json)echo "Compat versions (excluding oldest): $compat_versions"compat_count=$(jq -r 'length' <<< "$compat_versions")@@ -3791,13 +3756,13 @@ jobs:token: ${{ steps.app-token.outputs.token }}fetch-depth: 1- # The commit action loads from the PR head, and a head that predates it would fail- # with "action manifest not found" instead of saying what to do.- - name: Require a PR head with the commit action- if: steps.check-patches.outputs.has-patches == 'true' && hashFiles('.depot/actions/commit-snapshots/action.yml') == ''+ - name: Require snapshot conflict checks+ if: steps.check-patches.outputs.has-patches == 'true'run: |- echo "::error::This PR head predates Depot CI snapshot commits. Rebase onto master so CI can commit the updated snapshots."- exit 1+ if ! grep -Fq 'marker: snapshot-conflict-exit' .depot/actions/commit-snapshots/action.yml; then+ echo "::error::Rebase onto master before committing snapshots. This PR head cannot reject conflicting snapshot patches."+ exit 1+ fi- name: Get app token for CI report# continue-on-error: an empty token skips the CI report section, not the commit.diff --git a/.github/actions/commit-snapshots/action.yml b/.github/actions/commit-snapshots/action.ymlindex 00c63ed365ef..886e949afb04 100644--- a/.github/actions/commit-snapshots/action.yml+++ b/.github/actions/commit-snapshots/action.yml@@ -71,6 +71,8 @@ runs:for file in $(git apply --numstat "$patch" | cut -f3); doif git apply --check --include="$file" "$patch" 2>/dev/null; thengit apply --index --include="$file" "$patch"+ elif git apply --reverse --check --include="$file" "$patch" 2>/dev/null; then+ echo "Skipping $file from $patch (already applied)"elif [[ "$file" == *.ambr ]] && [ -f "$file" ] \&& grep -F -A1 -- "diff --git a/$file b/$file" "$patch" | grep -q '^new file mode'; thenextract_dir=$(mktemp -d)@@ -80,7 +82,9 @@ runs:git add -- "$file"echo "Merged $file from $patch"else- echo "::warning::$file in $patch could not be applied — skipping that file"+ # marker: snapshot-conflict-exit. ci-backend.yml refuses a PR head whose copy of this action lacks it.+ echo "::error::$file in $patch could not be applied. Rebase onto master and push again."+ exit 1fidonefidiff --git a/.github/scripts/test_ci_snapshot_patches.py b/.github/scripts/test_ci_snapshot_patches.pynew file mode 100644index 000000000000..4691f0ce37af--- /dev/null+++ b/.github/scripts/test_ci_snapshot_patches.py@@ -0,0 +1,61 @@+import os+import textwrap+import subprocess+from pathlib import Path++import pytest++ROOT = Path(__file__).resolve().parents[2]++[email protected]("engine", [".github", ".depot"])[email protected]("conflict", [False, True], ids=["overlapping-patches", "conflicting-patches"])+def test_snapshot_patches_skip_applied_files_but_reject_conflicts(engine: str, conflict: bool, tmp_path: Path) -> None:+ repo = tmp_path / "repo"+ repo.mkdir()++ def git(*args: str) -> str:+ return subprocess.check_output(["git", "-C", str(repo), *args], text=True)++ git("init", "-q")+ for name in ("a.snap", "b.snap"):+ (repo / name).write_text("old\n")+ git("add", ".")+ git(+ "-c",+ "user.name=CI fixture",+ "-c",+ "[email protected]",+ "-c",+ "commit.gpgsign=false",+ "commit",+ "-qm",+ "fixture",+ )+ for name in ("a.snap", "b.snap"):+ (repo / name).write_text("new\n")+ patches = tmp_path / "patches"+ patches.mkdir()+ (patches / "shard.patch").write_text(git("diff"))+ git("checkout", "--", ".")+ (repo / "a.snap").write_text("conflicting\n" if conflict else "new\n")+ git("add", "a.snap")++ action = (ROOT / engine / "actions/commit-snapshots/action.yml").read_text()+ step = action.split("- name: Apply snapshot patches\n", 1)[1].split("\n - name:", 1)[0]+ script = textwrap.dedent(step.split("run: |\n", 1)[1])+ result = subprocess.run(+ ["bash", "-eo", "pipefail", "-c", script],+ cwd=repo,+ env={**os.environ, "PATCH_PATH": str(patches)},+ capture_output=True,+ text=True,+ )+ if conflict:+ assert result.returncode != 0+ assert "could not be applied" in result.stdout+ assert (repo / "a.snap").read_text() == "conflicting\n"+ else:+ assert result.returncode == 0, result.stdout + result.stderr+ assert (repo / "a.snap").read_text() == "new\n"+ assert (repo / "b.snap").read_text() == "new\n"diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.ymlindex 6b91104e4a1f..77758e96da06 100644--- a/.github/workflows/ci-backend.yml+++ b/.github/workflows/ci-backend.yml@@ -1153,7 +1153,6 @@ jobs:# pytest-split flags must not leak from that shard onto its job-mates.env:PRODUCT_LEGS: ${{ toJSON(matrix.legs) }}- # Read only when an unrebased branch planned the pre-legs shape.LEGACY_FILTERS: ${{ matrix.filters }}LEGACY_PYTEST_ARGS: ${{ matrix.pytest_args }}CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA: ${{ matrix.new-events-schema && 'true' || 'false' }}@@ -1163,9 +1162,8 @@ jobs:# tested in the legacy joined mode, and its snapshots record SQL that no# recent project executes. Tests that need the legacy mode pin it# themselves with override_settings.- # marker: product-poe-default. The run block below greps the checked-out- # workflow for this token to tell a head that carries the flip from one- # that predates it.+ # marker: product-poe-default. The run block keeps legacy mode if the+ # checked-out workflow lacks this marker and its matching snapshots.PERSON_ON_EVENTS_V2_ENABLED: 'true'# products/tasks/backend/temporal moved here from the Django Temporal# segment, and its conftest and workflows talk to Modal. Injected only@@ -1196,24 +1194,17 @@ jobs:shell: bashrun: |set +e- # Open PR heads must have retry diagnostics before blanket retries are enabled.+ # Enable retries only when the checkout includes retry diagnostics.if grep -qF '"posthog.runner_name"' posthog/conftest.py; thenexport PYTEST_ADDOPTS="$PYTEST_ADDOPTS --force-reruns 1 --reruns-delay 1 -r fEsxXR"fioverall=0- # The job checks out the PR head while this workflow runs merged with- # master. A head that predates the person-on-events default lacks the- # snapshots regenerated under that mode, so keep it on the legacy mode- # until it rebases. Without this a fork or 'no-snapshot-update' PR, which- # checks snapshots rather than updating them, fails on queries it never- # changed. The marker sits on this step's env line in the checked-out copy.+ # A checkout without the matching snapshots must use legacy mode.if [[ "$PERSON_ON_EVENTS_V2_ENABLED" == "true" ]] && ! grep -qF "marker: product-poe-default" .github/workflows/ci-backend.yml; thenecho "::notice::Checked-out revision predates the person-on-events default, running product tests in legacy mode"export PERSON_ON_EVENTS_V2_ENABLED=falsefi- # A workflow edit reaches an open PR before the script edit does, so a- # branch that has not rebased still plans the flat {filters, pytest_args}- # shape. Normalize that into one leg rather than requiring the new key.+ # Accept a selector that returns the older flat matrix shape.if [ -z "$PRODUCT_LEGS" ] || [ "$PRODUCT_LEGS" = "null" ]; thenPRODUCT_LEGS=$(jq -cn --arg f "$LEGACY_FILTERS" --arg a "$LEGACY_PYTEST_ARGS" \'[{filters: $f, pytest_args: $a}]')@@ -3038,11 +3029,11 @@ jobs:DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}steps:+ # The default ref, which is the PR merge commit. turbo-discover selects the test files+ # from this tree, so a checkout of any other ref can lack a file that the selection lists.- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:fetch-depth: 1- repository: ${{ github.event.pull_request.head.repo.full_name }}- ref: ${{ github.event.pull_request.head.ref }}lfs: trueclean: false@@ -3108,11 +3099,7 @@ jobs:private-key: ${{ secrets.GH_APP_POSTHOG_DEVEX_GENERAL_PRIVATE_KEY }}skip-token-revoke: true- # Tool cache steps inlined rather than the setup-python-cached composite:- # this job checks out the PR head ref, which cannot resolve a local- # action that only exists on master until the branch rebases. The- # restore sits before setup-python so the tool cache is warm when it- # starts.+ # Restore before setup-python so the tool cache is warm when it starts.- name: Restore Python tool cacheid: python-toolcacheuses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3@@ -3130,8 +3117,6 @@ jobs:python-version: ${{ matrix.python-version }}token: ${{ steps.setup-gh-token.outputs.token || github.token }}- # setup-sqlx-cli resolves from the PR head ref here, so an unrebased branch- # gets a version that installs no Rust. Delete once open branches rebase.- name: Install Rustif: needs.changes.outputs.backend == 'true'uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9@@ -3553,29 +3538,21 @@ jobs:shell: 'signal-fanout bash --noprofile --norc -eo pipefail {0}'run: |set +e- # Open PR heads must have retry diagnostics before blanket retries are enabled.+ # Enable retries only when the checkout includes retry diagnostics.RETRY_ARGS=()if grep -qF '"posthog.runner_name"' posthog/conftest.py; thenRETRY_ARGS=(--force-reruns 1 --reruns-delay 1)fi- # Unrebased branches predate .github/coverage-core.cfg; an explicit --cov-config- # pointing at a missing file is a hard error, so drop coverage rather than fail.+ # A missing --cov-config file aborts pytest, so skip coverage if it is absent.if [[ -n "$COV_ARGS" && ! -f .github/coverage-core.cfg ]]; thenCOV_ARGS=""fi- # The job checks out the PR head while this workflow runs merged with- # master. A head that predates the person-on-events default lacks the- # test pins that came with it, so keep it on the legacy mode until it- # rebases. The marker sits on this step's env line in the checked-out copy.+ # A checkout without the matching test pins must use legacy mode.if [[ "$PERSON_ON_EVENTS_V2_ENABLED" == "true" ]] && ! grep -qF "marker: person-on-events-default" .github/workflows/ci-backend.yml; thenecho "::notice::Checked-out revision predates the person-on-events default, running Core in legacy mode"export PERSON_ON_EVENTS_V2_ENABLED=falsefi- # Pick the split algorithm and granularity at runtime: optimal_chunks +- # file granularity only when the installed pytest-split offers them, else- # duration_based_chunks / item. A workflow edit runs merged with master, so- # an unrebased PR on older pytest-split must not hit an unknown- # --splitting-algorithm / --split-granularity. See AGENTS.md (CI).+ # Unsupported pytest-split flags abort collection, so probe the installed plugin.SPLITTING_ALGORITHM=duration_based_chunksSPLIT_GRANULARITY=()if python -c "from pytest_split.algorithms import Algorithms; from pytest_split.plugin import PytestSplitFilePlugin; raise SystemExit(0 if 'optimal_chunks' in Algorithms.names() else 1)" 2>/dev/null; then@@ -3929,10 +3906,7 @@ jobs:junit-*.xml!junit-*-retry-failures.xml- # Exports TRUNK_CODEOWNERS_PATH for the uploads below, so Trunk attributes each test to- # the team that owns its file. The guard is for an unrebased branch: this job checks out- # the PR head ref, which may predate the script. Without it the uploader keeps reading- # .github/CODEOWNERS, as it did before.+ # The helper sets TRUNK_CODEOWNERS_PATH so Trunk attributes uploaded tests to their owners.- name: Build the Trunk ownership mapif: ${{ !cancelled() && needs.changes.outputs.backend == 'true' && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' && vars.TRUNK_UPLOAD_ENABLED == 'true' }}shell: bash@@ -3947,9 +3921,7 @@ jobs:# skips, so nothing uploads and no known flakes are quarantined. TRUNK_QUARANTINE_ENABLED# splits the two — it defaults off, so set it to 'true' to let the verdict step below mask# known flakes; otherwise any real failure reds the job (quarantining needs upload on too).- # Inlined rather than ./.github/actions/trunk-quarantine-gate, and so without its retry:- # this job checks out the PR head ref, which cannot resolve a local action that only- # exists on master until the branch rebases.+ # This inlined gate lacks the shared action's retry.- name: Quarantine gate (Core)id: quarantine_gate_corecontinue-on-error: true@@ -4004,32 +3976,22 @@ jobs:# Fully expanded compat matrix (version x shard group)compat_matrix: ${{ steps.read-versions.outputs.compat_matrix }}steps:- # Merge ref, for turbo-tests: it checks out the merge ref and mounts that config.xml.+ # Merge ref: turbo-tests and django check out the merge ref and mount its config.xml.+ # Reading the version from another ref would split an atomic version+config bump.- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:sparse-checkout: .github/clickhouse-versions.jsonsparse-checkout-cone-mode: false- # Head ref, for django: it checks out the PR head and mounts that config.xml. Reading- # its version from the merge ref instead would split an atomic version+config bump.- - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- with:- repository: ${{ github.event.pull_request.head.repo.full_name }}- ref: ${{ github.event.pull_request.head.ref }}- sparse-checkout: .github/clickhouse-versions.json- sparse-checkout-cone-mode: false- path: head-tree- name: Read ClickHouse versions from JSONid: read-versions- env:- DJANGO_VERSIONS: head-tree/.github/clickhouse-versions.jsonrun: |compat_shards="2"echo "Using $compat_shards shard(s) per compat version"# Oldest supported version for main Django tests (for max compatibility)- oldest_supported=$(jq -r '.oldest_supported' "$DJANGO_VERSIONS")+ oldest_supported=$(jq -r '.oldest_supported' .github/clickhouse-versions.json)if [ -z "$oldest_supported" ] || [ "$oldest_supported" = "null" ]; then- echo "::error::No oldest_supported version found in $DJANGO_VERSIONS"+ echo "::error::No oldest_supported version found in .github/clickhouse-versions.json"exit 1fiecho "oldest_supported_image=$oldest_supported" >> $GITHUB_OUTPUT@@ -4045,15 +4007,15 @@ jobs:echo "Local dev/hobby image for product tests: $local_image"# Read all unique versions so we can derive compat coverage.- all=$(jq -c '[.[]] | unique' "$DJANGO_VERSIONS")+ all=$(jq -c '[.[]] | unique' .github/clickhouse-versions.json)if [ "$all" = "[]" ] || [ -z "$all" ]; then- echo "::error::No versions found in $DJANGO_VERSIONS"+ echo "::error::No versions found in .github/clickhouse-versions.json"exit 1fiecho "All CH versions found: $all"# Compat coverage is only needed for non-oldest versions.- compat_versions=$(jq -c --arg oldest "$oldest_supported" '[.[]] | unique | map(select(. != $oldest))' "$DJANGO_VERSIONS")+ compat_versions=$(jq -c --arg oldest "$oldest_supported" '[.[]] | unique | map(select(. != $oldest))' .github/clickhouse-versions.json)echo "Compat versions (excluding oldest): $compat_versions"compat_count=$(jq -r 'length' <<< "$compat_versions")@@ -4137,6 +4099,14 @@ jobs:token: ${{ steps.app-token.outputs.token }}fetch-depth: 1+ - name: Require snapshot conflict checks+ if: steps.check-patches.outputs.has-patches == 'true'+ run: |+ if ! grep -Fq 'marker: snapshot-conflict-exit' .github/actions/commit-snapshots/action.yml; then+ echo "::error::Rebase onto master before committing snapshots. This PR head cannot reject conflicting snapshot patches."+ exit 1+ fi+- name: Commit snapshotsif: steps.check-patches.outputs.has-patches == 'true'uses: ./.github/actions/commit-snapshotsdiff --git a/docs/internal/ci-test-retries.md b/docs/internal/ci-test-retries.mddeleted file mode 100644index 2c986739cc0b..000000000000--- a/docs/internal/ci-test-retries.md+++ /dev/null@@ -1,48 +0,0 @@-# CI retries and Trunk--Retry failed tests in the test runner and retain each failed attempt in the uploaded JUnit report.-A passing retry can pass CI.-A test that fails its retry must still fail the test command.-The existing Trunk gate can clear failures for quarantined tests.-An upload failure does not turn a failed test command into a pass.--## Suites connected to Trunk--| Suite | Retry budget | Failed-attempt report |-| ----------------------------------------------- | -------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |-| Backend pytest: core, Temporal, products | One in CI | Separate JUnit reports retain failed attempts; see [PR #101493](https://github.com/PostHog/posthog/pull/101493) |-| Frontend Jest, Node.js Jest, replay-shared Jest | One in CI | Shared setup enables error recording; patched `jest-junit` emits retry children |-| Storybook | Two, as configured by its test runner | Patched `jest-junit` emits retry children |-| Playwright E2E | One in normal CI; zero in the audit workflow | Built-in JUnit reporter with `includeRetries: true` |-| Rust nextest | One in the CI profile | Built-in JUnit retry children |--Jest retries after the other tests in the file.-Local Jest commands do not enable the shared CI retry setting.-Existing suite-specific overrides still apply.--The `jest-junit` patch preserves the existing test names, file paths, counts, and final results.-It adds `flakyFailure` for a passing retry and `rerunFailure` for earlier attempts when the final attempt fails.-`logErrorsBeforeRetry: true` is required so Jest retains `retryReasons` for the reporter.--Trunk CLI 0.15.4 is pinned in the shared upload action and the inline Playwright upload step.-Its [parser and regression tests](https://github.com/trunk-io/analytics-cli/blob/0.15.4/context/src/junit/parser.rs) retain retry children as separate attempts.-The published [Trunk Playwright guide](https://docs.trunk.io/flaky-tests/get-started/frameworks/playwright) and [pytest guide](https://docs.trunk.io/flaky-tests/get-started/frameworks/pytest) still recommend disabling retries.-Use the released parser behavior and validate the actual report when a runner changes.--## Validation and rollout--Use a temporary test that fails once and then passes, plus a test that fails every attempt.-Check the command exit code and the XML for both cases.-Run `trunk-analytics-cli validate --junit-paths '<report path>'` before uploading; this command does not upload data.-The [Playwright reporter reference](https://playwright.dev/docs/test-reporters#junit-reporter) and [nextest retry reference](https://nexte.st/docs/features/retries/) describe their report settings.--After merge, inspect one recovered test from each suite in Trunk.-Confirm that it has both a failed and a passed attempt under the same identity.-Check the existing Engineering analytics attempt counts and recovered-test outcomes.-Track quarantine growth and CI failures after the change: more visible retry failures can produce more quarantine decisions.--## Other test jobs--This configuration covers the suites with Trunk upload gates.-Standalone Vitest jobs, Go jobs, Rust doctests, and separate desktop workflows need their own report and exit-code checks before adopting the same policy.-Lint, type checks, builds, test discovery errors, and process crashes do not receive a test retry.