feat(workflows): make shell step timeout configurable (#3327)#3328
Open
Noor-ul-ain001 wants to merge 3 commits into
Open
feat(workflows): make shell step timeout configurable (#3327)#3328Noor-ul-ain001 wants to merge 3 commits into
Noor-ul-ain001 wants to merge 3 commits into
Conversation
The `shell` step hardcoded a 300s subprocess timeout, so any command that legitimately runs longer than five minutes (a full build, a linter aggregator, an integration-test target) was killed with TimeoutExpired and failed the whole run, with no YAML knob to raise the limit. Add an optional `timeout` field (seconds) that defaults to 300 for backward compatibility and is threaded through to `subprocess.run`. The timeout failure message now reports the configured value instead of a hardcoded 300. `validate` rejects a `timeout` that is not a positive number (bool is rejected explicitly, since it is an int subclass but a config error rather than a duration). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 task
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes the workflow shell step’s subprocess timeout configurable per-step (defaulting to the historical 300s), so longer-running QA/build commands can run without being killed by a hardcoded limit.
Changes:
- Add optional
timeout(seconds) toshellstep execution, defaulting to 300. - Update the timeout failure message to report the configured timeout.
- Add/extend
ShellStepvalidation and unit tests to cover timeout behavior and invalid values.
Show a summary per file
| File | Description |
|---|---|
| src/specify_cli/workflows/steps/shell/init.py | Threads timeout from config into subprocess.run, updates timeout error message, and validates timeout input. |
| tests/test_workflows.py | Adds TestShellStep coverage for default/configured timeout wiring, error messaging, and validation cases. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Low
Comment on lines
+1318
to
+1322
| # A string and a bool are both invalid (bool is an int subclass but a | ||
| # config error, not a duration). | ||
| for bad in ("30", True): | ||
| errors = step.validate({"id": "qa", "run": "echo hi", "timeout": bad}) | ||
| assert any("'timeout' must be a positive number" in e for e in errors) |
Contributor
Author
There was a problem hiding this comment.
Added in 41cb5f1 — test_validate_rejects_non_finite_timeout asserts float('inf'), float('-inf'), and float('nan') are all rejected by validate(). Confirmed inf/nan slip past a plain > 0 check, so the test exercises the math.isfinite guard rather than duplicating existing coverage.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
The isfinite guard added in 955d46a rejects YAML .inf/.nan timeouts, but no test asserted it. inf and nan are floats that pass a plain > 0 check (nan <= 0 is False), so without an explicit case a regression could silently reaccept them and crash subprocess.run(timeout=...) at runtime. Addresses the remaining Copilot review comment on PR github#3328. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #3327. The workflow
shellstep hardcoded a 300-second subprocess timeout with no way to override it, so any command that legitimately runs longer than five minutes — a full build, a MegaLinter/golangci-lint aggregator, an integration-test target — was killed withTimeoutExpiredand failed the entire run. There was no YAML knob to raise the limit, which madeshellsteps unusable as a probe/gate over real project QA commands.Changes
timeoutfield (seconds) to the shell step, read viaconfig.get("timeout", 300)and threaded intosubprocess.run. Defaults to 300 so existing workflows are unaffected.validaterejects atimeoutthat is not a positive number.boolis rejected explicitly — it is anintsubclass, buttimeout: trueis a config error, not a duration.Acceptance criteria (from the issue)
timeout:value overrides the 300s default and is honored bysubprocess.run.timeout:preserves current behavior (300s).validaterejects a non-positive or non-numerictimeout.Testing
Seven new tests under
TestShellStep:timeoutis passed tosubprocess.runvalidaterejects non-positive (0,-30) and non-numeric ("30",True) valuesvalidateaccepts positiveint/floatpytest tests/test_workflows.py::TestShellStep→ 13 passed. Confirmed the behavior-changing tests fail without the source change (test-the-test viagit stash).🤖 Generated with Claude Code