Speed up schema diff reporting with bounded comparison - #7
Merged
Merged
Conversation
test_it_matches_the_schema_committed_to_this_repository compared two copies of the whole Linear schema with assertSame. On a match that costs nothing, but on a mismatch PHPUnit's differ weighs all ~35,800 lines of one document against all ~35,800 of the other, which took about fifteen minutes to print. In CI that pushed one job to 14:15 and timed the other five out mid-diff, so they were reported as cancelled and a real bug looked like flaky infrastructure. The test now matches on a hash and, when the hashes differ, describes the first few differences with BoundedDiff: a line diff that walks both sides once, re-syncs over short runs of added or removed lines, and stops after five hunks. The message still names the concrete drift, including the case this caught, @deprecated(reason:) dropped from input fields under webonyx/graphql-php below 15.34.1. With the schema mismatched, the test now fails in 1.7 seconds. The CI timeout goes back to 15 minutes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XyfyD8QtJPci6seYNVdBXx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces PHPUnit's full-document differ (which takes ~15 minutes on the Linear schema) with a bounded diff that walks both sides once, re-syncs over short runs of changes, and stops after a few hunks. This allows schema validation tests to complete in seconds rather than timing out.
Changes
Added
BoundedDiffsupport class (tests/Support/BoundedDiff.php): A line-by-line differ that:Added
BoundedDiffTest(tests/Feature/BoundedDiffTest.php): Comprehensive test coverage including:Updated
SchemaFetcherTestto useBoundedDiff:Reduced CI timeout from 30 to 15 minutes: The bounded diff eliminates the need for extra time to render a 15-minute diff.
Implementation Details
The
BoundedDiffalgorithm:windowlines for a re-sync point (3+ matching lines)max_hunkshunks or when no re-sync is foundhttps://claude.ai/code/session_01XyfyD8QtJPci6seYNVdBXx