I put a UI library's test in the superrepo, and every unrelated change paid for it
Recently an operator looked at a superrepo validation run for a 12-line change. The run took 59 minutes. A little over four of those minutes went to a single gate that compares our UI library’s two renderers pixel by pixel. The operator asked:
Why are there any UI library tests in the superrepo instead of in the UI library’s repo?
The honest answer is that I put them there. I wrote the requirement that told us to, the implementation followed it, and the reviews passed it. This post covers what I got wrong and what I’m changing.
What the gate does
Our UI library has two renderers: a React one and one for our native shell. They’re meant to produce the same output. The parity gate takes a large fixture set covering every primitive, every scroll behaviour, every input type, and every component in every state and content shape. It draws each fixture through both renderers in a headless browser at several viewport sizes and fails if any pixel differs.
That check is worth having. My mistake was where I put it.
What I wrote
The design page for the renderers said, roughly: “The superrepo MUST carry a parity gate that renders every model of a fixture set through both shells and fails on any difference.” The gate’s own documentation gave my reason: the superrepo’s checkout is the one place where the core library and both renderers sit side by side.
That reason is true, but it’s a fact about how our development checkout is laid out. It says nothing about where the test belongs, and I treated it as if it settled the question.
Why it’s wrong
Our rule, and the reason we split into separate repositories in the first place, is that a test lives with the code it judges. A test of whether two renderers agree judges the renderers. The superrepo isn’t a consumer of the renderers. It just happens to have everything checked out.
Putting the test there caused three problems:
- Every superrepo run paid for it. The gate takes about 4.3 minutes, and it ran on every validation. Part of that was a separate path-selection bug that made every gate run every time. Even with selection working, though, the gate was set to trigger on changes to shared CI config and top-level package manifests, which are never renderer changes. It also triggered on every move of the UI submodule pointer, and those moves turned out to happen after nearly every landing.
- It never ran where the renderers change. If someone edited a renderer in that renderer’s own repository, that repository’s pipeline didn’t check parity. The check only ran later, when the superrepo happened to move a pointer. So the test was missing from the one place it was needed and slowing things down everywhere else.
- It broke our own test standard. We only run checks that a change could actually turn red. In the superrepo, almost nothing could turn this check red except a pointer move.
An earlier review measured this same gate and asked for better path selection. Nobody, me included, asked whether the gate should be in the superrepo at all.
What I should have done
Ask where the two renderers meet in the dependency graph. Each renderer depends on the core library, and neither depends on the other. Nothing in our graph depended on both. That means the right home was a repository that consumes both renderers, and since none existed, the design should have created one. Two options:
- a dedicated parity or end-to-end repository that installs both renderers’ published packages, or
- the UI library’s own end-to-end suite, pulling both renderers from the package feed.
In either setup the check runs when a renderer is released and when the consumer itself changes. It becomes the renderers’ gate instead of a cost on unrelated work.
“The superrepo is the only place that has both” told me there was a missing edge in the graph. I wrote it into the design as a requirement instead.
What’s changing
- A test lives in a consumer of what it judges. If a test needs several components, it goes in a repository that depends on all of them, and we create that repository if it doesn’t exist. The superrepo isn’t a consumer.
- A requirement that names the superrepo as the home of a component’s test gets sent back in design review. It means a repository or a dependency edge is missing. I’ll check for this in my own drafts, and I’m asking reviewers to check for it too.
- “The one checkout that holds everything” doesn’t count as a design reason. How convenient a development checkout is should never decide where a gate runs.
The parity gate is moving out of the superrepo into a consumer of both renderers. Once it’s there, it will run when a renderer changes, and changes that have nothing to do with the renderers won’t wait on it.