mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
refactor: Remove timeout_minutes parameter from action (#482)
This change removes the custom timeout_minutes parameter from the action in favor of using GitHub Actions' native timeout-minutes feature. Changes: - Removed timeout_minutes input from action.yml and base-action/action.yml - Removed all timeout handling logic from base-action/src/run-claude.ts - Updated base-action/src/index.ts to remove timeoutMinutes parameter - Removed timeout-related tests from base-action/test/run-claude.test.ts - Removed timeout_minutes from all example workflow files (19 files) Rationale: - Simplifies the codebase by removing custom timeout logic - Users can use GitHub Actions' native timeout-minutes at the job/step level - Reduces complexity and maintenance burden - Follows GitHub Actions best practices BREAKING CHANGE: The timeout_minutes parameter is no longer supported. Users should use GitHub Actions' native timeout-minutes instead. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
1
.github/workflows/issue-triage.yml
vendored
1
.github/workflows/issue-triage.yml
vendored
@@ -102,7 +102,6 @@ jobs:
|
||||
prompt_file: /tmp/claude-prompts/triage-prompt.txt
|
||||
allowed_tools: "Bash(gh label list),mcp__github__get_issue,mcp__github__get_issue_comments,mcp__github__update_issue,mcp__github__search_issues,mcp__github__list_issues"
|
||||
mcp_config: /tmp/mcp-config/mcp-servers.json
|
||||
timeout_minutes: "5"
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
2
.github/workflows/test-base-action.yml
vendored
2
.github/workflows/test-base-action.yml
vendored
@@ -25,7 +25,6 @@ jobs:
|
||||
prompt: ${{ github.event.inputs.test_prompt || 'List the files in the current directory starting with "package"' }}
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
allowed_tools: "LS,Read"
|
||||
timeout_minutes: "3"
|
||||
|
||||
- name: Verify inline prompt output
|
||||
run: |
|
||||
@@ -83,7 +82,6 @@ jobs:
|
||||
prompt_file: "test-prompt.txt"
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
allowed_tools: "LS,Read"
|
||||
timeout_minutes: "3"
|
||||
|
||||
- name: Verify prompt file output
|
||||
run: |
|
||||
|
||||
@@ -53,7 +53,6 @@ jobs:
|
||||
path_to_claude_code_executable: /home/runner/.local/bin/claude
|
||||
path_to_bun_executable: /home/runner/.bun/bin/bun
|
||||
allowed_tools: "LS,Read"
|
||||
timeout_minutes: "3"
|
||||
|
||||
- name: Verify custom executables worked
|
||||
run: |
|
||||
|
||||
4
.github/workflows/test-settings.yml
vendored
4
.github/workflows/test-settings.yml
vendored
@@ -26,7 +26,6 @@ jobs:
|
||||
"allow": ["Bash(echo:*)"]
|
||||
}
|
||||
}
|
||||
timeout_minutes: "2"
|
||||
|
||||
- name: Verify echo worked
|
||||
run: |
|
||||
@@ -76,7 +75,6 @@ jobs:
|
||||
"deny": ["Bash(echo:*)"]
|
||||
}
|
||||
}
|
||||
timeout_minutes: "2"
|
||||
|
||||
- name: Verify echo was denied
|
||||
run: |
|
||||
@@ -114,7 +112,6 @@ jobs:
|
||||
Use Bash to echo "Hello from settings file test"
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
settings: "test-settings.json"
|
||||
timeout_minutes: "2"
|
||||
|
||||
- name: Verify echo worked
|
||||
run: |
|
||||
@@ -169,7 +166,6 @@ jobs:
|
||||
Use Bash to echo "This should not work from file"
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
settings: "test-settings.json"
|
||||
timeout_minutes: "2"
|
||||
|
||||
- name: Verify echo was denied
|
||||
run: |
|
||||
|
||||
@@ -57,10 +57,6 @@ inputs:
|
||||
required: false
|
||||
default: "false"
|
||||
|
||||
timeout_minutes:
|
||||
description: "Timeout in minutes for execution"
|
||||
required: false
|
||||
default: "30"
|
||||
claude_args:
|
||||
description: "Additional arguments to pass directly to Claude CLI"
|
||||
required: false
|
||||
@@ -197,7 +193,6 @@ runs:
|
||||
CLAUDE_CODE_ACTION: "1"
|
||||
INPUT_PROMPT_FILE: ${{ runner.temp }}/claude-prompts/claude-prompt.txt
|
||||
INPUT_SETTINGS: ${{ inputs.settings }}
|
||||
INPUT_TIMEOUT_MINUTES: ${{ inputs.timeout_minutes }}
|
||||
INPUT_CLAUDE_ARGS: ${{ steps.prepare.outputs.claude_args }}
|
||||
INPUT_EXPERIMENTAL_SLASH_COMMANDS_DIR: ${{ github.action_path }}/slash-commands
|
||||
INPUT_ACTION_INPUTS_PRESENT: ${{ steps.prepare.outputs.action_inputs_present }}
|
||||
|
||||
@@ -20,10 +20,6 @@ inputs:
|
||||
default: ""
|
||||
|
||||
# Action settings
|
||||
timeout_minutes:
|
||||
description: "Timeout in minutes for Claude Code execution"
|
||||
required: false
|
||||
default: "10"
|
||||
claude_args:
|
||||
description: "Additional arguments to pass directly to Claude CLI (e.g., '--max-turns 3 --mcp-config /path/to/config.json')"
|
||||
required: false
|
||||
@@ -130,7 +126,6 @@ runs:
|
||||
INPUT_PROMPT: ${{ inputs.prompt }}
|
||||
INPUT_PROMPT_FILE: ${{ inputs.prompt_file }}
|
||||
INPUT_SETTINGS: ${{ inputs.settings }}
|
||||
INPUT_TIMEOUT_MINUTES: ${{ inputs.timeout_minutes }}
|
||||
INPUT_CLAUDE_ARGS: ${{ inputs.claude_args }}
|
||||
INPUT_EXPERIMENTAL_SLASH_COMMANDS_DIR: ${{ inputs.experimental_slash_commands_dir }}
|
||||
INPUT_PATH_TO_CLAUDE_CODE_EXECUTABLE: ${{ inputs.path_to_claude_code_executable }}
|
||||
|
||||
@@ -104,5 +104,4 @@ jobs:
|
||||
prompt_file: /tmp/claude-prompts/triage-prompt.txt
|
||||
allowed_tools: "Bash(gh label list),mcp__github__get_issue,mcp__github__get_issue_comments,mcp__github__update_issue,mcp__github__search_issues,mcp__github__list_issues"
|
||||
mcp_config: /tmp/mcp-config/mcp-servers.json
|
||||
timeout_minutes: "5"
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
|
||||
@@ -22,7 +22,6 @@ async function run() {
|
||||
});
|
||||
|
||||
await runClaude(promptConfig.path, {
|
||||
timeoutMinutes: process.env.INPUT_TIMEOUT_MINUTES,
|
||||
claudeArgs: process.env.INPUT_CLAUDE_ARGS,
|
||||
allowedTools: process.env.INPUT_ALLOWED_TOOLS,
|
||||
disallowedTools: process.env.INPUT_DISALLOWED_TOOLS,
|
||||
|
||||
@@ -13,7 +13,6 @@ const EXECUTION_FILE = `${process.env.RUNNER_TEMP}/claude-execution-output.json`
|
||||
const BASE_ARGS = ["--verbose", "--output-format", "stream-json"];
|
||||
|
||||
export type ClaudeOptions = {
|
||||
timeoutMinutes?: string;
|
||||
claudeArgs?: string;
|
||||
model?: string;
|
||||
pathToClaudeCodeExecutable?: string;
|
||||
@@ -56,16 +55,6 @@ export function prepareRunConfig(
|
||||
// BASE_ARGS are always appended last (cannot be overridden)
|
||||
claudeArgs.push(...BASE_ARGS);
|
||||
|
||||
// Validate timeout if provided (affects process wrapper, not Claude)
|
||||
if (options.timeoutMinutes) {
|
||||
const timeoutMinutesNum = parseInt(options.timeoutMinutes, 10);
|
||||
if (isNaN(timeoutMinutesNum) || timeoutMinutesNum <= 0) {
|
||||
throw new Error(
|
||||
`timeoutMinutes must be a positive number, got: ${options.timeoutMinutes}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const customEnv: Record<string, string> = {};
|
||||
|
||||
if (process.env.INPUT_ACTION_INPUTS_PRESENT) {
|
||||
@@ -194,57 +183,15 @@ export async function runClaude(promptPath: string, options: ClaudeOptions) {
|
||||
claudeProcess.kill("SIGTERM");
|
||||
});
|
||||
|
||||
// Wait for Claude to finish with timeout
|
||||
let timeoutMs = 10 * 60 * 1000; // Default 10 minutes
|
||||
if (options.timeoutMinutes) {
|
||||
timeoutMs = parseInt(options.timeoutMinutes, 10) * 60 * 1000;
|
||||
} else if (process.env.INPUT_TIMEOUT_MINUTES) {
|
||||
const envTimeout = parseInt(process.env.INPUT_TIMEOUT_MINUTES, 10);
|
||||
if (isNaN(envTimeout) || envTimeout <= 0) {
|
||||
throw new Error(
|
||||
`INPUT_TIMEOUT_MINUTES must be a positive number, got: ${process.env.INPUT_TIMEOUT_MINUTES}`,
|
||||
);
|
||||
}
|
||||
timeoutMs = envTimeout * 60 * 1000;
|
||||
}
|
||||
// Wait for Claude to finish
|
||||
const exitCode = await new Promise<number>((resolve) => {
|
||||
let resolved = false;
|
||||
|
||||
// Set a timeout for the process
|
||||
const timeoutId = setTimeout(() => {
|
||||
if (!resolved) {
|
||||
console.error(
|
||||
`Claude process timed out after ${timeoutMs / 1000} seconds`,
|
||||
);
|
||||
claudeProcess.kill("SIGTERM");
|
||||
// Give it 5 seconds to terminate gracefully, then force kill
|
||||
setTimeout(() => {
|
||||
try {
|
||||
claudeProcess.kill("SIGKILL");
|
||||
} catch (e) {
|
||||
// Process may already be dead
|
||||
}
|
||||
}, 5000);
|
||||
resolved = true;
|
||||
resolve(124); // Standard timeout exit code
|
||||
}
|
||||
}, timeoutMs);
|
||||
|
||||
claudeProcess.on("close", (code) => {
|
||||
if (!resolved) {
|
||||
clearTimeout(timeoutId);
|
||||
resolved = true;
|
||||
resolve(code || 0);
|
||||
}
|
||||
});
|
||||
|
||||
claudeProcess.on("error", (error) => {
|
||||
if (!resolved) {
|
||||
console.error("Claude process error:", error);
|
||||
clearTimeout(timeoutId);
|
||||
resolved = true;
|
||||
resolve(1);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -30,36 +30,6 @@ describe("prepareRunConfig", () => {
|
||||
expect(prepared.promptPath).toBe("/custom/prompt/path.txt");
|
||||
});
|
||||
|
||||
describe("timeoutMinutes validation", () => {
|
||||
test("should accept valid timeoutMinutes value", () => {
|
||||
const options: ClaudeOptions = { timeoutMinutes: "15" };
|
||||
expect(() =>
|
||||
prepareRunConfig("/tmp/test-prompt.txt", options),
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
test("should throw error for non-numeric timeoutMinutes", () => {
|
||||
const options: ClaudeOptions = { timeoutMinutes: "abc" };
|
||||
expect(() => prepareRunConfig("/tmp/test-prompt.txt", options)).toThrow(
|
||||
"timeoutMinutes must be a positive number, got: abc",
|
||||
);
|
||||
});
|
||||
|
||||
test("should throw error for negative timeoutMinutes", () => {
|
||||
const options: ClaudeOptions = { timeoutMinutes: "-5" };
|
||||
expect(() => prepareRunConfig("/tmp/test-prompt.txt", options)).toThrow(
|
||||
"timeoutMinutes must be a positive number, got: -5",
|
||||
);
|
||||
});
|
||||
|
||||
test("should throw error for zero timeoutMinutes", () => {
|
||||
const options: ClaudeOptions = { timeoutMinutes: "0" };
|
||||
expect(() => prepareRunConfig("/tmp/test-prompt.txt", options)).toThrow(
|
||||
"timeoutMinutes must be a positive number, got: 0",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("claudeArgs handling", () => {
|
||||
test("should parse and include custom claude arguments", () => {
|
||||
const options: ClaudeOptions = {
|
||||
|
||||
@@ -93,6 +93,5 @@ jobs:
|
||||
Error logs:
|
||||
${{ toJSON(fromJSON(steps.failure_details.outputs.result).errorLogs) }}
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
timeout_minutes: "30"
|
||||
use_commit_signing: true
|
||||
claude_args: "--allowedTools 'Edit,MultiEdit,Write,Read,Glob,Grep,LS,Bash(bun:*),Bash(npm:*),Bash(npx:*),Bash(gh:*),mcp__github_file_ops__commit_files,mcp__github_file_ops__delete_files'"
|
||||
|
||||
@@ -94,5 +94,4 @@ jobs:
|
||||
Error logs:
|
||||
${{ toJSON(fromJSON(steps.failure_details.outputs.result).errorLogs) }}
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
timeout_minutes: "30"
|
||||
claude_args: "--allowedTools 'Edit,MultiEdit,Write,Read,Glob,Grep,LS,Bash(git:*),Bash(bun:*),Bash(npm:*),Bash(npx:*),Bash(gh:*)'"
|
||||
|
||||
@@ -21,7 +21,6 @@ jobs:
|
||||
uses: anthropics/claude-code-action@v1-dev
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
timeout_minutes: "60"
|
||||
prompt: |
|
||||
Please review this pull request and provide comprehensive feedback.
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ jobs:
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
# github_token not needed - uses default GITHUB_TOKEN for GitHub operations
|
||||
timeout_minutes: "30"
|
||||
prompt: |
|
||||
Review this pull request comprehensively.
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ jobs:
|
||||
uses: anthropics/claude-code-action@v1-dev
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
timeout_minutes: "60"
|
||||
prompt: |
|
||||
Please review this pull request focusing on the changed files.
|
||||
Provide feedback on:
|
||||
|
||||
@@ -26,7 +26,6 @@ jobs:
|
||||
uses: anthropics/claude-code-action@v1-dev
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
timeout_minutes: "60"
|
||||
prompt: |
|
||||
Please provide a thorough review of this pull request.
|
||||
|
||||
|
||||
@@ -61,4 +61,3 @@ jobs:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
claude_args: |
|
||||
--allowedTools "mcp__github__get_issue,mcp__github__search_issues,mcp__github__list_issues,mcp__github__create_issue_comment,mcp__github__update_issue,mcp__github__get_issue_comments"
|
||||
timeout_minutes: "5"
|
||||
|
||||
@@ -73,4 +73,3 @@ jobs:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
claude_args: |
|
||||
--allowedTools "Bash(gh label list),mcp__github__get_issue,mcp__github__get_issue_comments,mcp__github__update_issue,mcp__github__search_issues,mcp__github__list_issues"
|
||||
timeout_minutes: "5"
|
||||
|
||||
Reference in New Issue
Block a user