From 535275711f8dc17b5fc042ba1bf7e5d4d9c1877b Mon Sep 17 00:00:00 2001 From: "Alberto J. Gomez" Date: Wed, 4 Dec 2024 13:07:10 +0100 Subject: [PATCH 1/6] avoid compiling every time --- integration-tests/integration-test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/integration-tests/integration-test.go b/integration-tests/integration-test.go index 9f1569c30..c6917a151 100644 --- a/integration-tests/integration-test.go +++ b/integration-tests/integration-test.go @@ -5,6 +5,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strconv" "strings" "syscall" @@ -159,9 +160,12 @@ func expectExitCode(command string, code int) { func runCommand(command string) (string, error) { fmt.Println("Running command:", command) - args := []string{"run", "../main.go"} - args = append(args, strings.Split(command, " ")...) - cmd := exec.Command("go", args...) + binary := "../bin/bruin" + if runtime.GOOS == "windows" { + binary += ".exe" + } + args := strings.Split(command, " ") + cmd := exec.Command(binary, args...) cmd.Dir = currentFolder output, err := cmd.Output() From dfdc43def1d9b7cf09a45b5a4c264cdd928c8f5d Mon Sep 17 00:00:00 2001 From: "Alberto J. Gomez" Date: Wed, 4 Dec 2024 16:00:54 +0100 Subject: [PATCH 2/6] copy file --- .gitignore | 1 + Makefile | 6 +++++- integration-tests/integration-test.go | 24 ++++++++++++++---------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index dd0e923dc..42958c1b8 100644 --- a/.gitignore +++ b/.gitignore @@ -142,4 +142,5 @@ glossary.yaml integration-tests/duckdb.db integration-tests/logs +integration-tests/bruin !integration-tests/.bruin.yml \ No newline at end of file diff --git a/Makefile b/Makefile index fb8be334a..06bf7fe41 100644 --- a/Makefile +++ b/Makefile @@ -23,10 +23,14 @@ build: deps integration-test: build + @touch integration-tests/.git + @touch integration-tests/bruin + @rm -rf integration-tests/.git + @rm integration-tests/bruin @echo "$(OK_COLOR)==> Running integration tests...$(NO_COLOR)" @cd integration-tests && git init @go run integration-tests/integration-test.go - @rm -rf integration-tests/.git + clean: @rm -rf ./bin diff --git a/integration-tests/integration-test.go b/integration-tests/integration-test.go index c6917a151..2e1aeef4b 100644 --- a/integration-tests/integration-test.go +++ b/integration-tests/integration-test.go @@ -5,7 +5,6 @@ import ( "os" "os/exec" "path/filepath" - "runtime" "strconv" "strings" "syscall" @@ -17,12 +16,19 @@ import ( var currentFolder string func main() { - var err error - currentFolder = filepath.Join(currentFolder, "integration-tests") + path, err := os.Getwd() if err != nil { fmt.Println(err) os.Exit(1) } + currentFolder = filepath.Join(path, "integration-tests") + cmd := exec.Command("bash", "-c", "cp bin/bruin integration-tests/bruin") + out, err := cmd.Output() + if err != nil { + fmt.Println(err) + fmt.Println(string(out)) + os.Exit(1) + } expectExitCode("validate happy-path", 0) expectExitCode("run --use-uv happy-path", 0) @@ -130,11 +136,12 @@ func expectJSONOutput(command string, jsonFilePath string) { if path.Json() == "\"path\"" { continue } - + fmt.Println("Mismatch at: ", d.Path) fmt.Print("Expected json: ") fmt.Println(d.NewValues) fmt.Print("Not Matching found json: ") fmt.Println(d.OldValues) + os.Exit(1) } } @@ -146,6 +153,7 @@ func expectExitCode(command string, code int) { if err != nil { if exitCode != code { fmt.Println(strconv.Itoa(code) + " Was expected but got:" + strconv.Itoa(exitCode)) + fmt.Printf("Error: %v\n", err) fmt.Println(output) os.Exit(1) } @@ -159,13 +167,9 @@ func expectExitCode(command string, code int) { } func runCommand(command string) (string, error) { - fmt.Println("Running command:", command) - binary := "../bin/bruin" - if runtime.GOOS == "windows" { - binary += ".exe" - } + fmt.Println("Running command: bruin ", command) args := strings.Split(command, " ") - cmd := exec.Command(binary, args...) + cmd := exec.Command("bruin", args...) cmd.Dir = currentFolder output, err := cmd.Output() From 64bedbbc2b45c9e64b5c4e066852c016a5ebfb01 Mon Sep 17 00:00:00 2001 From: "Alberto J. Gomez" Date: Wed, 4 Dec 2024 16:38:43 +0100 Subject: [PATCH 3/6] add dot --- integration-tests/integration-test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/integration-test.go b/integration-tests/integration-test.go index 2e1aeef4b..2b8789690 100644 --- a/integration-tests/integration-test.go +++ b/integration-tests/integration-test.go @@ -169,7 +169,7 @@ func expectExitCode(command string, code int) { func runCommand(command string) (string, error) { fmt.Println("Running command: bruin ", command) args := strings.Split(command, " ") - cmd := exec.Command("bruin", args...) + cmd := exec.Command("./bruin", args...) cmd.Dir = currentFolder output, err := cmd.Output() From 49c567fe2e6c7cd044af589c5f7361a02cd0a554 Mon Sep 17 00:00:00 2001 From: "Alberto J. Gomez" Date: Wed, 4 Dec 2024 16:56:51 +0100 Subject: [PATCH 4/6] fix by OS --- integration-tests/integration-test.go | 8 +++++++- pkg/path/walk.go | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/integration-tests/integration-test.go b/integration-tests/integration-test.go index 2b8789690..c4e09a121 100644 --- a/integration-tests/integration-test.go +++ b/integration-tests/integration-test.go @@ -5,6 +5,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strconv" "strings" "syscall" @@ -169,7 +170,12 @@ func expectExitCode(command string, code int) { func runCommand(command string) (string, error) { fmt.Println("Running command: bruin ", command) args := strings.Split(command, " ") - cmd := exec.Command("./bruin", args...) + binary := "./bruin" + if runtime.GOOS == "windows" { + binary = "bruin" + } + cmd := exec.Command(binary, args...) + cmd.Dir = currentFolder output, err := cmd.Output() diff --git a/pkg/path/walk.go b/pkg/path/walk.go index 8f47918c4..91a4a4812 100644 --- a/pkg/path/walk.go +++ b/pkg/path/walk.go @@ -43,7 +43,6 @@ func GetPipelinePaths(root string, pipelineDefinitionFile []string) ([]string, e return nil }) - if err != nil { return nil, errors.Wrapf(err, "error walking directory") } From 2a4da04f7016da8f5c708b2d5e3e573b4e4e090c Mon Sep 17 00:00:00 2001 From: turtleDev Date: Fri, 6 Dec 2024 18:53:55 +0530 Subject: [PATCH 5/6] ci: fix windows e2e test failing --- integration-tests/integration-test.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/integration-tests/integration-test.go b/integration-tests/integration-test.go index c4e09a121..a656ddce5 100644 --- a/integration-tests/integration-test.go +++ b/integration-tests/integration-test.go @@ -23,12 +23,13 @@ func main() { os.Exit(1) } currentFolder = filepath.Join(path, "integration-tests") - cmd := exec.Command("bash", "-c", "cp bin/bruin integration-tests/bruin") - out, err := cmd.Output() - if err != nil { - fmt.Println(err) - fmt.Println(string(out)) - os.Exit(1) + + if runtime.GOOS == "windows" { + out, err := exec.Command("mv", "bin/bruin", "bin/bruin.exe").Output() + if err != nil { + fmt.Printf("failed to rename binary for execution on windows: %s\n", out) + panic(err) + } } expectExitCode("validate happy-path", 0) @@ -170,10 +171,12 @@ func expectExitCode(command string, code int) { func runCommand(command string) (string, error) { fmt.Println("Running command: bruin ", command) args := strings.Split(command, " ") - binary := "./bruin" + executable := "bruin" if runtime.GOOS == "windows" { - binary = "bruin" + executable = "bruin.exe" } + wd, _ := os.Getwd() + binary := filepath.Join(wd, "bin", executable) cmd := exec.Command(binary, args...) cmd.Dir = currentFolder From afb26ffa0fbd298554b4863b5d7205acd88e0d81 Mon Sep 17 00:00:00 2001 From: turtleDev Date: Fri, 6 Dec 2024 22:14:08 +0530 Subject: [PATCH 6/6] integration tests: fix formatting --- integration-tests/integration-test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/integration-test.go b/integration-tests/integration-test.go index a656ddce5..7247690dc 100644 --- a/integration-tests/integration-test.go +++ b/integration-tests/integration-test.go @@ -169,7 +169,7 @@ func expectExitCode(command string, code int) { } func runCommand(command string) (string, error) { - fmt.Println("Running command: bruin ", command) + fmt.Println("Running command: bruin", command) args := strings.Split(command, " ") executable := "bruin" if runtime.GOOS == "windows" {