Skip to content

perf(ci): scope pr-rtl to the components a PR touches - #4796

Merged
nynexman4464 merged 1 commit into
mainfrom
nynexman4464/perf/rtl-audit-scope
Aug 7, 2026
Merged

nynexman4464 merged 1 commit into
mainfrom
nynexman4464/perf/rtl-audit-scope

Conversation

@nynexman4464

@nynexman4464 nynexman4464 commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem

pr-rtl ran the RTL audit unfiltered on every PR — all ~1400 core-* stories, ~26 min, the long pole of PR CI by 2.5× (next slowest: test, 10 min). It ran even on PRs touching no component: on #4758 (eslint-plugin + docs only) pr-a11y correctly skipped in 0s while pr-rtl audited the whole library. Yield for those 26 minutes: 27 verdicts and 1492 N-A.

Changes

1. Scope the job like pr-a11y — gate on check-components.has_components, download pr-analysis, pass the changed components to the audit's --filter. All three mechanisms already existed; pr-a11y used them and pr-rtl used none. New components stay covered via newComponents. The empty-string guard matters: an absent or empty --filter means "audit everything".

2. Short-circuit D5 before the RTL page load — autoPositionalMirror loaded LTR, always loaded RTL, then checked whether either produced candidates. With no LTR candidate there's nothing to measure against, and 1378 of 1394 stories have none. Also closes a silent false-pass: the old ltr === 0 && rtl === 0 guard let one-sided stories reach a compare loop running min(ltr, rtl) = 0 times, reporting pass having compared nothing.

3. Root rtl:audit script — parity with a11y:audit, and avoids a footgun: pnpm -F is --filter, so pnpm -F @astryxdesign/storybook rtl-audit --filter Avatar has pnpm eat the flag and audit everything. Plus a short pointer in CONTRIBUTING.md.

Also fixes pr-rtl red on docsite-only PRs

Reported separately: docsite-only PRs build no Storybook artifact, so short_hash is empty and the job tries to download storybook-. Confirmed on #4770 (run). The proposed fix was "mirror pr-a11y's guard" — which is what this PR does, so no separate guard PR is needed.

Coverage tradeoff

Scoped CI can't see a component no PR touched. #4797 restores that with a weekly full sweep, mirroring pr-a11y / a11y-weekly.yml.

⚠️ The README and ci.yml comments here reference rtl-weekly.yml, which lands in #4797 — please land them together.

Test plan

Verified against the Storybook artifact from run 31122588220 (same 1394 stories), not a rebuild.

Scoped: pnpm rtl:audit -- --filter Avatar,TableTree → 19.7s (from ~26 min), reproducing that run's Avatar verdicts exactly (cand=3/14/4/6/14).

Full sweep A/B, same machine, same input:

wall AUTO PM
main 1724.81s 11 pass / 0 fail / 114 N-A 16 pass / 0 fail / 1378 N-A
this PR 936.17s 11 pass / 0 fail / 114 N-A 16 pass / 0 fail / 1378 N-A

45.7% faster from the short-circuit alone, with verdicts diffed element-by-element: auto, pm, and cur all identical (n=125 / 1394 / 3).

Also: ci.yml parses with the expected 8 steps; pnpm check:repo clean. ci.yml and rtl-audit.mjs already fail prettier on main (it only covers *.{ts,tsx,md}), so they're deliberately not reformatted. No changeset — no publishable package, matching #4718 / #4708 / #4674.

Follow-ups

@vercel

vercel Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 7, 2026 6:41pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

pr-rtl ran the RTL audit unfiltered on every PR, sweeping all ~1400 core-*
stories in ~26 minutes — the long pole of PR CI by 2.5x, and paid even by PRs
that touch no component. On #4758 (eslint-plugin + docs only) the sibling
pr-a11y correctly skipped in 0s while pr-rtl audited the whole library.

Scope the job like pr-a11y: gate on check-components.has_components, download
pr-analysis, and pass the changed components to the audit's --filter. Every
piece already existed — check-components publishes has_components,
analyze-pr.js writes newComponents/modifiedComponents, rtl-audit.mjs parses
--filter — pr-a11y used all three, pr-rtl used none. New components stay
covered via newComponents.

Also short-circuit D5 before the RTL page load. autoPositionalMirror loaded
LTR, always loaded RTL, then checked whether either produced candidates. With
no LTR candidate there is nothing to measure against, and 1378 of 1394 stories
have none, so this drops ~half of D5's page loads. It also closes a silent
false-pass: the old `ltr === 0 && rtl === 0` guard let one-sided stories reach
a compare loop that runs min(ltr, rtl) = 0 times and reported "pass" having
compared nothing.

Adds a root rtl:audit script for parity with a11y:audit, which also avoids a
footgun — pnpm -F IS --filter, so `pnpm -F @astryxdesign/storybook rtl-audit
--filter Avatar` has pnpm eat the flag and audit everything.

Coverage for untouched components comes from the weekly full sweep in the
stacked follow-up, mirroring the pr-a11y / a11y-weekly.yml split.

Test plan: verified against the Storybook artifact from run 31122588220 (same
1394 stories). `pnpm rtl:audit -- --filter Avatar,TableTree` finishes in 19.7s
and reproduces that run's Avatar verdicts exactly (cand=3/14/4/6/14). Full
unfiltered sweep of the unmodified script on the same input: 1724s, matching
CI's counts (AUTO 11/0/114, PM 16/0/1378). ci.yml parses; pnpm check:repo
clean; prettier-clean.
@nynexman4464
nynexman4464 force-pushed the nynexman4464/perf/rtl-audit-scope branch from 310537d to bc6316a Compare August 7, 2026 18:38
github-actions Bot added a commit that referenced this pull request Aug 7, 2026
@nynexman4464
nynexman4464 merged commit 846ec30 into main Aug 7, 2026
19 checks passed
@github-actions
github-actions Bot deleted the nynexman4464/perf/rtl-audit-scope branch August 8, 2026 06:25

This branch was successfully deployed

1 active deployment
Preview — bc6316ad Deployed Aug 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant