From 027c901c71f2e6491c9af3f65a93638818dde755 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Wed, 26 Jul 2023 10:12:52 +0200 Subject: [PATCH 1/2] Added support for build command chaining and error on missing wheel --- bundle/config/artifact.go | 18 ++++++++++++++---- bundle/libraries/libraries.go | 8 ++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/bundle/config/artifact.go b/bundle/config/artifact.go index 1ac371e93d..60331eb134 100644 --- a/bundle/config/artifact.go +++ b/bundle/config/artifact.go @@ -1,6 +1,7 @@ package config import ( + "bytes" "context" "fmt" "os/exec" @@ -40,10 +41,19 @@ func (a *Artifact) Build(ctx context.Context) ([]byte, error) { return nil, fmt.Errorf("no build property defined") } - buildParts := strings.Split(a.BuildCommand, " ") - cmd := exec.CommandContext(ctx, buildParts[0], buildParts[1:]...) - cmd.Dir = a.Path - return cmd.CombinedOutput() + out := make([][]byte, 0) + commands := strings.Split(a.BuildCommand, " && ") + for _, command := range commands { + buildParts := strings.Split(command, " ") + cmd := exec.CommandContext(ctx, buildParts[0], buildParts[1:]...) + cmd.Dir = a.Path + res, err := cmd.CombinedOutput() + if err != nil { + return res, err + } + out = append(out, res) + } + return bytes.Join(out, []byte{}), nil } func (a *Artifact) NormalisePaths() { diff --git a/bundle/libraries/libraries.go b/bundle/libraries/libraries.go index ff86a34b5c..d7b6c9f686 100644 --- a/bundle/libraries/libraries.go +++ b/bundle/libraries/libraries.go @@ -68,6 +68,10 @@ func findArtifactsAndMarkForUpload(ctx context.Context, lib *compute.Library, b return err } + if len(matches) == 0 && isLocalLibrary(lib) { + return fmt.Errorf("no library found for %s", libPath(lib)) + } + for _, match := range matches { af, err := findArtifactFileByLocalPath(match, b) if err != nil { @@ -105,3 +109,7 @@ func libPath(library *compute.Library) string { return "" } + +func isLocalLibrary(library *compute.Library) bool { + return library.Whl != "" || library.Jar != "" +} From 339bea27a57d91338f14b6435c7e261ea51de970 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Wed, 26 Jul 2023 14:40:17 +0200 Subject: [PATCH 2/2] use libpath --- bundle/libraries/libraries.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundle/libraries/libraries.go b/bundle/libraries/libraries.go index d7b6c9f686..f7a2574adb 100644 --- a/bundle/libraries/libraries.go +++ b/bundle/libraries/libraries.go @@ -111,5 +111,5 @@ func libPath(library *compute.Library) string { } func isLocalLibrary(library *compute.Library) bool { - return library.Whl != "" || library.Jar != "" + return libPath(library) != "" }