Skip to content

Commit 72fc475

Browse files
committed
fix
1 parent 7931950 commit 72fc475

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cmd/grafana-app-sdk/generate.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ func preflightGeneratedGoCodeCompiles(cfg *config.Config, files codejen.Files) e
268268
if goModule == "" {
269269
return preflightGeneratedGoCodeCompilesWithOverlay(files)
270270
}
271+
if currentModule != "" && goModule == currentModule {
272+
return preflightGeneratedGoCodeCompilesWithOverlay(files)
273+
}
271274

272275
goGenRoot := cfg.Codegen.GoGenPath
273276
if goGenRoot == "" {
@@ -420,7 +423,10 @@ func preflightGeneratedGoCodeCompiles(cfg *config.Config, files codejen.Files) e
420423

421424
buildCmd := exec.Command("go", "build", "-mod=mod", "./...")
422425
buildCmd.Dir = moduleRoot
423-
buildCmd.Env = append(os.Environ(), "GOSUMDB=off")
426+
buildCmd.Env = append(os.Environ(),
427+
"GOSUMDB=off",
428+
fmt.Sprintf("GOCACHE=%s", filepath.Join(tempDir, "gocache")),
429+
)
424430
out, err := buildCmd.CombinedOutput()
425431
if err != nil {
426432
return fmt.Errorf("generated code contains compilation errors, this is likely a bug in sdk. If you'd like to bypass the compilation check, please set skipPreflightCompilationCheck to true.\n\n%s\n%w", strings.TrimSpace(string(out)), err)
@@ -488,7 +494,10 @@ func preflightGeneratedGoCodeCompilesWithOverlay(files codejen.Files) error {
488494

489495
buildArgs := append([]string{"build", "-overlay", overlayPath}, packages...)
490496
buildCmd := exec.Command("go", buildArgs...)
491-
buildCmd.Env = append(os.Environ(), "GOSUMDB=off")
497+
buildCmd.Env = append(os.Environ(),
498+
"GOSUMDB=off",
499+
fmt.Sprintf("GOCACHE=%s", filepath.Join(tempDir, "gocache")),
500+
)
492501
out, err := buildCmd.CombinedOutput()
493502
if err != nil {
494503
return fmt.Errorf("generated code contains compilation errors, this is likely a bug in sdk. If you'd like to bypass the compilation check, please set skipPreflightCompilationCheck to true.\n\n%s\n%w", strings.TrimSpace(string(out)), err)

0 commit comments

Comments
 (0)