Skip to content

Commit 5fc7d5c

Browse files
iQQBotona-agent
andcommitted
feat: auto-convert Go library deps to weak dependencies
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>
1 parent 74b1482 commit 5fc7d5c

5 files changed

Lines changed: 934 additions & 37 deletions

File tree

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ srcs:
108108
- "glob/**/path"
109109
# Deps list dependencies to other packages which must be built prior to building this package. How these dependencies are made
110110
# available during build depends on the package type.
111+
# NOTE: Go packages with `packaging: library` are automatically treated as "weak dependencies" - their source files
112+
# are copied (not built artifacts), and they don't block the build. See "Go Library Dependencies" section below.
111113
deps:
112114
- some/other:package
113115
# Argdeps makes build arguments version relevant. I.e. if the value of a build arg listed here changes, so does the package version.
@@ -125,6 +127,8 @@ config:
125127
```YAML
126128
config:
127129
# Packaging method. See https://godoc.org/github.com/gitpod-io/leeway/pkg/leeway#GoPackaging for details. Defaults to library.
130+
# IMPORTANT: Packages with `packaging: library` are treated as "weak dependencies" when referenced by other packages.
131+
# This means their source files are copied (not built artifacts), and they build in parallel rather than blocking.
128132
packaging: library
129133
# If true leeway runs `go generate -v ./...` prior to testing/building. Defaults to false.
130134
generate: false
@@ -144,6 +148,43 @@ config:
144148
goMod: "../go.mod"
145149
```
146150
151+
#### Go Library Dependencies (Weak Dependencies)
152+
153+
When a Go package with `packaging: library` is listed as a dependency, leeway automatically treats it as a "weak dependency". This behavior is optimized for Go's module system:
154+
155+
| Aspect | Regular Dependency | Go Library (Weak) Dependency |
156+
|--------|-------------------|------------------------------|
157+
| Affects package version | ✅ | ✅ |
158+
| Must be built first | ✅ | ❌ |
159+
| What's copied to `_deps/` | Built artifact | Source files |
160+
| `go.mod replace` added | ✅ | ✅ |
161+
| Added to build queue | ✅ | ✅ |
162+
163+
**Why this matters:**
164+
- Go libraries are typically used for their source code via `go.mod replace` directives
165+
- The library's tests can run in parallel with the dependent package's build
166+
- Changes to the library still trigger rebuilds of dependent packages (version tracking)
167+
- Build times improve because packages don't wait for library builds to complete
168+
169+
**Example:**
170+
```yaml
171+
# my-lib/BUILD.yaml
172+
packages:
173+
- name: lib
174+
type: go
175+
config:
176+
packaging: library # This makes it a weak dependency when referenced
177+
178+
# my-app/BUILD.yaml
179+
packages:
180+
- name: app
181+
type: go
182+
deps:
183+
- my-lib:lib # Automatically treated as weak dep - sources copied, builds in parallel
184+
config:
185+
packaging: app
186+
```
187+
147188
### Yarn packages
148189
```YAML
149190
config:

0 commit comments

Comments
 (0)