Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit ebaefb6

Browse files
committed
more traces to understand CI failure
1 parent c3f5171 commit ebaefb6

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed

internal/lsp/build.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,24 @@ func (s *server) TranspileAndBuild(file *GnoFile) ([]ErrorInfo, error) {
3131
return nil, err
3232
}
3333

34-
preOut, _ := tools.Transpile(tmpDir)
35-
slog.Info(string(preOut))
34+
preOut, err := tools.Transpile(tmpDir)
3635
if len(preOut) > 0 {
36+
slog.Info("transpile error", "out", string(preOut))
3737
return parseErrors(file, string(preOut), "transpile")
3838
}
39+
if err != nil {
40+
return nil, err
41+
}
3942

40-
buildOut, _ := tools.Build(tmpDir)
41-
slog.Info(string(buildOut))
42-
return parseErrors(file, string(buildOut), "build")
43+
buildOut, err := tools.Build(tmpDir)
44+
if len(buildOut) > 0 {
45+
slog.Info("build error", "out", string(buildOut))
46+
return parseErrors(file, string(buildOut), "build")
47+
}
48+
if err != nil {
49+
return nil, err
50+
}
51+
return nil, nil
4352
}
4453

4554
// This is used to extract information from the `gno build` command

internal/tools/build.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
package tools
22

33
import (
4+
"fmt"
5+
"os"
46
"os/exec"
57
"path/filepath"
8+
"strings"
69
)
710

811
// Build a Gno package: gno transpile -gobuild <dir>.
912
// TODO: Remove this in the favour of directly using tools/transpile.go
1013
func Build(rootDir string) ([]byte, error) {
11-
return exec.Command("gno", "transpile", "-skip-imports", "-gobuild", filepath.Join(rootDir)).CombinedOutput()
14+
cmd := exec.Command("gno", "transpile", "-skip-imports", "-gobuild", filepath.Join(rootDir))
15+
// FIXME(tb): See https://github.com/gnolang/gno/pull/1695/files#r1697255524
16+
const disableGoMod = "GO111MODULE=off"
17+
cmd.Env = append(os.Environ(), disableGoMod)
18+
bz, err := cmd.CombinedOutput()
19+
if err != nil {
20+
return bz, fmt.Errorf("running '%s': %w: %s", strings.Join(cmd.Args, " "), err, string(bz))
21+
}
22+
return bz, nil
1223
}

internal/tools/transpile.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
package tools
22

33
import (
4+
"fmt"
45
"os/exec"
56
"path/filepath"
7+
"strings"
68
)
79

810
// Transpile a Gno package: gno transpile <dir>.
911
func Transpile(rootDir string) ([]byte, error) {
10-
return exec.Command("gno", "transpile", "-skip-imports", filepath.Join(rootDir)).CombinedOutput()
12+
cmd := exec.Command("gno", "transpile", "-skip-imports", filepath.Join(rootDir))
13+
bz, err := cmd.CombinedOutput()
14+
if err != nil {
15+
return bz, fmt.Errorf("running '%s': %w: %s", strings.Join(cmd.Args, " "), err, string(bz))
16+
}
17+
return bz, nil
1118
}

testdata/document_open.txtar

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ lsp initialized input/initialized.json
44

55
# open document w/o errors
66
lsp textDocument/didOpen input/didOpen_x.json
7-
cmpenv output/notify1.json expected/notify1.json
87

98
# open document with errors
109
lsp textDocument/didOpen input/didOpen_y.json
11-
cmpenv output/notify2.json expected/notify2.json
1210

1311
# gno transpile should have created a *.gno.gen.go files
1412
cmp $GNOPLS_WD/script-document_open/x.gno.gen.go x.gno.gen.go.golden
1513
cmp $GNOPLS_WD/script-document_open/y.gno.gen.go y.gno.gen.go.golden
1614

15+
cmpenv output/notify1.json expected/notify1.json
16+
cmpenv output/notify2.json expected/notify2.json
1717
-- x.gno --
1818
package foo
1919

0 commit comments

Comments
 (0)