-
Notifications
You must be signed in to change notification settings - Fork 20
feat: auto-convert Go library deps to weak dependencies #325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iQQBot
wants to merge
5
commits into
main
Choose a base branch
from
feature/go-library-weak-deps
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,264
−119
Conversation
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
210c8cd to
5fc7d5c
Compare
7da9ab1 to
69b3ee4
Compare
WVerlaek
reviewed
Jan 16, 2026
Member
WVerlaek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise LGTM!
a38626b to
2d4d09f
Compare
Go packages with packaging: library are now automatically treated as weak dependencies when referenced. This means: - Source files are copied to _deps/ (not built artifacts) - go.mod replace directives are added - Builds run in parallel (don't block dependent package) - Version tracking ensures cache invalidation when libraries change This improves build parallelism for Go monorepos where libraries are used for source code via go.mod replace, not for built artifacts. Co-authored-by: Ona <no-reply@ona.com>
A Go library can only be a weak dependency if ALL its transitive dependencies are also Go libraries. If a Go library depends on non-Go-library packages (e.g., generic packages), it's treated as a regular hard dependency. This simplifies the implementation by removing the need to handle hard deps of weak deps separately. Co-authored-by: Ona <no-reply@ona.com>
- Release build semaphore before waiting for weak deps (allows other builds to proceed) - All packages wait for their weak deps (transitive failures propagate) - Remove artifact from cache if weak dep fails - Respect src rules when copying weak dependency sources Co-authored-by: Ona <no-reply@ona.com>
2d4d09f to
44e5c89
Compare
The weak dependency feature is now opt-in via CLI flag. When not enabled, weak deps are treated as hard deps (built artifacts are copied instead of source code). - Add GetEffectiveDependencies/GetEffectiveTransitiveDependencies helpers - Update buildDependencies to use effective deps - Update Build() to use effective transitive deps - Update buildGo() to use effective deps Co-authored-by: Ona <no-reply@ona.com>
44e5c89 to
7dc802f
Compare
Tests verify that: - With flag enabled: only hard deps are returned, weak deps handled separately - With flag disabled: weak deps are treated as hard deps (combined) - Transitive dependencies work correctly in both modes Co-authored-by: Ona <no-reply@ona.com>
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
Go packages with
packaging: libraryare now automatically treated as "weak dependencies" when referenced, improving build parallelism for Go monorepos.Motivation
In Go monorepos, libraries are typically used for their source code via
go.mod replacedirectives, not for their built artifacts. Previously, leeway would:This was inefficient because the dependent package only needs the library's source files, not its built artifact.
Changes
Weak Dependencies for Go Libraries
When a Go package with
packaging: libraryis listed as a dependency, it's automatically converted to a "weak dependency":_deps/go.mod replaceaddedImportant Constraint
A Go library can only be a weak dependency if all its transitive dependencies are also Go libraries. If a Go library depends on non-Go-library packages (e.g., generic packages), it's treated as a regular hard dependency.
Build Flow
Weak Dependency Failure Propagation
If a weak dependency fails (e.g., tests fail), all packages that depend on it will also fail before running their build commands. This prevents publishing packages (e.g., Docker images) when their weak dependencies have failed.
Implementation uses a broadcast channel pattern - multiple packages can wait on the same weak dep result.
Cache Behavior
Example
Testing
canBeWeakDep()andcheckAllDepsAreGoLibraries()GetTransitiveWeakDependencies()collectWeakDependencies()