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: gate CI on trunk auto-quarantine and drop test reruns (#68290)

Paul D'Ambra9027b1795162
diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.yml
index 02adac4dec52..13bac15a9a87 100644
--- a/.depot/workflows/ci-backend.yml
+++ b/.depot/workflows/ci-backend.yml
@@ -14,9 +14,12 @@
# - permissions: pull-requests:read (no comment/auto-commit side effects)
# - Stripped side effects: artifact uploads, PR comment posters, snapshot
# auto-commit (handle-snapshots), posthog-github-action telemetry,
-# --store-durations write, test-selection verdict, Trunk flaky-test upload
-# (trunk-upload — the shadow strips the junit artifact uploads it would aggregate,
-# and must not post to the external Trunk service from a non-blocking timing trial)
+# --store-durations write, test-selection verdict, Trunk flaky-test quarantine
+# gate (canonical runs per-shard analytics-uploader steps that post to the
+# external Trunk service and gate the job on the quarantine list; the shadow
+# strips them — no Trunk posting from a non-blocking timing trial — and so also
+# omits the test steps' continue-on-error and the fork/no-gate failure
+# fallbacks that exist only to hand the pass/fail verdict to that gate)
# - OpenAPI types: the check-openapi-types job is folded into check-migrations as a
# check-only step (drift still fails the run); only its auto-commit side effect is dropped
# - actions/cache reads/writes route to Depot Cache, not GitHub Actions Cache,
@@ -1638,9 +1641,9 @@ jobs:
fi
if [[ "$MODE" == "selected" ]]; then
# Selected mode: run only the test files chosen by the snob shadow selector.
- # No --splits/--group (no sharding), no --reruns (selected runs should fail
- # loud so flaky tests get fixed instead of masked; the ready-for-review full
- # run has reruns).
+ # No --splits/--group (no sharding), and no --reruns in selected mode. The full
+ # run keeps a reduced --reruns 1 cold-start net, mirroring canonical (which runs
+ # it until Trunk's quarantine list matures; the shadow strips the gate itself).
if [[ "${{ matrix.person-on-events }}" == "true" ]]; then
targets="$POE_FILES"
else
@@ -1671,7 +1674,7 @@ jobs:
--pytest-durations=100 \
--splitting-algorithm="$SPLITTING_ALGORITHM" \
"${SPLIT_GRANULARITY[@]}" \
- --reruns 2 --reruns-delay 1 \
+ --reruns 1 --reruns-delay 1 \
-r fEsxX \
--junitxml=junit-core.xml \
$PYTEST_ARGS
@@ -1739,8 +1742,8 @@ jobs:
# two timeout tests fail downstream (hogql_table never reached). Canonical GHA still runs them.
# The --deselect guards stay on both branches so a selected run can't re-enable them.
if [[ "$MODE" == "selected" ]]; then
- # Selected mode: no sharding, no --reruns (fail loud; the ready full
- # run still reruns). See the core selected branch for the rationale.
+ # Selected mode: no sharding, no --reruns — see the core selected branch;
+ # the full run keeps a reduced --reruns 1 cold-start net mirroring canonical.
# shellcheck disable=SC2086
pytest -v --tb=short --reuse-db -o junit_duration_report=call $TEMPORAL_FILES -m "not async_migrations" \
--deselect "posthog/temporal/tests/data_modeling/test_run_workflow.py::test_run_workflow_with_minio_bucket" \
@@ -1762,7 +1765,7 @@ jobs:
--pytest-durations=100 \
--splitting-algorithm="$SPLITTING_ALGORITHM" \
"${SPLIT_GRANULARITY[@]}" \
- --reruns 2 --reruns-delay 1 \
+ --reruns 1 --reruns-delay 1 \
-r fEsxX \
--junitxml=junit-temporal.xml \
$PYTEST_ARGS
diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml
index e0c68707f42b..d8fecfc1885f 100644
--- a/.github/workflows/ci-backend.yml
+++ b/.github/workflows/ci-backend.yml
@@ -2476,6 +2476,10 @@ jobs:
- name: Run Core tests
id: run-core-tests
+ # continue-on-error so a test failure doesn't fail the job here; the
+ # quarantine gate at the end of the job is the verdict — it passes when
+ # every failure is an already-quarantined flake, fails otherwise.
+ continue-on-error: true
if: ${{ needs.changes.outputs.backend == 'true' && matrix.segment == 'Core' }}
env:
PERSON_ON_EVENTS_V2_ENABLED: ${{ matrix.person-on-events && 'true' || 'false' }}
@@ -2514,8 +2518,9 @@ jobs:
if [[ "$MODE" == "selected" ]]; then
# Selected mode: run only the test files chosen by the snob shadow selector.
# No --splits/--group (no sharding), no --store-durations (don't pollute timing
- # data with a partial run), no --reruns (selected runs should fail loud so flaky
- # tests get fixed instead of masked; the ready-for-review full run has reruns).
+ # data with a partial run), and no --reruns (fail loud on the narrow subset).
+ # The full run below keeps a reduced --reruns 1 as a cold-start net while Trunk's
+ # quarantine list matures; drop it back to 0 once quarantine reliably catches flakes.
if [[ "${{ matrix.person-on-events }}" == "true" ]]; then
targets="$POE_FILES"
else
@@ -2546,7 +2551,7 @@ jobs:
--pytest-durations=100 \
--splitting-algorithm="$SPLITTING_ALGORITHM" \
"${SPLIT_GRANULARITY[@]}" \
- --reruns 2 --reruns-delay 1 \
+ --reruns 1 --reruns-delay 1 \
-r fEsxX \
--junitxml=junit-core.xml \
$PYTEST_ARGS
@@ -2589,6 +2594,9 @@ jobs:
- name: Run Temporal tests
id: run-temporal-tests
+ # continue-on-error: the quarantine gate at the end of the job is the verdict.
+ # See "Run Core tests".
+ continue-on-error: true
if: ${{ needs.changes.outputs.backend == 'true' && matrix.segment == 'Temporal' }}
# See "Run Core tests" for why signal-fanout wraps bash here.
shell: 'signal-fanout bash --noprofile --norc -eo pipefail {0}'
@@ -2621,8 +2629,8 @@ jobs:
fi
if [[ "$MODE" == "selected" ]]; then
# Selected mode: no sharding, no --store-durations (don't pollute
- # timing data with a partial run), no --reruns (fail loud; the ready
- # full run still reruns). See the core selected branch for the rationale.
+ # timing data with a partial run), no --reruns. See the core selected branch;
+ # the full run keeps a reduced --reruns 1 cold-start net until quarantine matures.
# shellcheck disable=SC2086
pytest -v --tb=short --reuse-db -o junit_duration_report=call $TEMPORAL_FILES -m "not async_migrations" \
-r fEsxX \
@@ -2641,7 +2649,7 @@ jobs:
--pytest-durations=100 \
--splitting-algorithm="$SPLITTING_ALGORITHM" \
"${SPLIT_GRANULARITY[@]}" \
- --reruns 2 --reruns-delay 1 \
+ --reruns 1 --reruns-delay 1 \
-r fEsxX \
--junitxml=junit-temporal.xml \
$PYTEST_ARGS
@@ -2673,14 +2681,14 @@ jobs:
- name: Verify new snapshots for flakiness
# Only in UPDATE mode - CHECK mode doesn't update snapshots
- if: ${{ needs.detect-snapshot-mode.outputs.mode == 'update' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog' && needs.changes.outputs.backend == 'true' && !matrix.person-on-events && !matrix.compat }}
+ if: ${{ needs.detect-snapshot-mode.outputs.mode == 'update' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog' && needs.changes.outputs.backend == 'true' && !matrix.person-on-events && !matrix.compat && steps.run-core-tests.outcome != 'failure' && steps.run-temporal-tests.outcome != 'failure' }}
shell: bash
run: |
.github/scripts/verify-new-snapshots.sh
- name: Generate snapshot patch
# Only in UPDATE mode - CHECK mode verifies snapshots match exactly
- if: ${{ needs.detect-snapshot-mode.outputs.mode == 'update' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog' && needs.changes.outputs.backend == 'true' && !matrix.person-on-events && !matrix.compat }}
+ if: ${{ needs.detect-snapshot-mode.outputs.mode == 'update' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog' && needs.changes.outputs.backend == 'true' && !matrix.person-on-events && !matrix.compat && steps.run-core-tests.outcome != 'failure' && steps.run-temporal-tests.outcome != 'failure' }}
shell: bash
run: |
mkdir -p /tmp/patches
@@ -2696,7 +2704,7 @@ jobs:
- name: Upload snapshot patch
# Only in UPDATE mode
- if: ${{ needs.detect-snapshot-mode.outputs.mode == 'update' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog' && needs.changes.outputs.backend == 'true' && !matrix.person-on-events && !matrix.compat }}
+ if: ${{ needs.detect-snapshot-mode.outputs.mode == 'update' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog' && needs.changes.outputs.backend == 'true' && !matrix.person-on-events && !matrix.compat && steps.run-core-tests.outcome != 'failure' && steps.run-temporal-tests.outcome != 'failure' }}
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: snapshot-patch-${{ matrix.segment }}-${{ matrix.group }}
@@ -2718,6 +2726,36 @@ jobs:
name: junit-results-backend-${{ matrix.artifact_key }}
path: junit-*.xml
+ # Quarantine gate: uploads junit to Trunk and gates the job. Exit 0 when every
+ # failure is an already-quarantined flake, non-zero otherwise (falls back to the
+ # raw test outcome if Trunk is unreachable). Runs the token only on internal PRs,
+ # master, and the merge queue — never on fork PRs or Dependabot, which have no
+ # secret.
+ - name: Quarantine gate (Core)
+ if: ${{ !cancelled() && matrix.segment == 'Core' && needs.changes.outputs.backend == 'true' && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' }}
+ uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
+ with:
+ junit-paths: junit-core.xml
+ org-slug: posthog-inc
+ quarantine: true
+ previous-step-outcome: ${{ steps.run-core-tests.outcome }}
+ token: ${{ secrets.TRUNK_API_TOKEN }}
+ - name: Quarantine gate (Temporal)
+ if: ${{ !cancelled() && matrix.segment == 'Temporal' && needs.changes.outputs.backend == 'true' && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' }}
+ uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
+ with:
+ junit-paths: junit-temporal.xml
+ org-slug: posthog-inc
+ quarantine: true
+ previous-step-outcome: ${{ steps.run-temporal-tests.outcome }}
+ token: ${{ secrets.TRUNK_API_TOKEN }}
+ # No Trunk secret on fork PRs and Dependabot; fall back to the raw test outcome so
+ # a genuine failure still goes red exactly as before.
+ - name: Fail on test failure (no quarantine gate)
+ if: ${{ !cancelled() && needs.changes.outputs.backend == 'true' && (steps.run-core-tests.outcome == 'failure' || steps.run-temporal-tests.outcome == 'failure') && !(env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]') }}
+ shell: bash
+ run: exit 1
+
# Aggregate and commit snapshot changes from all matrix jobs
get_clickhouse_versions:
@@ -3135,31 +3173,3 @@ jobs:
uv run --script .github/scripts/report_test_timings.py \
--min-duration-seconds=0.5 \
./junit-artifacts
-
- trunk-upload:
- name: Upload test results to Trunk
- # Core/Temporal already emit and upload junit-results-* artifacts;
- # this feeds them to Trunk (flaky-test detection) once. Trusted non-pull_request
- # events only (master push + merge queue), so the secret token never runs in a
- # PR-controlled context; the uploader is a pinned external action, not a local one.
- needs: [django_tests]
- runs-on: ubuntu-latest
- continue-on-error: true
- timeout-minutes: 10
- if: always() && github.repository == 'PostHog/posthog' && github.event_name != 'pull_request'
- steps:
- - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- with:
- fetch-depth: 1
- - name: Download JUnit artifacts
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v6.0.0
- continue-on-error: true
- with:
- path: ./junit-artifacts
- pattern: junit-results-*
- - name: Upload to Trunk
- uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
- with:
- junit-paths: junit-artifacts/**/*.xml
- org-slug: posthog-inc
- token: ${{ secrets.TRUNK_API_TOKEN }}
diff --git a/.github/workflows/ci-e2e-playwright.yml b/.github/workflows/ci-e2e-playwright.yml
index 62943423cc32..42dfd41b2def 100644
--- a/.github/workflows/ci-e2e-playwright.yml
+++ b/.github/workflows/ci-e2e-playwright.yml
@@ -14,7 +14,7 @@ on:
workflow_dispatch:
inputs:
playwright_retries:
- description: 'Override Playwright retries (leave empty for default of 3 on CI). Set to "0" to surface true per-test failure rate.'
+ description: 'Override Playwright retries (leave empty for default of 1 on CI — a cold-start net while Trunk quarantine matures). Set to 0 to surface true per-test failure rate.'
required: false
type: string
default: ''
@@ -68,6 +68,7 @@ env:
# Internal API auth needs a non-empty INTERNAL_API_SECRET when DEBUG/TEST are off. The dev value
# matches the Node plugins container's non-prod default, so Django<->Node internal calls authenticate.
INTERNAL_API_SECRET: posthog123
+ RUNS_ON_INTERNAL_PR: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false }}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
@@ -569,20 +570,25 @@ jobs:
- name: Run Playwright tests
id: playwright-tests
+ # continue-on-error so a failure doesn't fail the job here; the quarantine gate
+ # below is the verdict — it passes when every failure is an already-quarantined
+ # flake, fails otherwise.
+ continue-on-error: true
shell: bash
env:
- # The flake-audit workflow (.github/workflows/ci-e2e-playwright-audit.yml)
- # passes PLAYWRIGHT_RETRIES=0 to surface real per-test failure rates.
- # PR/master runs leave this unset and inherit the default (3 retries).
- PLAYWRIGHT_RETRIES: ${{ inputs.playwright_retries }}
+ # Retries default to 1 as a cold-start net while Trunk's quarantine list
+ # matures — a not-yet-classified flake gets one retry instead of reding the PR.
+ # Drop back to 0 once quarantine reliably catches flakes so raw signal reaches
+ # Trunk. The flake-audit workflow still forces 0; workflow_dispatch can override.
+ PLAYWRIGHT_RETRIES: ${{ inputs.playwright_retries || '1' }}
# WARNING: Worker count is tuned to avoid CPU scheduling contention. Talk to #team-devex before changing.
# Reduced from 6+4 to 4+2 to minimize CPU scheduling contention (see PR #46853)
# Capture-only: VR is the gate for visual changes, Playwright just captures screenshots
run: |
- pnpm --filter=@posthog/playwright exec playwright test --workers=4 --max-failures=5 --update-snapshots
+ pnpm --filter=@posthog/playwright exec playwright test --workers=4 --update-snapshots
- name: Verify changed Playwright tests are stable
- if: success() && github.event_name == 'pull_request'
+ if: steps.playwright-tests.outcome == 'success' && github.event_name == 'pull_request'
shell: bash
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
@@ -680,17 +686,26 @@ jobs:
path: playwright/junit-results.xml
if-no-files-found: ignore
- - name: Upload test results to Trunk
- # Flaky-test detection. Trusted non-pull_request events only, so the secret token
- # never runs in a PR-controlled context; continue-on-error so an upload hiccup
- # never fails the job.
- if: ${{ !cancelled() && github.event_name != 'pull_request' }}
- continue-on-error: true
+ # Quarantine gate: uploads junit to Trunk and gates the job. Exit 0 when every
+ # failure is an already-quarantined flake, non-zero otherwise (falls back to the
+ # raw test outcome if Trunk is unreachable). Runs the token only on internal PRs,
+ # master, and the merge queue — never on fork PRs or Dependabot, which have no
+ # secret.
+ - name: Quarantine gate
+ if: ${{ !cancelled() && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' }}
uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
with:
junit-paths: playwright/junit-results.xml
org-slug: posthog-inc
+ quarantine: true
+ previous-step-outcome: ${{ steps.playwright-tests.outcome }}
token: ${{ secrets.TRUNK_API_TOKEN }}
+ # No Trunk secret on fork PRs and Dependabot; fall back to the raw playwright
+ # outcome so a genuine failure still goes red exactly as before.
+ - name: Fail on Playwright failure (no quarantine gate)
+ if: ${{ !cancelled() && steps.playwright-tests.outcome == 'failure' && !(env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]') }}
+ shell: bash
+ run: exit 1
- name: Publish report to Cloudflare Pages
if: always() && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
diff --git a/.github/workflows/ci-frontend.yml b/.github/workflows/ci-frontend.yml
index c9446b8aa8e2..a66296d87f64 100644
--- a/.github/workflows/ci-frontend.yml
+++ b/.github/workflows/ci-frontend.yml
@@ -21,6 +21,9 @@ permissions:
pull-requests: write
actions: read
+env:
+ RUNS_ON_INTERNAL_PR: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false }}
+
jobs:
# Job to decide if we should run frontend ci
# See https://github.com/dorny/paths-filter#conditional-execution for more details
@@ -657,6 +660,11 @@ jobs:
install-command: pnpm --filter=@posthog/frontend... install --frozen-lockfile
- name: Test with Jest
+ id: run-jest
+ # continue-on-error so a failure doesn't fail the job here; the quarantine
+ # gate below is the verdict — it passes when every failure is an
+ # already-quarantined flake, fails otherwise.
+ continue-on-error: true
env:
NODE_OPTIONS: --max-old-space-size=16384
SHARD_INDEX: ${{ matrix.chunk }}
@@ -705,6 +713,29 @@ jobs:
if-no-files-found: ignore
retention-days: 1
+ # Quarantine gate: uploads junit to Trunk and gates the job. Exit 0 when every
+ # failure is an already-quarantined flake, non-zero otherwise (falls back to the
+ # raw test outcome if Trunk is unreachable). FOSS and EE run the same test files,
+ # so each segment uploads under its own variant to keep their histories distinct.
+ # Runs the token only on internal PRs, master, and the merge queue — never on fork
+ # PRs or Dependabot, which have no secret.
+ - name: Quarantine gate
+ if: ${{ !cancelled() && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' }}
+ uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
+ with:
+ junit-paths: junit-results/junit-${{ matrix.segment }}-${{ matrix.chunk }}.xml
+ org-slug: posthog-inc
+ variant: ${{ matrix.segment }}
+ quarantine: true
+ previous-step-outcome: ${{ steps.run-jest.outcome }}
+ token: ${{ secrets.TRUNK_API_TOKEN }}
+ # No Trunk secret on fork PRs and Dependabot; fall back to the raw jest outcome so
+ # a genuine failure still goes red exactly as before.
+ - name: Fail on jest failure (no quarantine gate)
+ if: ${{ !cancelled() && steps.run-jest.outcome == 'failure' && !(env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]') }}
+ shell: bash
+ run: exit 1
+
jest-replay-shared:
runs-on: ubuntu-latest
timeout-minutes: 10
@@ -721,8 +752,45 @@ jobs:
uses: ./.github/actions/pnpm-install
- name: Test with Jest
+ id: run-jest
+ # continue-on-error so the quarantine gate below is the verdict.
+ continue-on-error: true
+ env:
+ JEST_JUNIT_OUTPUT_DIR: ${{ github.workspace }}/junit-results
+ JEST_JUNIT_OUTPUT_NAME: junit-replay-shared.xml
+ # Anchor flake identity to the test file, matching the main jest job.
+ JEST_JUNIT_SUITE_NAME: '{filepath}'
+ JEST_JUNIT_ADD_FILE_ATTRIBUTE: 'true'
run: pnpm --filter=@posthog/replay-shared test
+ - name: Upload test results
+ if: always()
+ uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
+ with:
+ name: junit-results-replay-shared
+ path: junit-results/junit-*.xml
+ if-no-files-found: ignore
+ retention-days: 1
+
+ # Quarantine gate: see the jest job for the full rationale. Runs the token only
+ # on internal PRs, master, and the merge queue — never on fork PRs or Dependabot.
+ - name: Quarantine gate
+ if: ${{ !cancelled() && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' }}
+ uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
+ with:
+ junit-paths: junit-results/junit-replay-shared.xml
+ org-slug: posthog-inc
+ variant: replay-shared
+ quarantine: true
+ previous-step-outcome: ${{ steps.run-jest.outcome }}
+ token: ${{ secrets.TRUNK_API_TOKEN }}
+ # No Trunk secret on fork PRs and Dependabot; fall back to the raw jest outcome so
+ # a genuine failure still goes red exactly as before.
+ - name: Fail on jest failure (no quarantine gate)
+ if: ${{ !cancelled() && steps.run-jest.outcome == 'failure' && !(env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]') }}
+ shell: bash
+ run: exit 1
+
calculate-running-time:
name: Calculate running time
needs:
@@ -810,45 +878,3 @@ jobs:
exit 1
fi
echo "Frontend TypeScript checks passed."
-
- trunk-upload:
- name: Upload test results to Trunk
- # jest shards emit and upload junit-results-frontend-* artifacts; this feeds them to
- # Trunk (flaky-test detection) once. Trusted non-pull_request events only (master push),
- # so the secret token never runs in a PR-controlled context; the uploader is a pinned
- # external action, not a local one.
- needs: [jest]
- runs-on: ubuntu-latest
- continue-on-error: true
- timeout-minutes: 10
- # != 'skipped' (not == 'success'): a failed shard still emits junit, and failing
- # results are exactly the flake signal Trunk needs. Only bail when jest never ran.
- if: always() && github.repository == 'PostHog/posthog' && github.event_name != 'pull_request' && needs.jest.result != 'skipped'
- steps:
- - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- with:
- fetch-depth: 1
- persist-credentials: false
- - name: Download JUnit artifacts
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v6.0.0
- continue-on-error: true
- with:
- path: ./junit-artifacts
- pattern: junit-results-frontend-*
- # FOSS and EE run the same test files, so a single upload would give one test id
- # both segments' outcomes and a segment-specific failure would look like a flake.
- # Upload each segment under its own Trunk variant to keep their histories distinct.
- - name: Upload FOSS results to Trunk
- uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
- with:
- junit-paths: junit-artifacts/**/junit-FOSS-*.xml
- org-slug: posthog-inc
- variant: FOSS
- token: ${{ secrets.TRUNK_API_TOKEN }}
- - name: Upload EE results to Trunk
- uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
- with:
- junit-paths: junit-artifacts/**/junit-EE-*.xml
- org-slug: posthog-inc
- variant: EE
- token: ${{ secrets.TRUNK_API_TOKEN }}
diff --git a/common/replay-shared/jest.config.js b/common/replay-shared/jest.config.js
index 4f747e8d8f3e..8c6814e0a2c0 100644
--- a/common/replay-shared/jest.config.js
+++ b/common/replay-shared/jest.config.js
@@ -7,4 +7,6 @@ module.exports = {
testEnvironment: 'node',
clearMocks: true,
testMatch: ['<rootDir>/src/**/*.test.ts'],
+ // CI sets JEST_JUNIT_OUTPUT_DIR to collect junit for the Trunk quarantine gate.
+ reporters: process.env.JEST_JUNIT_OUTPUT_DIR ? ['default', 'jest-junit'] : ['default'],
}
diff --git a/common/replay-shared/package.json b/common/replay-shared/package.json
index 8dcc2d10d02f..cac5f46addc4 100644
--- a/common/replay-shared/package.json
+++ b/common/replay-shared/package.json
@@ -20,6 +20,7 @@
"@swc/core": "^1.11.29",
"@swc/jest": "^0.2.37",
"@types/jest": "catalog:",
- "jest": "^29.7.0"
+ "jest": "^29.7.0",
+ "jest-junit": "catalog:"
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5280d352bb54..21ba388cb682 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -54,6 +54,9 @@ catalogs:
jest:
specifier: ^29.7.0
version: 29.7.0
+ jest-junit:
+ specifier: ^16.0.0
+ version: 16.0.0
kea:
specifier: ^4.0.0-pre.5
version: 4.0.0-pre.5
@@ -401,6 +404,9 @@ importers:
jest:
specifier: ^29.7.0
+ jest-junit:
+ specifier: 'catalog:'
+ version: 16.0.0
common/storybook:
dependencies:
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index b686d1a2f2ac..8884e1918d5f 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -54,6 +54,7 @@ catalog:
oxfmt: ^0.35.0
# Testing
jest: ^29.7.0
+ jest-junit: ^16.0.0
'@types/jest': ^29.5.12
'@types/node': ^22.13.14
'@playwright/test': 1.60.0