: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): share desktop change detection across suites (#126570)
posthog[bot]9a0a7eb3f722
diff --git a/.github/workflows/desktop-build.yml b/.github/workflows/desktop-build.ymlindex 4733dc1a96af..20e82623eaf4 100644--- a/.github/workflows/desktop-build.yml+++ b/.github/workflows/desktop-build.yml@@ -4,6 +4,12 @@ on:# Dispatched by desktop-ci.yml, the single PR/merge_group run for the whole# desktop suite; merge_group gating and PR concurrency live there.workflow_call:+ inputs:+ run-suite:+ description: Whether this suite needs to run; an empty value uses local change detection.+ type: string+ required: false+ default: ''secrets:GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY:required: false@@ -27,7 +33,7 @@ jobs:changes:runs-on: depot-ubuntu-24.04timeout-minutes: 5- if: github.event_name != 'merge_group'+ if: github.event_name != 'merge_group' && inputs.run-suite == ''permissions:pull-requests: readoutputs:@@ -91,7 +97,7 @@ jobs:github.event_name != 'merge_group' &&(github.event.pull_request.draft != true ||startsWith(github.head_ref, 'trunk-merge/')) &&- (needs.changes.result != 'success' || needs.changes.outputs.code == 'true' || needs.changes.outputs.workflow == 'true')+ (inputs.run-suite == 'true' || (inputs.run-suite == '' && (needs.changes.result != 'success' || needs.changes.outputs.code == 'true' || needs.changes.outputs.workflow == 'true')))runs-on: depot-ubuntu-24.04-4timeout-minutes: 30permissions:diff --git a/.github/workflows/desktop-ci.yml b/.github/workflows/desktop-ci.ymlindex 04c14712e410..7fe4215b9fb5 100644--- a/.github/workflows/desktop-ci.yml+++ b/.github/workflows/desktop-ci.yml@@ -4,10 +4,8 @@ name: Desktop CI# (500 runs/10s/repo) counts workflow runs, and a run that calls reusable# workflows counts once, so the whole desktop suite costs one slot per push.#-# The suites themselves stay unfiltered here on purpose: each child gates its-# own work on an internal `changes` job, so a non-desktop PR pays a handful of-# short detector jobs and skips everything else. A trigger-level `paths:`-# filter would stop the `Desktop * Pass` checks from ever reporting, leaving+# Suite-specific filters keep unrelated pull requests from running Desktop jobs.+# A trigger-level `paths:` filter would stop the `Desktop * Pass` checks from ever reporting, leaving# any PR that requires them stuck waiting for status.on:@@ -32,22 +30,111 @@ permissions:pull-requests: readjobs:+ changes:+ runs-on: depot-ubuntu-24.04+ timeout-minutes: 5+ if: github.event_name == 'pull_request'+ permissions:+ pull-requests: read+ outputs:+ build: ${{ steps.filter.outputs.agent == 'true' || steps.filter.outputs.code == 'true' || steps.filter.outputs.build == 'true' }}+ quality: ${{ steps.filter.outputs.agent == 'true' || steps.filter.outputs.quality_code == 'true' || steps.filter.outputs.quality == 'true' }}+ typecheck: ${{ steps.filter.outputs.agent == 'true' || steps.filter.outputs.code == 'true' || steps.filter.outputs.typecheck == 'true' }}+ test: ${{ steps.filter.outputs.agent == 'true' || steps.filter.outputs.code == 'true' || steps.filter.outputs.test == 'true' }}+ test_e2e: ${{ steps.filter.outputs.agent == 'true' || steps.filter.outputs.packages == 'true' || steps.filter.outputs.test == 'true' }}+ steps:+ # Own rate-limit bucket; the shared GITHUB_TOKEN goes hot at merge peaks.+ - uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1+ id: app-token+ # forks can't read org secrets, so fall back to github.token+ if: github.repository == 'PostHog/posthog' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository+ with:+ client-id: ${{ vars.GH_APP_POSTHOG_PATHS_FILTER_APP_ID }}+ private-key: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY }}++ - name: Detect relevant changes+ id: filter+ if: github.event_name == 'pull_request'+ uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1+ with:+ token: ${{ steps.app-token.outputs.token || github.token }}+ predicate-quantifier: every+ filters: |+ # Wider excludes than desktop-quality.yml, which keeps .vscode and+ # .claude in scope because Biome lints them. Only documentation+ # markdown is excluded: the app loads markdown under src/ at runtime.+ code:+ - "products/desktop/**"+ - "!products/desktop/*.md"+ - "!products/desktop/**/README.md"+ - "!products/desktop/**/AGENTS.md"+ - "!products/desktop/**/CLAUDE.md"+ - "!products/desktop/docs/**"+ - "!products/desktop/.vscode/**"+ - "!products/desktop/.claude/**"+ - "!products/desktop/.husky/**"+ - "!products/desktop/LICENSE"+ - "!products/desktop/.gitignore"+ - "!products/desktop/.env.example"+ # Biome lints tracked JSON in .vscode/.claude, so only workflow YAML and+ # documentation markdown are ignored: the app loads markdown under src/ at runtime.+ quality_code:+ - "products/desktop/**"+ - "!products/desktop/*.md"+ - "!products/desktop/**/README.md"+ - "!products/desktop/**/AGENTS.md"+ - "!products/desktop/**/CLAUDE.md"+ - "!products/desktop/docs/**"+ - "!products/desktop/.husky/**"+ - "!products/desktop/LICENSE"+ - "!products/desktop/.gitignore"+ - "!products/desktop/.env.example"+ agent:+ - "packages/agent/**"+ packages:+ - "products/desktop/packages/**"+ build:+ - ".github/workflows/desktop-build.yml"+ quality:+ - ".github/workflows/desktop-quality.yml"+ typecheck:+ - ".github/workflows/desktop-typecheck.yml"+ test:+ - ".github/workflows/desktop-test.yml"+build:+ needs: changes+ if: ${{ !cancelled() }}+ with:+ run-suite: ${{ needs.changes.result == 'success' && needs.changes.outputs.build || '' }}uses: ./.github/workflows/desktop-build.ymlsecrets:GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY }}quality:+ needs: changes+ if: ${{ !cancelled() }}+ with:+ run-suite: ${{ needs.changes.result == 'success' && needs.changes.outputs.quality || '' }}uses: ./.github/workflows/desktop-quality.ymlsecrets:GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY }}typecheck:+ needs: changes+ if: ${{ !cancelled() }}+ with:+ run-suite: ${{ needs.changes.result == 'success' && needs.changes.outputs.typecheck || '' }}uses: ./.github/workflows/desktop-typecheck.ymlsecrets:GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY }}test:+ needs: changes+ if: ${{ !cancelled() }}+ with:+ run-suite: ${{ needs.changes.result == 'success' && needs.changes.outputs.test || '' }}+ run-e2e: ${{ needs.changes.result == 'success' && needs.changes.outputs.test_e2e || '' }}uses: ./.github/workflows/desktop-test.ymlsecrets:GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY }}@@ -96,13 +183,17 @@ jobs:# not branch protection.tests-pass:name: Desktop Tests Pass- needs: [build, quality, typecheck, test, backend-coupling]+ needs: [changes, build, quality, typecheck, test, backend-coupling]if: ${{ !cancelled() }}runs-on: depot-ubuntu-24.04timeout-minutes: 5steps:- name: Check resultsrun: |+ if [[ "${{ needs.changes.result }}" != "success" && "${{ needs.changes.result }}" != "skipped" ]]; then+ echo "Desktop change detection did not succeed (result: ${{ needs.changes.result }})."+ exit 1+ fiif [[ "${{ needs.build.result }}" != "success" && "${{ needs.build.result }}" != "skipped" ]]; thenecho "Desktop build did not succeed (result: ${{ needs.build.result }})."exit 1diff --git a/.github/workflows/desktop-quality.yml b/.github/workflows/desktop-quality.ymlindex 41bf0035a7dd..0c8506508c79 100644--- a/.github/workflows/desktop-quality.yml+++ b/.github/workflows/desktop-quality.yml@@ -4,6 +4,12 @@ on:# Dispatched by desktop-ci.yml, the single PR/merge_group run for the whole# desktop suite; merge_group gating and PR concurrency live there.workflow_call:+ inputs:+ run-suite:+ description: Whether this suite needs to run; an empty value uses local change detection.+ type: string+ required: false+ default: ''secrets:GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY:required: false@@ -22,7 +28,7 @@ jobs:changes:runs-on: depot-ubuntu-24.04timeout-minutes: 5- if: github.event_name != 'merge_group'+ if: github.event_name != 'merge_group' && inputs.run-suite == ''permissions:pull-requests: readoutputs:@@ -69,7 +75,7 @@ jobs:quality:needs: changes# Fail closed: if change detection itself failed, run instead of skipping.- if: ${{ !cancelled() && github.event_name != 'merge_group' && (needs.changes.result != 'success' || needs.changes.outputs.code == 'true' || needs.changes.outputs.workflow == 'true') }}+ if: ${{ !cancelled() && github.event_name != 'merge_group' && (inputs.run-suite == 'true' || (inputs.run-suite == '' && (needs.changes.result != 'success' || needs.changes.outputs.code == 'true' || needs.changes.outputs.workflow == 'true'))) }}runs-on: depot-ubuntu-24.04-4timeout-minutes: 15permissions:diff --git a/.github/workflows/desktop-test.yml b/.github/workflows/desktop-test.ymlindex 19aeb8451706..6e4c0cadc8ca 100644--- a/.github/workflows/desktop-test.yml+++ b/.github/workflows/desktop-test.yml@@ -4,6 +4,17 @@ on:# Dispatched by desktop-ci.yml, the single PR/merge_group run for the whole# desktop suite; merge_group gating and PR concurrency live there.workflow_call:+ inputs:+ run-suite:+ description: Whether this suite needs to run; an empty value uses local change detection.+ type: string+ required: false+ default: ''+ run-e2e:+ description: Whether package changes require end-to-end tests.+ type: string+ required: false+ default: ''secrets:GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY:required: false@@ -30,7 +41,7 @@ jobs:changes:runs-on: depot-ubuntu-24.04timeout-minutes: 5- if: github.event_name != 'merge_group'+ if: github.event_name != 'merge_group' && inputs.run-suite == ''permissions:pull-requests: readoutputs:@@ -83,7 +94,7 @@ jobs:unit-test:needs: changes# Fail closed: if change detection itself failed, run instead of skipping.- if: ${{ !cancelled() && github.event_name != 'merge_group' && (needs.changes.result != 'success' || needs.changes.outputs.code == 'true' || needs.changes.outputs.workflow == 'true') }}+ if: ${{ !cancelled() && github.event_name != 'merge_group' && (inputs.run-suite == 'true' || (inputs.run-suite == '' && (needs.changes.result != 'success' || needs.changes.outputs.code == 'true' || needs.changes.outputs.workflow == 'true'))) }}runs-on: depot-ubuntu-24.04-4timeout-minutes: 30permissions:@@ -137,7 +148,7 @@ jobs:electron-test:needs: changes# Fail closed: if change detection itself failed, run instead of skipping.- if: ${{ !cancelled() && github.event_name != 'merge_group' && (needs.changes.result != 'success' || needs.changes.outputs.code == 'true' || needs.changes.outputs.workflow == 'true') }}+ if: ${{ !cancelled() && github.event_name != 'merge_group' && (inputs.run-suite == 'true' || (inputs.run-suite == '' && (needs.changes.result != 'success' || needs.changes.outputs.code == 'true' || needs.changes.outputs.workflow == 'true'))) }}runs-on: depot-ubuntu-24.04-4timeout-minutes: 30permissions:@@ -285,7 +296,7 @@ jobs:# batch merges cleanly, which is what a queue run is for. A model timeout there# removes a PR that changes no desktop code from the queue. The PR's own run# still covers every branch that really changes products/desktop/packages/.- if: ${{ (needs.changes.outputs.packages == 'true' || needs.changes.outputs.workflow == 'true') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && !startsWith(github.head_ref, 'trunk-merge/') }}+ if: ${{ !cancelled() && ((inputs.run-suite != '' && inputs.run-e2e == 'true') || (inputs.run-suite == '' && needs.changes.result == 'success' && (needs.changes.outputs.packages == 'true' || needs.changes.outputs.workflow == 'true'))) && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && !startsWith(github.head_ref, 'trunk-merge/') }}runs-on: depot-ubuntu-24.04-4timeout-minutes: 30permissions:diff --git a/.github/workflows/desktop-typecheck.yml b/.github/workflows/desktop-typecheck.ymlindex 84ecc8980c9a..b88c68ba9096 100644--- a/.github/workflows/desktop-typecheck.yml+++ b/.github/workflows/desktop-typecheck.yml@@ -4,6 +4,12 @@ on:# Dispatched by desktop-ci.yml, the single PR/merge_group run for the whole# desktop suite; merge_group gating and PR concurrency live there.workflow_call:+ inputs:+ run-suite:+ description: Whether this suite needs to run; an empty value uses local change detection.+ type: string+ required: false+ default: ''secrets:GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY:required: false@@ -27,7 +33,7 @@ jobs:changes:runs-on: depot-ubuntu-24.04timeout-minutes: 5- if: github.event_name != 'merge_group'+ if: github.event_name != 'merge_group' && inputs.run-suite == ''permissions:pull-requests: readoutputs:@@ -77,7 +83,7 @@ jobs:typecheck:needs: changes# Fail closed: if change detection itself failed, run instead of skipping.- if: ${{ !cancelled() && github.event_name != 'merge_group' && (needs.changes.result != 'success' || needs.changes.outputs.code == 'true' || needs.changes.outputs.workflow == 'true') }}+ if: ${{ !cancelled() && github.event_name != 'merge_group' && (inputs.run-suite == 'true' || (inputs.run-suite == '' && (needs.changes.result != 'success' || needs.changes.outputs.code == 'true' || needs.changes.outputs.workflow == 'true'))) }}runs-on: depot-ubuntu-24.04-4timeout-minutes: 30permissions:diff --git a/tools/workflow-plan/tests/workflows.test.ts b/tools/workflow-plan/tests/workflows.test.tsindex a2b075dce693..d53ca53722e7 100644--- a/tools/workflow-plan/tests/workflows.test.ts+++ b/tools/workflow-plan/tests/workflows.test.ts@@ -1,5 +1,6 @@// These tests check the CI workflows, not the planner. A failure here means a// job condition in a workflow file changed what runs; the planner itself is covered by plan.test.ts.+import { load } from 'js-yaml'import { spawnSync } from 'node:child_process'import { readdirSync } from 'node:fs'import path from 'node:path'@@ -590,6 +591,48 @@ const namedJobs = (file: string): Set<string> =>)describe('CI workflow run plans', () => {+ it.each(['build', 'quality', 'typecheck', 'test'])('Desktop %s shares the fallback detector filters', (name) => {+ const filters = (file: string): Record<string, string[]> =>+ load(+ String(workflow(file).jobs.changes?.steps?.find((step) => step.id === 'filter')?.with?.filters)+ ) as Record<string, string[]>+ const shared = filters('desktop-ci.yml')+ const fallback = filters(`desktop-${name}.yml`)+ expect(shared[name === 'quality' ? 'quality_code' : 'code']).toEqual(fallback.code)+ expect(shared.agent).toEqual(fallback.agent)+ expect(shared[name]).toEqual(fallback.workflow)+ if (name === 'test') {+ expect(shared.packages).toEqual(fallback.packages)+ }+ })++ it.each(['success', 'failure', 'cancelled', 'skipped'] as const)(+ 'Desktop callers pass shared decisions only after a successful detector (%s)',+ (result) => {+ const functions = planFunctions({+ dependenciesSucceeded: result === 'success' || result === 'skipped',+ dependenciesFailed: result === 'failure',+ cancelled: false,+ })+ for (const selected of ['true', 'false']) {+ const needs = {+ changes: {+ result,+ outputs: Object.fromEntries(+ ['build', 'quality', 'typecheck', 'test', 'test_e2e'].map((name) => [name, selected])+ ),+ },+ }+ for (const name of ['build', 'quality', 'typecheck', 'test']) {+ const caller = workflow('desktop-ci.yml').jobs[name] as { with: Record<string, string> }+ for (const input of Object.values(caller.with)) {+ expect(evaluateValue(input, { needs }, functions)).toBe(result === 'success' ? selected : '')+ }+ }+ }+ }+ )+it.each([{name: 'mobile PR',