From 665a44756112a17061e24bf3c7563f0bdb8ebcf6 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Wed, 11 Dec 2024 18:57:43 +0100 Subject: [PATCH] more traces to understand CI failure --- internal/lsp/build.go | 9 ++++++--- internal/tools/build.go | 13 ++++++++++++- testdata/document_open.txtar | 4 ++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/internal/lsp/build.go b/internal/lsp/build.go index 12c223c..56b0d6f 100644 --- a/internal/lsp/build.go +++ b/internal/lsp/build.go @@ -32,14 +32,17 @@ func (s *server) TranspileAndBuild(file *GnoFile) ([]ErrorInfo, error) { } preOut, _ := tools.Transpile(tmpDir) - slog.Info(string(preOut)) if len(preOut) > 0 { + slog.Info("transpile error", "out", string(preOut)) return parseErrors(file, string(preOut), "transpile") } buildOut, _ := tools.Build(tmpDir) - slog.Info(string(buildOut)) - return parseErrors(file, string(buildOut), "build") + if len(buildOut) > 0 { + slog.Info("build error", "out", string(buildOut)) + return parseErrors(file, string(buildOut), "build") + } + return nil, nil } // This is used to extract information from the `gno build` command diff --git a/internal/tools/build.go b/internal/tools/build.go index d48ff6f..f98df2d 100644 --- a/internal/tools/build.go +++ b/internal/tools/build.go @@ -1,12 +1,23 @@ package tools import ( + "fmt" + "os" "os/exec" "path/filepath" + "strings" ) // Build a Gno package: gno transpile -gobuild . // TODO: Remove this in the favour of directly using tools/transpile.go func Build(rootDir string) ([]byte, error) { - return exec.Command("gno", "transpile", "-skip-imports", "-gobuild", filepath.Join(rootDir)).CombinedOutput() + cmd := exec.Command("gno", "transpile", "-skip-imports", "-gobuild", filepath.Join(rootDir)) + // FIXME(tb): See https://github.com/gnolang/gno/pull/1695/files#r1697255524 + const disableGoMod = "GO111MODULE=off" + cmd.Env = append(os.Environ(), disableGoMod) + bz, err := cmd.CombinedOutput() + if err != nil { + return bz, fmt.Errorf("running '%s': %w: %s", strings.Join(cmd.Args, " "), err, string(bz)) + } + return bz, nil } diff --git a/testdata/document_open.txtar b/testdata/document_open.txtar index 5cb76f0..250c5f2 100644 --- a/testdata/document_open.txtar +++ b/testdata/document_open.txtar @@ -4,16 +4,16 @@ lsp initialized input/initialized.json # open document w/o errors lsp textDocument/didOpen input/didOpen_x.json -cmpenv output/notify1.json expected/notify1.json # open document with errors lsp textDocument/didOpen input/didOpen_y.json -cmpenv output/notify2.json expected/notify2.json # gno transpile should have created a *.gno.gen.go files cmp $GNOPLS_WD/script-document_open/x.gno.gen.go x.gno.gen.go.golden cmp $GNOPLS_WD/script-document_open/y.gno.gen.go y.gno.gen.go.golden +cmpenv output/notify1.json expected/notify1.json +cmpenv output/notify2.json expected/notify2.json -- x.gno -- package foo