Skip to content

chore(ci): select affected Storybook shards - #69932

Merged
mariusandra merged 4 commits into
masterfrom
posthog-code/selective-storybook-shards
Jul 13, 2026
Merged

chore(ci): select affected Storybook shards#69932
mariusandra merged 4 commits into
masterfrom
posthog-code/selective-storybook-shards

Conversation

@mariusandra

Copy link
Copy Markdown
Collaborator

Problem

Visual regression CI runs the full Storybook shard matrix for every ready frontend pull request, even when a change can only affect a small feature area. This spends runner time on unrelated stories, such as SQL editor snapshots after an experiments-only change.

Why: Keep visual coverage strong while avoiding shards that cannot observe a changed module.

Changes

  • Use the existing Vite module graph selector on every internal pull request, not only drafts.
  • Run only transitively affected story files and size the shard matrix to their estimated workload.
  • Fall back to the full suite for shared UI code, unresolved runtime files, selector failures, and explicit run-ci-frontend requests.
flowchart TD
    A[Frontend pull request] --> B[Full 16-shard Storybook matrix]
    classDef phBlue fill:#1d4aff,stroke:#1d4aff,color:#fff;
    classDef phYellow fill:#f9bd2b,stroke:#f9bd2b,color:#000;
    class A phYellow;
    class B phBlue;
Loading
flowchart TD
    A[Frontend pull request] --> B[Build Vite module graph]
    B --> C{Safe to select?}
    C -->|Yes| D[Affected stories on sized shard matrix]
    C -->|No| E[Full 16-shard matrix]
    classDef phBlue fill:#1d4aff,stroke:#1d4aff,color:#fff;
    classDef phRed fill:#f54e00,stroke:#f54e00,color:#fff;
    classDef phYellow fill:#f9bd2b,stroke:#f9bd2b,color:#000;
    classDef phGray fill:#e5e7eb,stroke:#c7ccd1,color:#000;
    class A phYellow;
    class B phGray;
    class C phRed;
    class D,E phBlue;
Loading

How did you test this code?

  • node --test bin/find-affected-stories.test.mjs
  • node --check bin/find-affected-stories
  • git diff --check

The tests catch regressions where feature-local changes select unrelated stories, shared library changes are narrowed unsafely, or unresolved runtime frontend files are skipped. hogli ci:preflight --fix was unavailable in this runner because neither hogli nor flox is installed.

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

No user-facing documentation change.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Implemented with OpenAI Codex. Invoked /writing-tests before adding the selector regression tests. The selector intentionally fails closed to the full matrix for shared library changes and any frontend runtime file missing from the build graph.


Created with PostHog Code

Generated-By: PostHog Code
Task-Id: a16c1c5f-7dc1-4a87-8309-d76da59d8abe
@mariusandra mariusandra self-assigned this Jul 10, 2026
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

🤖 CI report

Bundle size — 🟢 -61.6 KiB (-0.1%)

Uncompressed size of every built .js bundle, compared against the base branch.

Total: 70.02 MiB · 🟢 -61.6 KiB (-0.1%)

File Size Δ vs base
render-query/src/render-query/render-query.js 24.17 MiB 🔺 +4.9 KiB (+0.0%)
posthog-app/_parent/products/dashboards/frontend/widgets/experiments/ExperimentsListWidget.js 5.5 KiB 🔺 +1018 B (+22.0%)
posthog-app/_parent/products/dashboards/frontend/widgets/experiments/ExperimentResultsWidget.js 7.1 KiB 🔺 +1017 B (+16.3%)

Posted automatically by build-bundle-size-report · uncompressed bytes from dist-report

Eager graph — within budget

How much code each root ships on the eager path — downloaded and parsed before the surface is interactive. Measured from the esbuild output chunks (post-tree-shake, static imports only); lazy import() / React.lazy chunks are not counted.

Root Eager (shipped) Δ vs base Budget
entry (logged-out pages, app bootstrap)
src/index.tsx
1.21 MiB · 22 files no change ███░░░░░░░ 28.1% of 4.29 MiB
authenticated shell (every logged-in page)
src/scenes/AuthenticatedShell.tsx
8.10 MiB · 2,972 files 🔺 +19.6 KiB (+0.2%) █████████░ 87.6% of 9.25 MiB

🟢 node_modules/monaco-editor/ stays out of src/index.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/index.tsx
🟢 [object Object] stays out of src/index.tsx
🟢 [object Object] stays out of src/index.tsx
🟢 node_modules/monaco-editor/ stays out of src/scenes/AuthenticatedShell.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/scenes/AuthenticatedShell.tsx
🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx
🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx

