From c2db9d077d854e516d94b8862a4dea5feb6e4e4f Mon Sep 17 00:00:00 2001 From: James McNamara Date: Mon, 25 Mar 2024 13:26:26 -0700 Subject: [PATCH] [sg] legacy commands continue watching after compilation failures (#61274) Allow legacy commands to fail compilation and continue watching --- dev/sg/internal/run/run.go | 7 ++++++- sg.config.yaml | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dev/sg/internal/run/run.go b/dev/sg/internal/run/run.go index 597b3753926..63274d7b3a8 100644 --- a/dev/sg/internal/run/run.go +++ b/dev/sg/internal/run/run.go @@ -106,6 +106,12 @@ func (runner *cmdRunner) run(ctx context.Context) error { shouldRestart, err := runner.reinstall(ctx, cmd) if err != nil { runner.printError(cmd, err) + + // If the error came from the install step then we continue watching + // and will retry building if there is another source change. + if _, ok := err.(installErr); ok { + continue + } return err } @@ -164,7 +170,6 @@ func (runner *cmdRunner) reinstall(ctx context.Context, cmd SGConfigCommand) (bo } if err := installer.RunInstall(ctx, runner.parentEnv); err != nil { - runner.printError(cmd, err) return false, err } newHash, err := md5HashFile(bin) diff --git a/sg.config.yaml b/sg.config.yaml index 178b11a983d..9a16b4f4e76 100644 --- a/sg.config.yaml +++ b/sg.config.yaml @@ -287,6 +287,7 @@ commands: export GCFLAGS='all=-N -l' fi go build -gcflags="$GCFLAGS" -o .bin/worker github.com/sourcegraph/sourcegraph/cmd/worker + checkBinary: .bin/worker watch: - lib - internal