Skip to content

Add timeout param to ctx.actions.run#29395

Open
jpopadak wants to merge 1 commit intobazelbuild:masterfrom
jpopadak:jpopadak/run-timeout
Open

Add timeout param to ctx.actions.run#29395
jpopadak wants to merge 1 commit intobazelbuild:masterfrom
jpopadak:jpopadak/run-timeout

Conversation

@jpopadak
Copy link
Copy Markdown

Description

Add timeout param to ctx.actions.run for RBE and local environment use.

  • Add timeout parameter to ctx.actions.run() and ctx.actions.run_shell() Starlark API
  • Add SpawnAction.Builder.setTimeout(Duration) that sets ExecutionRequirements.TIMEOUT in execution info
  • Add empty-string guard to Spawns.getTimeout()
  • Add unit tests for setTimeout and Starlark timeout parameter (positive, zero, null, negative, override)

Motivation

Some actions in a Remote Execution environment can take a long time and there is no way to split them up due to some third party application commands. The environment can have their own timeouts, but if a single action needs to be longer, it should be explicitly configured for that longer timeout.

Build API Changes

Does this PR affect the Build API? Yes - Starlark API

If yes, please answer the following:

  1. Has this been discussed in a design doc or issue? Custom RBE timeout for non-test actions #21142
  2. Is the change backward compatible? Yes - additive to something the user does not have access to change.
  3. If it's a breaking change, what is the migration plan? N/A

Checklist

  • I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable).

Release Notes

RELNOTES[NEW]: Add parameter timeout to ctx.actions.{run,run_shell}

- Add timeout parameter to ctx.actions.run() and
  ctx.actions.run_shell() Starlark API
- Add SpawnAction.Builder.setTimeout(Duration) that sets
  ExecutionRequirements.TIMEOUT in execution info
- Add empty-string guard to Spawns.getTimeout()
- Add unit tests for setTimeout and Starlark timeout
  parameter (positive, zero, null, negative, override)
@jpopadak jpopadak marked this pull request as ready for review April 24, 2026 22:06
@jpopadak jpopadak requested a review from a team as a code owner April 24, 2026 22:06
@jpopadak jpopadak requested review from aranguyen and removed request for a team April 24, 2026 22:06
@github-actions github-actions Bot added team-Performance Issues for Performance teams team-Configurability platforms, toolchains, cquery, select(), config transitions team-Starlark-Integration Issues involving Bazel's integration with Starlark, excluding builtin symbols awaiting-review PR is awaiting review from an assigned reviewer team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts labels Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-Configurability platforms, toolchains, cquery, select(), config transitions team-Performance Issues for Performance teams team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts team-Starlark-Integration Issues involving Bazel's integration with Starlark, excluding builtin symbols

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant