fix(updates): scope commit drift to monorepo rootDirectory (#637) - #665
Open
santhiprakash wants to merge 1 commit into
Open
fix(updates): scope commit drift to monorepo rootDirectory (#637)#665santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
A monorepo project with its own rootDirectory was offered an unnecessary redeploy when other projects in the same repo changed. The drift tracker compared the deployed SHA against the repo-wide branch HEAD (latestSha) with no path scoping, so a commit that touched only a sibling directory still showed 'Update available A -> B'. When the project has a rootDirectory, compute behind-ness from the GitHub compare of deployedSha..latestSha filtered to paths under that root (or a configured monorepo shared-path / root-config file). Uses the same leaf matching as the webhook and smart-route deploys so the update badge and deploy routing always agree on 'affects this project'. Conservative on every failure mode: missing ctx, compare API error, or a truncated compare response (>=300 files) keep 'behind' as-is so the badge never misses a real update because the network blinked.
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
Fixes #637.
A monorepo project with its own
rootDirectorywas offered an unnecessary redeploy when other projects in the same repo changed. The drift tracker compared the deployed SHA against the repo-wide branch HEAD (latestSha) with no path scoping, so a commit that touched only a sibling directory still showed "Update available A → B".When the project has a
rootDirectory, the drift now computes "behind" from the GitHub compare ofdeployedSha..latestShafiltered to paths under that root (or a configured monorepo shared-path / root-config file). Uses the same leaf matching as the webhook and smart-route deploys so the update badge and deploy routing always agree on "affects this project".Behavior
rootDirectorywhose committed diff is confined to a sibling directory → no spurious "Update available".apps/backend-utils/*does not match rootapps/backend.framework === "monorepo"— inert in single-app projects.Conservative failure modes
The badge must never miss a real update because the network blinked:
behindas-is.behindas-is.behindas-is.Tests
apps/api/src/modules/github/webhook-changed-files.test.ts— new unit tests forrootScopeAffected(10 cases).apps/api/test/modules/updates/drift-evaluation.test.ts— 10 new test cases for the monorepo scoping behavior inevaluateDrift, covering all the conservative-failure branches above.All 26
drift-evaluationtests pass. No existing tests changed.Verification
bun run --cwd apps/api lint(typecheck) clean.bun x vitest run test/modules/updates/— 38 passed (26 drift + 12 cache), 0 failed.bun x vitest run src/modules/— 974 passed, 0 failed (one unrelatedgh-identity-healthtest failure pre-exists onmain).Diff