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: fix crash in MustRunCommandWithOutput #28709

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions internal/build/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,18 @@ func MustRunCommand(cmd string, args ...string) {
MustRun(exec.Command(cmd, args...))
}

// MustRunCommandWithOutput runs the given command, and ensures that some output will be
// printed while it runs. This is useful for CI builds where the process will be stopped
// when there is no output.
func MustRunCommandWithOutput(cmd string, args ...string) {
var done chan bool
// This is a little loop to generate some output, so CI does not tear down the
// process after 300 seconds.
interval := time.NewTicker(time.Minute)
defer interval.Stop()
go func() {
for i := 0; i < 15; i++ {
for range interval.C {
fmt.Printf("Waiting for command %q\n", cmd)
select {
case <-time.After(time.Minute):
break
case <-done:
return
}
}
}()
MustRun(exec.Command(cmd, args...))
close(done)
}

var warnedAboutGit bool
Expand Down
Loading