feat: auto-convert Go library deps to weak dependencies - #325
Closed
iQQBot wants to merge 5 commits into
Closed
Conversation
iQQBot
force-pushed
the
feature/go-library-weak-deps
branch
6 times, most recently
from
January 15, 2026 07:50
210c8cd to
5fc7d5c
Compare
iQQBot
marked this pull request as ready for review
January 15, 2026 16:36
iQQBot
force-pushed
the
feature/go-library-weak-deps
branch
2 times, most recently
from
January 15, 2026 20:42
7da9ab1 to
69b3ee4
Compare
WVerlaek
reviewed
Jan 16, 2026
iQQBot
force-pushed
the
feature/go-library-weak-deps
branch
2 times, most recently
from
January 19, 2026 13:47
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>
iQQBot
force-pushed
the
feature/go-library-weak-deps
branch
from
January 19, 2026 14:06
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>
iQQBot
force-pushed
the
feature/go-library-weak-deps
branch
from
January 20, 2026 19:50
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>
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
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()