Skip to content

Commit

Permalink
[RB] Support configuring whether to run targets on the local vs remot…
Browse files Browse the repository at this point in the history
…e runner (buildbuddy-io#6755)
  • Loading branch information
maggie-lou committed Jun 13, 2024
1 parent 3245d82 commit 58f3b51
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cli/remotebazel/remotebazel.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ var (
remoteRunner = remoteFlagset.String("remote_runner", defaultRemoteExecutionURL, "The Buildbuddy grpc target the remote runner should run on.")
timeout = remoteFlagset.Duration("timeout", 0, "If set, requests that have exceeded this timeout will be canceled automatically. (Ex. --timeout=15m; --timeout=2h)")
execPropsFlag = bbflag.New(remoteFlagset, "runner_exec_properties", []string{}, "Exec properties that will apply to the *ci runner execution*. Key-value pairs should be separated by '=' (Ex. --runner_exec_properties=NAME=VALUE). Can be specified more than once. NOTE: If you want to apply an exec property to the bazel command that's run on the runner, just pass at the end of the command (Ex. bb remote build //... --remote_default_exec_properties=OSFamily=linux).")
runRemotely = remoteFlagset.Bool("run_remotely", true, "For `run` commands, whether the target should be run remotely. If false, the target will be built remotely, and then fetched and run locally.")

defaultBranchRefs = []string{"refs/heads/main", "refs/heads/master"}
)
Expand Down Expand Up @@ -703,7 +704,7 @@ func Run(ctx context.Context, opts RunOpts, repoConfig *RepoConfig) (int, error)
fetchOutputs := false
runOutput := false
bazelArgs := arg.GetBazelArgs(opts.Args)
if len(bazelArgs) > 0 && (bazelArgs[0] == "build" || bazelArgs[0] == "run") {
if len(bazelArgs) > 0 && (bazelArgs[0] == "build" || (bazelArgs[0] == "run" && !*runRemotely)) {
fetchOutputs = true
if bazelArgs[0] == "run" {
runOutput = true
Expand Down Expand Up @@ -762,6 +763,7 @@ func Run(ctx context.Context, opts RunOpts, repoConfig *RepoConfig) (int, error)
ContainerImage: *containerImage,
Env: envVars,
ExecProperties: platform.Properties,
RunRemotely: *runRemotely,
}
req.GetRepoState().Patch = append(req.GetRepoState().Patch, repoConfig.Patches...)

Expand Down

0 comments on commit 58f3b51

Please sign in to comment.