: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): post no backend test results check for a passing draft (#118825)
Raúl Negrón-Otero1f4e1c400814
diff --git a/.agents/skills/depot-ci/references/posthog-check-run-semantics.md b/.agents/skills/depot-ci/references/posthog-check-run-semantics.mdindex 55882ee9fbcd..6a74561ce3ed 100644--- a/.agents/skills/depot-ci/references/posthog-check-run-semantics.md+++ b/.agents/skills/depot-ci/references/posthog-check-run-semantics.md@@ -36,7 +36,8 @@ The engines agree everywhere except the empty matrix and the matrix check granul- A check run that concludes `skipped` **satisfies** a required status check, and the Trunk merge queue scores it the same way. The repo already depends on this: `Build Docker image` is a required context that concludes `skipped` on most PRs, and they merge.- A required context that **no check run ever reports** stays pending and blocks. This is the empty-matrix failure mode above, and it is also what a `paths:` filter does when it silences a whole workflow.-- Required contexts are pinned to one app. Every entry in this repo's `master` ruleset carries `integration_id: 15368`, the `github-actions` app. Read them with:+- A check run that stays `in_progress` blocks, and GitHub keeps every completed check run on its commit. Depot creates a job's own check only when the job resolves, so a new run on an already green commit (a draft marked ready, a reopen) cannot hold the commit pending: the old success stands until the new gate job ends. That is why the required backend context is the gate job's `Backend CI on Depot / Test results` check, posted by the PostHog tests app: a passing draft run does not post it, so the context stays missing until the ready run posts the verdict. A draft shows the check only when its run failed.+- Required contexts are pinned to one app. Most entries in this repo's `master` ruleset carry `integration_id: 15368`, the `github-actions` app; the backend entry, `Backend CI on Depot / Test results`, is pinned to the PostHog tests app. Read them with:```bashgh api repos/PostHog/posthog/rulesets --jq '.[] | select(.name=="master") | .id'diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.ymlindex c2f8b09f1238..bbf5054be1ed 100644--- a/.depot/workflows/ci-backend.yml+++ b/.depot/workflows/ci-backend.yml@@ -122,8 +122,8 @@# Shards derive from .test_durations (Amdahl), restored from Depot Cache (else committed);# .github/workflows/ci-backend-update-test-timing.yml keeps that cache fresh.name: Backend CI on Depot-# Depot CI copy of canonical Backend CI. Branch protection requires this workflow's gate,-# `Backend CI on Depot / Django Tests Pass on Depot`, posted by the Depot Code Access app.+# Depot CI copy of canonical Backend CI. Branch protection requires the gate job's+# `Backend CI on Depot / Test results` check, posted by the PostHog tests app.# Pull requests, master pushes, manual runs and the hourly master run all start here.# The drift check (.github/workflows/ci-backend-shadow-drift.yml) keeps this file in sync# with canonical; it runs whenever either file changes.@@ -4341,7 +4341,6 @@ jobs:- name: Mint gate check tokenid: gate-tokenif: ${{ always() && github.event_name == 'pull_request' }}- continue-on-error: trueuses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1with:client-id: ${{ secrets.GH_APP_POSTHOG_TESTS_APP_ID }}@@ -4349,18 +4348,26 @@ jobs:permission-checks: write# Depot's own checks carry no output and their pages need a Depot login, so this# check carries the gate summary: GitHub shows the title on the PR's check row- # and the summary on the Checks tab.+ # and the summary on the Checks tab. Branch protection requires this check, so a+ # failed post must fail the gate.- name: Post the test results checkif: ${{ always() && steps.gate-token.outputs.token != '' }}- continue-on-error: trueenv:GH_TOKEN: ${{ steps.gate-token.outputs.token }}REPO: ${{ github.repository }}SHA: ${{ github.event.pull_request.head.sha }}GATE_CHECK: Backend CI on Depot / Test results- # A `no-ci` draft skips change detection and every check, so its row says so.+ # A `no-ci` draft skips change detection and every check.CONCLUSION: ${{ job.status == 'cancelled' && 'cancelled' || needs.changes.result == 'skipped' && 'skipped' || (steps.verdict.outcome == 'success' && 'success' || 'failure') }}+ # A completed check stays on the commit, so a draft's passing verdict would satisfy+ # branch protection the moment the PR turns ready. Merge-queue PRs are drafts whose+ # run is the verdict.+ IS_DRAFT: ${{ github.event.pull_request.draft && !startsWith(github.head_ref, 'trunk-merge/') }}run: |+ if [[ "$IS_DRAFT" == "true" && "$CONCLUSION" != "failure" ]]; then+ echo "Draft run: the ready-for-review run posts the $GATE_CHECK check."+ exit 0+ ficase "$CONCLUSION" insuccess) title="Backend tests passed on Depot" ;;skipped) title="No backend checks ran on Depot" ;;diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.ymlindex 30cb7c456a07..2439c30e0a98 100644--- a/.github/workflows/ci-backend.yml+++ b/.github/workflows/ci-backend.yml@@ -4150,7 +4150,7 @@ jobs:# Depot gate replaces it there.- name: Point at the Depot gateif: github.event_name == 'pull_request'- run: echo "::notice::Depot CI runs the backend tests for pull requests. The required check is 'Backend CI on Depot / Django Tests Pass on Depot'."+ run: echo "::notice::Depot CI runs the backend tests for pull requests. The required check is 'Backend CI on Depot / Test results'."- name: Summarize dependency resultsif: github.event_name != 'pull_request'run: |diff --git a/docs/published/handbook/engineering/fork-pull-requests.md b/docs/published/handbook/engineering/fork-pull-requests.mdindex fd0816668de5..d77be8480b57 100644--- a/docs/published/handbook/engineering/fork-pull-requests.md+++ b/docs/published/handbook/engineering/fork-pull-requests.md@@ -3,7 +3,7 @@ title: Pull requests from forkssidebar: Handbook----Backend CI runs on Depot CI, from `.depot/workflows/ci-backend.yml`, and its gate check `Backend CI on Depot / Django Tests Pass on Depot` is required on `master`.+Backend CI runs on Depot CI, from `.depot/workflows/ci-backend.yml`, and its gate's `Backend CI on Depot / Test results` check is required on `master`.Depot CI never runs a fork's code, so a fork pull request gets no backend run and that check stays pending.A fork pull request cannot merge as it is.After review, a PostHog engineer re-creates the change on a branch in this repository, which gets a Depot run and the required check.