Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ func addBuildFlags(cmd *cobra.Command) {
cmd.Flags().Bool("report-github", os.Getenv("GITHUB_OUTPUT") != "", "Report package build success/failure to GitHub Actions using the GITHUB_OUTPUT environment variable")
cmd.Flags().Bool("fixed-build-dir", true, "Use a fixed build directory for each package, instead of based on the package version, to better utilize caches based on absolute paths (defaults to true)")
cmd.Flags().Bool("docker-export-to-cache", false, "Export Docker images to cache instead of pushing directly (enables SLSA L3 compliance)")
cmd.Flags().Bool("go-library-weak-deps", false, "Treat Go library dependencies as weak dependencies (copy source instead of built artifacts)")
}

func getBuildOpts(cmd *cobra.Command) ([]leeway.BuildOption, cache.LocalCache) {
Expand Down Expand Up @@ -412,6 +413,11 @@ func getBuildOpts(cmd *cobra.Command) ([]leeway.BuildOption, cache.LocalCache) {
dockerExportSet = true
}

goLibraryWeakDeps, err := cmd.Flags().GetBool("go-library-weak-deps")
if err != nil {
log.Fatal(err)
}

return []leeway.BuildOption{
leeway.WithLocalCache(localCache),
leeway.WithRemoteCache(remoteCache),
Expand All @@ -430,6 +436,7 @@ func getBuildOpts(cmd *cobra.Command) ([]leeway.BuildOption, cache.LocalCache) {
leeway.WithInFlightChecksums(inFlightChecksums),
leeway.WithDockerExportToCache(dockerExportToCache, dockerExportSet),
leeway.WithDockerExportEnv(dockerExportEnvValue, dockerExportEnvSet),
leeway.WithGoLibraryWeakDeps(goLibraryWeakDeps),
}, localCache
}

Expand Down
15 changes: 15 additions & 0 deletions pkg/leeway/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,11 @@ type buildOptions struct {
DockerExportEnvValue bool // Value from explicit user env var
DockerExportEnvSet bool // Whether user explicitly set env var (before workspace)

// GoLibraryWeakDeps enables treating Go library dependencies as weak dependencies.
// When enabled, Go library deps copy source code instead of built artifacts,
// allowing parallel builds while still running tests.
GoLibraryWeakDeps bool

context *buildContext
}

Expand Down Expand Up @@ -640,6 +645,16 @@ func WithDockerExportEnv(value, isSet bool) BuildOption {
}
}

// WithGoLibraryWeakDeps enables treating Go library dependencies as weak dependencies.
// When enabled, Go library deps copy source code instead of built artifacts,
// allowing parallel builds while still running tests.
func WithGoLibraryWeakDeps(enabled bool) BuildOption {
return func(opts *buildOptions) error {
opts.GoLibraryWeakDeps = enabled
return nil
}
}

func withBuildContext(ctx *buildContext) BuildOption {
return func(opts *buildOptions) error {
opts.context = ctx
Expand Down
Loading