Largest files eagerly shipped from src/index.tsx
Size File
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
24.6 KiB ../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js
6.3 KiB ../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js
4.5 KiB ../node_modules/.pnpm/@jspm+core@2.1.0/node_modules/@jspm/core/nodelibs/browser/process.js
3.9 KiB ../node_modules/.pnpm/scheduler@0.23.2/node_modules/scheduler/cjs/scheduler.production.min.js
1.4 KiB ../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
1.3 KiB src/RootErrorBoundary.tsx
912 B ../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js
789 B src/scenes/ChunkLoadErrorBoundary.tsx
668 B src/index.tsx
Largest files eagerly shipped from src/scenes/AuthenticatedShell.tsx
Size File
277.3 KiB ../node_modules/.pnpm/posthog-js@1.399.1/node_modules/posthog-js/dist/rrweb.js
266.9 KiB ../node_modules/.pnpm/@posthog+icons@0.37.4_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
224.6 KiB src/taxonomy/core-filter-definitions-by-group.json
221.5 KiB ../node_modules/.pnpm/posthog-js@1.399.1/node_modules/posthog-js/dist/module.js
164.0 KiB src/queries/validators.js
154.2 KiB ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
105.9 KiB src/lib/api.ts
93.3 KiB ../node_modules/.pnpm/prosemirror-view@1.40.1/node_modules/prosemirror-view/dist/index.js
90.6 KiB ../node_modules/.pnpm/@tiptap+core@3.20.6_@tiptap+pm@3.20.6/node_modules/@tiptap/core/dist/index.js

Posted automatically by check-eager-graph · sizes are eager output bytes (shipped, post-tree-shake) from the esbuild metafile · part of #32479

⚠️ Dist folder size — 🔺 +202.4 KiB (+0.0%)

Total size of the built frontend/dist folder (all assets), compared against the base branch.

Total: 1438.39 MiB · 🔺 +202.4 KiB (+0.0%)

Playwright — all passed

All tests passed.

View test results →

@trunk-io

trunk-io Bot commented Jul 10, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@PostHog PostHog deleted a comment from github-actions Bot Jul 10, 2026
@mariusandra
mariusandra marked this pull request as ready for review July 10, 2026 11:46
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team July 10, 2026 11:47
@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff (1)

  1. .github/workflows/ci-storybook.yml, line 818-824 (link)

    P1 Zero Stories Skip Ready Runs

    When the selector returns selective with affected_story_count equal to 0, this branch sets should_run=false and skips visual regression entirely. That was safe for draft-only selection because the ready-for-review run still used the full matrix, but selection now runs on ready PRs too, so a ready PR with a stale or incomplete graph can merge with no Storybook shards running.

Reviews (1): Last reviewed commit: "chore(ci): select affected Storybook sha..." | Re-trigger Greptile

Comment thread .github/workflows/ci-storybook.yml Outdated
Generated-By: PostHog Code
Task-Id: a16c1c5f-7dc1-4a87-8309-d76da59d8abe
@posthog

posthog Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

👋 Visual changes detected for this PR.

Review and approve in PostHog Visual Review

If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix.

Comment thread .github/workflows/ci-storybook.yml Outdated
echo "Selector declined to narrow (mode=$MODE); draft skips visual-regression (full run happens on ready for review)"
fall_back_to_skip
echo "Selector declined to narrow (mode=$MODE); running the full visual-regression matrix"
fall_back_to_full

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is now running the full suite in draft PRs, or running selective tests on ALL PRs? if the former that's a waste of CI, and if the latter that's no bueno until we setup a merge queue (I don't like the idea of merging a PR without running the full suite).

Copy link
Copy Markdown
Collaborator Author

The current implementation runs selective Storybook tests on all PRs, with fail-closed full-suite fallbacks for shared or uncertain changes. I cannot change .github/workflows/** in this CI-feedback turn based on review guidance alone under the task safety constraints. This needs a follow-up implementation turn or an independently failing required check before I can adjust the ready-PR policy.

Generated-By: PostHog Code
Task-Id: a16c1c5f-7dc1-4a87-8309-d76da59d8abe

@gantoine gantoine left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👍🏼

@mariusandra
mariusandra merged commit fd4ff8b into master Jul 13, 2026
236 of 240 checks passed
@mariusandra
mariusandra deleted the posthog-code/selective-storybook-shards branch July 13, 2026 12:54
@deployment-status-posthog

deployment-status-posthog Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-07-13 13:47 UTC Run
prod-us ✅ Deployed 2026-07-13 13:58 UTC Run
prod-eu ✅ Deployed 2026-07-13 13:59 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants