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:
km-anthropic
2025-08-25 12:13:11 -07:00
committed by GitHub
parent 3c6f2209b6
commit 986e40a89c
18 changed files with 4 additions and 115 deletions

View File

@@ -102,7 +102,6 @@ jobs:
prompt_file: /tmp/claude-prompts/triage-prompt.txt 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" 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 mcp_config: /tmp/mcp-config/mcp-servers.json
timeout_minutes: "5"
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -25,7 +25,6 @@ jobs:
prompt: ${{ github.event.inputs.test_prompt || 'List the files in the current directory starting with "package"' }} prompt: ${{ github.event.inputs.test_prompt || 'List the files in the current directory starting with "package"' }}
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
allowed_tools: "LS,Read" allowed_tools: "LS,Read"
timeout_minutes: "3"
- name: Verify inline prompt output - name: Verify inline prompt output
run: | run: |
@@ -83,7 +82,6 @@ jobs:
prompt_file: "test-prompt.txt" prompt_file: "test-prompt.txt"
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
allowed_tools: "LS,Read" allowed_tools: "LS,Read"
timeout_minutes: "3"
- name: Verify prompt file output - name: Verify prompt file output
run: | run: |

View File

@@ -53,7 +53,6 @@ jobs:
path_to_claude_code_executable: /home/runner/.local/bin/claude path_to_claude_code_executable: /home/runner/.local/bin/claude
path_to_bun_executable: /home/runner/.bun/bin/bun path_to_bun_executable: /home/runner/.bun/bin/bun
allowed_tools: "LS,Read" allowed_tools: "LS,Read"
timeout_minutes: "3"
- name: Verify custom executables worked - name: Verify custom executables worked
run: | run: |

View File

@@ -26,7 +26,6 @@ jobs:
"allow": ["Bash(echo:*)"] "allow": ["Bash(echo:*)"]
} }
} }
timeout_minutes: "2"
- name: Verify echo worked - name: Verify echo worked
run: | run: |
@@ -76,7 +75,6 @@ jobs:
"deny": ["Bash(echo:*)"] "deny": ["Bash(echo:*)"]
} }
} }
timeout_minutes: "2"
- name: Verify echo was denied - name: Verify echo was denied
run: | run: |
@@ -114,7 +112,6 @@ jobs:
Use Bash to echo "Hello from settings file test" Use Bash to echo "Hello from settings file test"
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
settings: "test-settings.json" settings: "test-settings.json"
timeout_minutes: "2"
- name: Verify echo worked - name: Verify echo worked
run: | run: |
@@ -169,7 +166,6 @@ jobs:
Use Bash to echo "This should not work from file" Use Bash to echo "This should not work from file"
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
settings: "test-settings.json" settings: "test-settings.json"
timeout_minutes: "2"
- name: Verify echo was denied - name: Verify echo was denied
run: | run: |

View File

@@ -57,10 +57,6 @@ inputs:
required: false required: false
default: "false" default: "false"
timeout_minutes:
description: "Timeout in minutes for execution"
required: false
default: "30"
claude_args: claude_args:
description: "Additional arguments to pass directly to Claude CLI" description: "Additional arguments to pass directly to Claude CLI"
required: false required: false
@@ -197,7 +193,6 @@ runs:
CLAUDE_CODE_ACTION: "1" CLAUDE_CODE_ACTION: "1"
INPUT_PROMPT_FILE: ${{ runner.temp }}/claude-prompts/claude-prompt.txt INPUT_PROMPT_FILE: ${{ runner.temp }}/claude-prompts/claude-prompt.txt
INPUT_SETTINGS: ${{ inputs.settings }} INPUT_SETTINGS: ${{ inputs.settings }}
INPUT_TIMEOUT_MINUTES: ${{ inputs.timeout_minutes }}
INPUT_CLAUDE_ARGS: ${{ steps.prepare.outputs.claude_args }} INPUT_CLAUDE_ARGS: ${{ steps.prepare.outputs.claude_args }}
INPUT_EXPERIMENTAL_SLASH_COMMANDS_DIR: ${{ github.action_path }}/slash-commands INPUT_EXPERIMENTAL_SLASH_COMMANDS_DIR: ${{ github.action_path }}/slash-commands
INPUT_ACTION_INPUTS_PRESENT: ${{ steps.prepare.outputs.action_inputs_present }} INPUT_ACTION_INPUTS_PRESENT: ${{ steps.prepare.outputs.action_inputs_present }}

View File

@@ -20,10 +20,6 @@ inputs:
default: "" default: ""
# Action settings # Action settings
timeout_minutes:
description: "Timeout in minutes for Claude Code execution"
required: false
default: "10"
claude_args: claude_args:
description: "Additional arguments to pass directly to Claude CLI (e.g., '--max-turns 3 --mcp-config /path/to/config.json')" description: "Additional arguments to pass directly to Claude CLI (e.g., '--max-turns 3 --mcp-config /path/to/config.json')"
required: false required: false
@@ -130,7 +126,6 @@ runs:
INPUT_PROMPT: ${{ inputs.prompt }} INPUT_PROMPT: ${{ inputs.prompt }}
INPUT_PROMPT_FILE: ${{ inputs.prompt_file }} INPUT_PROMPT_FILE: ${{ inputs.prompt_file }}
INPUT_SETTINGS: ${{ inputs.settings }} INPUT_SETTINGS: ${{ inputs.settings }}
INPUT_TIMEOUT_MINUTES: ${{ inputs.timeout_minutes }}
INPUT_CLAUDE_ARGS: ${{ inputs.claude_args }} INPUT_CLAUDE_ARGS: ${{ inputs.claude_args }}
INPUT_EXPERIMENTAL_SLASH_COMMANDS_DIR: ${{ inputs.experimental_slash_commands_dir }} INPUT_EXPERIMENTAL_SLASH_COMMANDS_DIR: ${{ inputs.experimental_slash_commands_dir }}
INPUT_PATH_TO_CLAUDE_CODE_EXECUTABLE: ${{ inputs.path_to_claude_code_executable }} INPUT_PATH_TO_CLAUDE_CODE_EXECUTABLE: ${{ inputs.path_to_claude_code_executable }}

View File

@@ -104,5 +104,4 @@ jobs:
prompt_file: /tmp/claude-prompts/triage-prompt.txt 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" 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 mcp_config: /tmp/mcp-config/mcp-servers.json
timeout_minutes: "5"
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

View File

@@ -22,7 +22,6 @@ async function run() {
}); });
await runClaude(promptConfig.path, { await runClaude(promptConfig.path, {
timeoutMinutes: process.env.INPUT_TIMEOUT_MINUTES,
claudeArgs: process.env.INPUT_CLAUDE_ARGS, claudeArgs: process.env.INPUT_CLAUDE_ARGS,
allowedTools: process.env.INPUT_ALLOWED_TOOLS, allowedTools: process.env.INPUT_ALLOWED_TOOLS,
disallowedTools: process.env.INPUT_DISALLOWED_TOOLS, disallowedTools: process.env.INPUT_DISALLOWED_TOOLS,

View File

@@ -13,7 +13,6 @@ const EXECUTION_FILE = `${process.env.RUNNER_TEMP}/claude-execution-output.json`
const BASE_ARGS = ["--verbose", "--output-format", "stream-json"]; const BASE_ARGS = ["--verbose", "--output-format", "stream-json"];
export type ClaudeOptions = { export type ClaudeOptions = {
timeoutMinutes?: string;
claudeArgs?: string; claudeArgs?: string;
model?: string; model?: string;
pathToClaudeCodeExecutable?: string; pathToClaudeCodeExecutable?: string;
@@ -56,16 +55,6 @@ export function prepareRunConfig(
// BASE_ARGS are always appended last (cannot be overridden) // BASE_ARGS are always appended last (cannot be overridden)
claudeArgs.push(...BASE_ARGS); 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> = {}; const customEnv: Record<string, string> = {};
if (process.env.INPUT_ACTION_INPUTS_PRESENT) { if (process.env.INPUT_ACTION_INPUTS_PRESENT) {
@@ -194,57 +183,15 @@ export async function runClaude(promptPath: string, options: ClaudeOptions) {
claudeProcess.kill("SIGTERM"); claudeProcess.kill("SIGTERM");
}); });
// Wait for Claude to finish with timeout // Wait for Claude to finish
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;
}
const exitCode = await new Promise<number>((resolve) => { 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) => { claudeProcess.on("close", (code) => {
if (!resolved) { resolve(code || 0);
clearTimeout(timeoutId);
resolved = true;
resolve(code || 0);
}
}); });
claudeProcess.on("error", (error) => { claudeProcess.on("error", (error) => {
if (!resolved) { console.error("Claude process error:", error);
console.error("Claude process error:", error); resolve(1);
clearTimeout(timeoutId);
resolved = true;
resolve(1);
}
}); });
}); });

View File

@@ -30,36 +30,6 @@ describe("prepareRunConfig", () => {
expect(prepared.promptPath).toBe("/custom/prompt/path.txt"); 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", () => { describe("claudeArgs handling", () => {
test("should parse and include custom claude arguments", () => { test("should parse and include custom claude arguments", () => {
const options: ClaudeOptions = { const options: ClaudeOptions = {

View File

@@ -93,6 +93,5 @@ jobs:
Error logs: Error logs:
${{ toJSON(fromJSON(steps.failure_details.outputs.result).errorLogs) }} ${{ toJSON(fromJSON(steps.failure_details.outputs.result).errorLogs) }}
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
timeout_minutes: "30"
use_commit_signing: true 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'" 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'"

View File

@@ -94,5 +94,4 @@ jobs:
Error logs: Error logs:
${{ toJSON(fromJSON(steps.failure_details.outputs.result).errorLogs) }} ${{ toJSON(fromJSON(steps.failure_details.outputs.result).errorLogs) }}
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} 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:*)'" claude_args: "--allowedTools 'Edit,MultiEdit,Write,Read,Glob,Grep,LS,Bash(git:*),Bash(bun:*),Bash(npm:*),Bash(npx:*),Bash(gh:*)'"

View File

@@ -21,7 +21,6 @@ jobs:
uses: anthropics/claude-code-action@v1-dev uses: anthropics/claude-code-action@v1-dev
with: with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
timeout_minutes: "60"
prompt: | prompt: |
Please review this pull request and provide comprehensive feedback. Please review this pull request and provide comprehensive feedback.

View File

@@ -31,7 +31,6 @@ jobs:
with: with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
# github_token not needed - uses default GITHUB_TOKEN for GitHub operations # github_token not needed - uses default GITHUB_TOKEN for GitHub operations
timeout_minutes: "30"
prompt: | prompt: |
Review this pull request comprehensively. Review this pull request comprehensively.

View File

@@ -27,7 +27,6 @@ jobs:
uses: anthropics/claude-code-action@v1-dev uses: anthropics/claude-code-action@v1-dev
with: with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
timeout_minutes: "60"
prompt: | prompt: |
Please review this pull request focusing on the changed files. Please review this pull request focusing on the changed files.
Provide feedback on: Provide feedback on:

View File

@@ -26,7 +26,6 @@ jobs:
uses: anthropics/claude-code-action@v1-dev uses: anthropics/claude-code-action@v1-dev
with: with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
timeout_minutes: "60"
prompt: | prompt: |
Please provide a thorough review of this pull request. Please provide a thorough review of this pull request.

View File

@@ -61,4 +61,3 @@ jobs:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
claude_args: | 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" --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"

View File

@@ -73,4 +73,3 @@ jobs:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
claude_args: | 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" --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"