: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): stop gating the merge queue on visual review (#78044)
Georges-Antoine Assicb9078a5ee08
diff --git a/.github/workflows/ci-storybook.yml b/.github/workflows/ci-storybook.ymlindex 4311e39a4c31..f0b69f32ccca 100644--- a/.github/workflows/ci-storybook.yml+++ b/.github/workflows/ci-storybook.yml@@ -59,6 +59,16 @@ jobs:&& steps.baseline_push.outputs.result != 'true')}}matrix: ${{ steps.matrix.outputs.matrix }}+ # Trunk's merge queue opens its PR from trunk-merge/**. Scoped to same-repo+ # heads because github.head_ref is author-controlled: without the scope, any+ # contributor could opt out of the visual gates below by naming their branch+ # trunk-merge/**. Only write access can push such a branch here.+ merge_queue: >-+ ${{+ github.event_name == 'pull_request'+ && github.event.pull_request.head.repo.full_name == github.repository+ && startsWith(github.head_ref, 'trunk-merge/')+ }}steps:# Needed by the "Derive Node-only product workspace exclusions" step (reads# pnpm-workspace.yaml + bin/frontend-exclude-filter) and by the local@@ -355,7 +365,11 @@ jobs:VR_PR: ${{ github.event.pull_request.number }}# PRs are gating ("review"); master pushes are tracking-only ("observe") since# there's no PR to approve and we don't want master runs to block or prompt for approval.- VR_PURPOSE: ${{ github.event_name == 'push' && 'observe' || 'review' }}+ # trunk-merge/** is observe for the same reason: the queue's PR is ephemeral, so a+ # diff there has no reviewer and no approval path. Master baseline drift would+ # otherwise block every PR behind it on a diff none of their authors can resolve.+ # The run is still created, so merge-time drift stays visible in Visual Review.+ VR_PURPOSE: ${{ (github.event_name == 'push' || needs.changes.outputs.merge_queue == 'true') && 'observe' || 'review' }}# Selective storybook runs only render a subset of stories. Without --partial,# VR would flag every untouched baseline identifier as removed.VR_PARTIAL: ${{ needs.select-stories.outputs.mode == 'selective' && '--partial' || '' }}@@ -578,7 +592,12 @@ jobs:name: Storybook flake verificationruns-on: ubuntu-latestneeds: [changes, build-storybook]- if: needs.changes.outputs.frontend == 'true' && github.event_name == 'pull_request'+ # Skipped on trunk-merge/**: the job diffs against base.sha to find changed stories,+ # which on a queue branch is the same set the PR's own run already re-ran three times.+ if: |+ needs.changes.outputs.frontend == 'true'+ && github.event_name == 'pull_request'+ && needs.changes.outputs.merge_queue != 'true'timeout-minutes: 45container:image: ghcr.io/posthog/playwright:v1.60.0@@ -711,7 +730,7 @@ jobs:name: Complete Visual Review runruns-on: ubuntu-latesttimeout-minutes: 15- needs: [visual-regression, vr-setup]+ needs: [changes, visual-regression, vr-setup]# Intentional always(), not !cancelled(): this job finalizes external state,# so a run cancelled after the matrix succeeded must still complete the VR# run rather than leave its commit status stuck pending. It also stops the@@ -765,19 +784,26 @@ jobs:run: cd vr-cli/products/visual_review/cli && npm ci && npm run build- name: Complete Visual Review run- # On master pushes the run was created with --purpose observe (tracking-only),- # but `vr run complete` still exits 1 whenever visual changes are detected.- # That makes the Storybook check fail on master even though observe runs are- # not gating by design. Treat exit 1 as informational on push events; PRs- # still gate as before.- continue-on-error: ${{ github.event_name == 'push' }}env:VR_TOKEN: ${{ secrets.VR_API_TOKEN }}+ # Master pushes and merge-queue branches create the run with --purpose observe+ # (tracking-only), because neither has a PR whose reviewer could approve a diff.+ VR_OBSERVE: ${{ github.event_name == 'push' || needs.changes.outputs.merge_queue == 'true' }}run: |+ status=0node vr-cli/products/visual_review/cli/dist/cli/src/index.js run complete \--run-id "${{ needs.vr-setup.outputs.run_id }}" \--baseline frontend/snapshots.yml \- --token "$VR_TOKEN"+ --token "$VR_TOKEN" || status=$?++ # `vr run complete` exits 1 for unresolved visual changes and 2 when the CLI+ # itself failed (auth, network, timeout, backend processing). Only the former+ # is expected on an observe run, so exit 2 still reds CI everywhere.+ if [ "$status" -eq 1 ] && [ "$VR_OBSERVE" = 'true' ]; then+ echo "Observe run: visual changes recorded, not gating."+ exit 0+ fi+ exit "$status"calculate-running-time:name: Calculate running timediff --git a/products/visual_review/README.md b/products/visual_review/README.mdindex 284d2ee08582..da214265a2fd 100644--- a/products/visual_review/README.md+++ b/products/visual_review/README.md@@ -88,7 +88,7 @@ Final job: `vr run complete --run-id <id>`- backend fetches baseline from GitHub- classifies all snapshots, detects removals- triggers diffs, posts GitHub Check- - exit code gates the pipeline (1 = changes need review)+ - exit code gates the pipeline (1 = changes need review, 2 = command failed)```The backend is the source of truth for baselines — it fetches the `.snapshots.yml` from GitHub at `complete_run` time. The CLI no longer sends baseline hashes; it only sends snapshot identifiers and content hashes.@@ -111,7 +111,10 @@ The CLI uploads directly to S3 via presigned POST URLs — the backend never pro**`vr run upload`** — per-shard: hashes PNGs in a directory, sends identifiers + hashes via `add-snapshots`, uploads missing artifacts.-**`vr run complete`** — triggers completion (classification, removal detection, diffs). On `review` runs: exits 1 if unapproved changes are detected, 0 if clean or `--auto-approve` is set. On `observe` runs: always exits 0 (non-gating).+**`vr run complete`** — triggers completion (classification, removal detection, diffs).+Exits 1 if unapproved changes are detected, 0 if clean or `--auto-approve` is set, and 2 if the command itself failed (auth, network, timeout, backend processing).+The exit code does not depend on `--purpose`: an `observe` run still exits 1 on unapproved changes, so a caller that wants tracking-only behavior has to tolerate exit 1 itself.+`ci-storybook.yml` does exactly that on master pushes and merge-queue branches, and treats exit 2 as a failure everywhere.### Run purposesdiff --git a/products/visual_review/cli/src/index.ts b/products/visual_review/cli/src/index.tsindex 383b1a62fcc1..37bf9eaea6eb 100644--- a/products/visual_review/cli/src/index.ts+++ b/products/visual_review/cli/src/index.ts@@ -141,7 +141,10 @@ run.command('complete')process.exit(exitCode)} catch (error) {console.error('Error:', error)- process.exit(1)+ // 2, not 1, so callers can tell a failed CLI apart from the exit 1 that+ // runComplete returns for unresolved visual changes. CI tolerates the latter+ // on tracking-only runs and must never tolerate this.+ process.exit(2)}})