Repository navigation
fix(workspace): topological sort and incremental dep propagation - #34
Merged
Merged
Conversation
- Add sortPackagesTopologically() to workspace_utils.dart using Kahn's algorithm so dependency packages are always versioned before their consumers. - Replace the single end-of-loop updateWorkspaceDependencies() call in versionWorkspace() with an incremental call immediately after each package is versioned, so downstream packages see the updated constraint during the same run and the dep bump is captured inside the new tag's range (preventing cascade bumps on subsequent runs). - Add workspace_utils_test.dart covering: stable order, single dep, diamond graph, liquid_flutter scenario, external deps ignored, cycle fallback.
Version AnalysisNext Version: Changelog: 📄 View detailed changelog in job summary |
Version AnalysisNext Version: Changelog: 📄 View detailed changelog in job summary |
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.
Problem
Two bugs in workspace versioning caused unreliable version bumps across multiple runs:
Bug 1 — Ordering:
updateWorkspaceDependenciesran as a single pass after all packages were versioned. Packages were processed in workspace declaration order, so a consumer package could be versioned before its dependency's pubspec was updated. The dep-constraint bump would then land in a later commit, outside the new tag's range, causing another spurious bump on the next CI run.Bug 2 — Cascade: Because the dep bump ended up in a post-tag commit, the next run would see
pubspec.yamlchanges since the last tag and re-version the consumer again indefinitely.Fix
workspace_utils.dart: AddsortPackagesTopologically()(Kahn's algorithm). Builds the intra-workspace dependency graph from each package'spubspec.yamland returns packages in an order where every dependency appears before its consumers. Falls back to the original order on detected cycles (with a warning).workspace_version.dart: UsesortPackagesTopologicallybefore the versioning loop. After each package is versioned, immediately callupdateWorkspaceDependenciesfor just that package so that downstream consumers see the updated constraint within the same run. The dep bump is then captured inside the new tag's range, and subsequent runs start from the new tag with no spurious changes.Tests
6 new unit tests in
test/version/workspace_utils_test.dart:liquid_flutterbeforetest_utilsandreactive_forms