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.

chore(ci): retry the trunk quarantine gate once (#82483)

Raúl Negrón-Otero2cfc28d88f3d
diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.yml
index 4df65d9c01f7..c199d6e595b8 100644
--- a/.depot/workflows/ci-backend.yml
+++ b/.depot/workflows/ci-backend.yml
@@ -29,7 +29,9 @@
# TRUNK_UPLOAD_ENABLED repo variable as an upload kill-switch, and its verdict step
# on TRUNK_QUARANTINE_ENABLED to decide whether known flakes are masked; since the
# shadow strips both the gate and the verdict step entirely, both variables are
-# no-ops here and there is nothing to mirror)
+# no-ops here and there is nothing to mirror. Canonical's turbo-tests gate now calls
+# ./.github/actions/trunk-quarantine-gate, which retries the upload once; the shadow
+# has no gate to call it from, so there is no ./.depot/actions mirror of it either)
# - Per-test failure rollup: canonical's django_tests gate uploads product JUnit and, when a
# test job fails, downloads that shard's JUnit to list the actual failing tests. The shadow
# strips artifact uploads (above), so it has nothing to download and keeps the plain
diff --git a/.github/actions/trunk-quarantine-gate/action.yml b/.github/actions/trunk-quarantine-gate/action.yml
new file mode 100644
index 000000000000..2ae8b83793f2
--- /dev/null
+++ b/.github/actions/trunk-quarantine-gate/action.yml
@@ -0,0 +1,66 @@
+name: 'Trunk quarantine gate'
+description: 'Upload a shard JUnit report to Trunk, masking known flakes, retrying once on a transient upload failure'
+
+inputs:
+ junit-paths:
+ description: 'Comma-separated glob paths to the JUnit files this shard wrote'
+ required: true
+ previous-step-outcome:
+ description: 'steps.<test step>.outcome, so Trunk can tell a failed shard from a passing one'
+ required: true
+ token:
+ description: 'Trunk API token'
+ required: true
+ variant:
+ description: 'Trunk variant, for suites whose shards upload under one name'
+ required: false
+ default: ''
+
+runs:
+ using: 'composite'
+ steps:
+ - name: Upload to Trunk
+ id: upload
+ continue-on-error: true
+ uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
+ with:
+ junit-paths: ${{ inputs.junit-paths }}
+ org-slug: posthog-inc
+ variant: ${{ inputs.variant }}
+ # Pinned rather than 'latest', which costs an extra github.com request to follow the release redirect.
+ cli-version: '0.13.7'
+ quarantine: true
+ previous-step-outcome: ${{ inputs.previous-step-outcome }}
+ token: ${{ inputs.token }}
+
+ # Randomized because a github.com release-asset rate limit or a Trunk outage fails every
+ # shard at once, and a fixed delay would retry them all in the same instant too.
+ - name: Back off before retrying
+ if: ${{ steps.upload.outcome == 'failure' && inputs.previous-step-outcome == 'success' }}
+ shell: bash
+ run: sleep $((15 + RANDOM % 46))
+
+ # Only a shard whose tests passed: the uploader exits non-zero by design when the report has
+ # failures it could not quarantine, and re-uploading those would double-count them in the
+ # flake statistics that decide what gets quarantined.
+ - name: Upload to Trunk (retry)
+ id: upload-retry
+ if: ${{ steps.upload.outcome == 'failure' && inputs.previous-step-outcome == 'success' }}
+ continue-on-error: true
+ uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
+ with:
+ junit-paths: ${{ inputs.junit-paths }}
+ org-slug: posthog-inc
+ variant: ${{ inputs.variant }}
+ cli-version: '0.13.7'
+ quarantine: true
+ previous-step-outcome: ${{ inputs.previous-step-outcome }}
+ token: ${{ inputs.token }}
+
+ # Re-raise, so this action's own outcome still means what a bare uploader step meant and
+ # callers can keep gating their verdict on `steps.<gate>.outcome == 'success'`. Without it
+ # the swallowed attempts above would report success and mask every real failure.
+ - name: Fail if no attempt cleared the shard
+ if: ${{ steps.upload.outcome != 'success' && steps.upload-retry.outcome != 'success' }}
+ shell: bash
+ run: exit 1
diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml
index 48955bf74289..df12cd8181ec 100644
--- a/.github/workflows/ci-backend.yml
+++ b/.github/workflows/ci-backend.yml
@@ -1037,7 +1037,7 @@ jobs:
# Best-effort Trunk upload (continue-on-error); the "Fail on test failure" step below is
# the verdict, so a Trunk outage can't red a passing shard. Internal PRs only (needs the
- # secret); cli-version pinned, not 'latest' (skips the release redirect).
+ # secret).
# TRUNK_UPLOAD_ENABLED is the master kill-switch: when it is not 'true' this gate
# 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
@@ -1046,12 +1046,9 @@ jobs:
id: quarantine_gate
continue-on-error: true
if: ${{ !cancelled() && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' && vars.TRUNK_UPLOAD_ENABLED == 'true' }}
- uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
+ uses: ./.github/actions/trunk-quarantine-gate
with:
junit-paths: products/*/junit-product.xml
- org-slug: posthog-inc
- cli-version: '0.13.7'
- quarantine: true
previous-step-outcome: ${{ steps.run-product-tests.outcome }}
token: ${{ secrets.TRUNK_API_TOKEN }}
@@ -3275,6 +3272,9 @@ 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.
- name: Quarantine gate (Core)
id: quarantine_gate_core
continue-on-error: true
diff --git a/.github/workflows/ci-e2e-playwright.yml b/.github/workflows/ci-e2e-playwright.yml
index 029b44e88c4a..fdd4e60b5f6b 100644
--- a/.github/workflows/ci-e2e-playwright.yml
+++ b/.github/workflows/ci-e2e-playwright.yml
@@ -1038,6 +1038,9 @@ 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.
- name: Quarantine gate
id: quarantine_gate
continue-on-error: true
diff --git a/.github/workflows/ci-frontend.yml b/.github/workflows/ci-frontend.yml
index 6ca2311a07b0..6c9c517335fe 100644
--- a/.github/workflows/ci-frontend.yml
+++ b/.github/workflows/ci-frontend.yml
@@ -802,8 +802,7 @@ jobs:
# Best-effort Trunk upload (continue-on-error); the "Fail on jest failure" step below is
# the verdict, so a Trunk outage can't red a passing shard. FOSS and EE share test files,
- # so each segment uploads under its own variant. Internal PRs only (needs the secret);
- # cli-version pinned, not 'latest' (skips the release redirect).
+ # so each segment uploads under its own variant. Internal PRs only (needs the secret).
# TRUNK_UPLOAD_ENABLED is the master kill-switch: when it is not 'true' this gate
# 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
@@ -812,13 +811,10 @@ jobs:
id: quarantine_gate
continue-on-error: true
if: ${{ !cancelled() && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' && vars.TRUNK_UPLOAD_ENABLED == 'true' }}
- uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
+ uses: ./.github/actions/trunk-quarantine-gate
with:
junit-paths: junit-results/junit-${{ matrix.segment }}-${{ matrix.chunk }}.xml
- org-slug: posthog-inc
variant: ${{ matrix.segment }}
- cli-version: '0.13.7'
- quarantine: true
previous-step-outcome: ${{ steps.run-jest.outcome }}
token: ${{ secrets.TRUNK_API_TOKEN }}
# Verdict: red a real failure the gate didn't clear as a quarantined flake. != 'success'
@@ -877,7 +873,7 @@ jobs:
retention-days: 1
# Best-effort Trunk upload (continue-on-error); the "Fail on jest failure" step below is
- # the verdict. See the jest job for the full rationale. cli-version pinned, not 'latest'.
+ # the verdict. See the jest job for the full rationale.
# TRUNK_UPLOAD_ENABLED is the master kill-switch: when it is not 'true' this gate
# 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
@@ -886,13 +882,10 @@ jobs:
id: quarantine_gate
continue-on-error: true
if: ${{ !cancelled() && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' && vars.TRUNK_UPLOAD_ENABLED == 'true' }}
- uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
+ uses: ./.github/actions/trunk-quarantine-gate
with:
junit-paths: junit-results/junit-replay-shared.xml
- org-slug: posthog-inc
variant: replay-shared
- cli-version: '0.13.7'
- quarantine: true
previous-step-outcome: ${{ steps.run-jest.outcome }}
token: ${{ secrets.TRUNK_API_TOKEN }}
- name: Fail on jest failure
diff --git a/.github/workflows/ci-llm-gateway.yml b/.github/workflows/ci-llm-gateway.yml
index a0b056f98720..ad9fc3a024b7 100644
--- a/.github/workflows/ci-llm-gateway.yml
+++ b/.github/workflows/ci-llm-gateway.yml
@@ -102,7 +102,7 @@ jobs:
# Best-effort Trunk upload (continue-on-error); the "Fail on test failure" step below is
# the verdict, so a Trunk outage can't red a passing job. Internal PRs only (needs the
- # secret); cli-version pinned, not 'latest' (skips the release redirect).
+ # secret).
# TRUNK_UPLOAD_ENABLED is the master kill-switch: when it is not 'true' this gate
# 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
@@ -111,12 +111,9 @@ jobs:
id: quarantine_gate
continue-on-error: true
if: ${{ !cancelled() && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' && vars.TRUNK_UPLOAD_ENABLED == 'true' }}
- uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
+ uses: ./.github/actions/trunk-quarantine-gate
with:
junit-paths: services/llm-gateway/junit.xml
- org-slug: posthog-inc
- cli-version: '0.13.7'
- quarantine: true
previous-step-outcome: ${{ steps.run-tests.outcome }}
token: ${{ secrets.TRUNK_API_TOKEN }}
diff --git a/.github/workflows/ci-mcp.yml b/.github/workflows/ci-mcp.yml
index 88dfe2eca6f2..705fce5f803e 100644
--- a/.github/workflows/ci-mcp.yml
+++ b/.github/workflows/ci-mcp.yml
@@ -673,7 +673,7 @@ jobs:
# Best-effort Trunk upload (continue-on-error); the "Fail on test failure" step below is
# the verdict, so a Trunk outage can't red a passing job. Internal PRs only (needs the
- # secret); cli-version pinned, not 'latest' (skips the release redirect).
+ # secret).
# TRUNK_UPLOAD_ENABLED is the master kill-switch: when it is not 'true' this gate
# 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
@@ -682,12 +682,9 @@ jobs:
id: quarantine_gate
continue-on-error: true
if: ${{ !cancelled() && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' && vars.TRUNK_UPLOAD_ENABLED == 'true' }}
- uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
+ uses: ./.github/actions/trunk-quarantine-gate
with:
junit-paths: services/mcp/junit-integration.xml
- org-slug: posthog-inc
- cli-version: '0.13.7'
- quarantine: true
previous-step-outcome: ${{ steps.run-integration-tests.outcome }}
token: ${{ secrets.TRUNK_API_TOKEN }}
diff --git a/.github/workflows/ci-nodejs.yml b/.github/workflows/ci-nodejs.yml
index c747307c7181..162b9d0c70f9 100644
--- a/.github/workflows/ci-nodejs.yml
+++ b/.github/workflows/ci-nodejs.yml
@@ -511,7 +511,7 @@ jobs:
# Best-effort Trunk upload (continue-on-error); the "Fail on test failure" step below is
# the verdict, so a Trunk outage can't red a passing shard. Internal PRs only (needs the
- # secret); cli-version pinned, not 'latest' (skips the release redirect).
+ # secret).
# TRUNK_UPLOAD_ENABLED is the master kill-switch: when it is not 'true' this gate
# 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
@@ -520,12 +520,9 @@ jobs:
id: quarantine_gate
continue-on-error: true
if: ${{ !cancelled() && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' && vars.TRUNK_UPLOAD_ENABLED == 'true' }}
- uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
+ uses: ./.github/actions/trunk-quarantine-gate
with:
junit-paths: junit-results/junit-*.xml
- org-slug: posthog-inc
- cli-version: '0.13.7'
- quarantine: true
# Worst of the two test steps: the gate must know the run failed even when
# only the parity step (shard 1) did. A skipped parity step counts as success.
previous-step-outcome: ${{ (steps.run-jest.outcome == 'failure' || steps.run-parity.outcome == 'failure') && 'failure' || 'success' }}
diff --git a/.github/workflows/desktop-test.yml b/.github/workflows/desktop-test.yml
index e0fcf08496db..80d20dbe2b37 100644
--- a/.github/workflows/desktop-test.yml
+++ b/.github/workflows/desktop-test.yml
@@ -138,7 +138,7 @@ jobs:
# Best-effort Trunk upload (continue-on-error); the "Fail on test failure" step below is
# the verdict, so a Trunk outage can't red a passing job. Internal PRs only (needs the
- # secret); cli-version pinned, not 'latest' (skips the release redirect).
+ # secret).
# TRUNK_UPLOAD_ENABLED is the master kill-switch: when it is not 'true' this gate
# 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
@@ -147,15 +147,12 @@ jobs:
id: quarantine_gate
continue-on-error: true
if: ${{ !cancelled() && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' && vars.TRUNK_UPLOAD_ENABLED == 'true' }}
- uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
+ uses: ./.github/actions/trunk-quarantine-gate
with:
# Scope to each package root. A bare **/junit.xml glob descends into
# node_modules, where pnpm symlinks workspace packages, and uploads
# every report many times over.
junit-paths: 'products/desktop/apps/*/junit.xml,products/desktop/packages/*/junit.xml'
- org-slug: posthog-inc
- cli-version: '0.13.7'
- quarantine: true
previous-step-outcome: ${{ steps.run-tests.outcome }}
token: ${{ secrets.TRUNK_API_TOKEN }}
@@ -254,7 +251,7 @@ jobs:
# Best-effort Trunk upload (continue-on-error); the "Fail on E2E failure" step below is
# the verdict, so a Trunk outage can't red a passing job. Internal PRs only (needs the
- # secret); cli-version pinned, not 'latest' (skips the release redirect).
+ # secret).
# TRUNK_UPLOAD_ENABLED is the master kill-switch: when it is not 'true' this gate
# 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
@@ -263,12 +260,9 @@ jobs:
id: quarantine_gate
continue-on-error: true
if: ${{ !cancelled() && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' && vars.TRUNK_UPLOAD_ENABLED == 'true' }}
- uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
+ uses: ./.github/actions/trunk-quarantine-gate
with:
junit-paths: 'products/desktop/apps/code/tests/e2e/junit.xml'
- org-slug: posthog-inc
- cli-version: '0.13.7'
- quarantine: true
previous-step-outcome: ${{ steps.run-e2e.outcome }}
token: ${{ secrets.TRUNK_API_TOKEN }}
@@ -297,12 +291,9 @@ jobs:
id: quarantine_gate_web
continue-on-error: true
if: ${{ !cancelled() && env.RUNS_ON_INTERNAL_PR == 'true' && github.repository == 'PostHog/posthog' && github.actor != 'dependabot[bot]' && vars.TRUNK_UPLOAD_ENABLED == 'true' }}
- uses: trunk-io/analytics-uploader@385f1ccdf345b4532dc4b6c665dd432b702b8e28 # v2.1.2
+ uses: ./.github/actions/trunk-quarantine-gate
with:
junit-paths: 'products/desktop/apps/web/tests/e2e/junit.xml'
- org-slug: posthog-inc
- cli-version: '0.13.7'
- quarantine: true
previous-step-outcome: ${{ steps.run-web-e2e.outcome }}
token: ${{ secrets.TRUNK_API_TOKEN }}