Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/build: Consider running go mod download prior to build #88

Closed
radeksimko opened this issue Jan 10, 2023 · 0 comments · Fixed by #90
Closed

internal/build: Consider running go mod download prior to build #88

radeksimko opened this issue Jan 10, 2023 · 0 comments · Fixed by #90
Labels
enhancement New feature or request

Comments

@radeksimko
Copy link
Member

We currently run just go build in order to build the tool after cloning (and installing appropriate Go version):

goArgs := []string{"build", "-o", filepath.Join(targetDir, binaryName)}
if gb.DetectVendoring {
vendorDir := filepath.Join(repoDir, "vendor")
if fi, err := os.Stat(vendorDir); err == nil && fi.IsDir() {
goArgs = append(goArgs, "-mod", "vendor")
}
}
gb.log().Printf("executing %s %q in %q", reqGo.Cmd, goArgs, repoDir)
cmd := exec.CommandContext(ctx, reqGo.Cmd, goArgs...)
cmd.Dir = repoDir
out, err := cmd.CombinedOutput()
if err != nil {
return "", fmt.Errorf("unable to build: %w\n%s", err, out)
}

There is a high likelihood that we would benefit from running go mod download to 1st download dependencies in a separate step. That would allow us to more clearly distinguish failures related to dependency/networking issues from actual build errors.

2023/01/10 03:15:32 go_build.go:62: executing go1.19.4 ["build" "-o" "/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/hc-install-terraform-a086453783c74e0bf03ea23009d15d3af63e7415317297110/terraform"] in "/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/hc-install-build-terraform2680510350"
panic: test timed out after 30m0s

goroutine 40 [running]:
testing.(*M).startAlarm.func1()
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1788 +0x8e
created by time.goFunc
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/time/sleep.go:180 +0x31

goroutine 1 [chan receive, 29 minutes]:
testing.(*T).Run(0xc00012c820, {0x1404bcd, 0xa0c61c40cb}, 0x141d488)
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1307 +0x375
testing.runTests.func1(0xc00013c930)
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1598 +0x6e
testing.tRunner(0xc00012c820, 0xc000113d18)
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1259 +0x[102](https://github.com/hashicorp/hc-install/actions/runs/3879804908/jobs/6617325038#step:4:103)
testing.runTests(0xc0000e4580, {0x16f89e0, 0x4, 0x4}, {0x[108](https://github.com/hashicorp/hc-install/actions/runs/3879804908/jobs/6617325038#step:4:109)294d, 0x13ff24d, 0x1700520})
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1596 +0x43f
testing.(*M).Run(0xc0000e4580)
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1504 +0x51d
main.main()
	_testmain.go:49 +0x14b

goroutine 19 [chan receive, 17 minutes]:
os/exec.(*Cmd).Wait(0xc01674c000)
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/os/exec/exec.go:518 +0x188
os/exec.(*Cmd).Run(0x4)
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/os/exec/exec.go:341 +0x39
os/exec.(*Cmd).CombinedOutput(0xc01674c000)
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/os/exec/exec.go:570 +0x96
github.com/hashicorp/hc-install/internal/build.(*GoBuild).Build(0x16f3ca0, {0x1486d08, 0xc01a1b4180}, {0xc00008f5c0, 0x2}, {0xc01a139180, 0x77}, {0x13fd28e, 0x9})
	/Users/runner/work/hc-install/hc-install/internal/build/go_build.go:65 +0x57b
github.com/hashicorp/hc-install/build.(*GitRevision).Build(0xc0000e4600, {0x1486cd0, 0xc0000a8008})
	/Users/runner/work/hc-install/hc-install/build/git_revision.go:171 +0xbab
github.com/hashicorp/hc-install/build.TestGitRevision_terraform(0xc00012c9c0)
	/Users/runner/work/hc-install/hc-install/build/git_revision_test.go:28 +0x1c5
testing.tRunner(0xc00012c9c0, 0x141d488)
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1259 +0x102
created by testing.(*T).Run
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/testing/testing.go:1306 +0x35a

goroutine 11 [IO wait, 17 minutes]:
internal/poll.runtime_pollWait(0x6f3ddc8, 0x72)
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/netpoll.go:303 +0x85
internal/poll.(*pollDesc).wait(0xc01a1b4060, 0xc01885c242, 0x1)
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/internal/poll/fd_poll_runtime.go:84 +0x32
internal/poll.(*pollDesc).waitRead(...)
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Read(0xc01a1b4060, {0xc01885c242, 0x1bbe, 0x1bbe})
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/internal/poll/fd_unix.go:167 +0x25a
os.(*File).read(...)
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/os/file_posix.go:32
os.(*File).Read(0xc0186d2010, {0xc01885c242, 0x0, 0xc00b84fea0})
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/os/file.go:[119](https://github.com/hashicorp/hc-install/actions/runs/3879804908/jobs/6617325038#step:4:120) +0x5e
bytes.(*Buffer).ReadFrom(0xc0196b0[120](https://github.com/hashicorp/hc-install/actions/runs/3879804908/jobs/6617325038#step:4:121), {0x[147](https://github.com/hashicorp/hc-install/actions/runs/3879804908/jobs/6617325038#step:4:148)d180, 0xc0186d2010})
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/bytes/buffer.go:204 +0x98
io.copyBuffer({0x147c680, 0xc0196b0120}, {0x147d180, 0xc0186d2010}, {0x0, 0x0, 0x0})
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/io/io.go:409 +0x14b
io.Copy(...)
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/io/io.go:382
os/exec.(*Cmd).writerDescriptor.func1()
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/os/exec/exec.go:311 +0x3a
os/exec.(*Cmd).Start.func1(0x0)
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/os/exec/exec.go:444 +0x25
created by os/exec.(*Cmd).Start
	/Users/runner/hostedtoolcache/go/1.17.13/x64/src/os/exec/exec.go:443 +0x87b
FAIL	github.com/hashicorp/hc-install/build	1802.321s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant