From 308512548e1b3c546a194af120901788a1346023 Mon Sep 17 00:00:00 2001 From: claude Date: Tue, 29 Jul 2025 22:41:27 +0000 Subject: [PATCH] Add comprehensive logging to debug slow job completion - Add timestamps to prepare.ts completion - Add timestamps and signal handlers to both MCP servers - Add start/end logging to update-comment-link.ts - Add final action completion logging step - Log when composite action steps complete vs job cleanup --- action.yml | 20 ++++++++++++++++++++ src/entrypoints/prepare.ts | 3 +++ src/entrypoints/update-comment-link.ts | 3 +++ src/mcp/gitea-mcp-server.ts | 15 +++++++++++++-- src/mcp/local-git-ops-server.ts | 15 +++++++++++++-- 5 files changed, 52 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index ca6eae4..e8c8e78 100644 --- a/action.yml +++ b/action.yml @@ -111,6 +111,12 @@ runs: ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key != 'use-oauth' && inputs.anthropic_api_key || '' }} CLAUDE_CREDENTIALS: ${{ inputs.claude_credentials }} + - name: Log before Claude Code + if: steps.prepare.outputs.contains_trigger == 'true' + shell: bash + run: | + echo "[$(date -u +%Y-%m-%dT%H:%M:%S.%3NZ)] Starting Claude Code base action..." + - name: Run Claude Code id: claude-code if: steps.prepare.outputs.contains_trigger == 'true' @@ -165,6 +171,13 @@ runs: VERTEX_REGION_CLAUDE_3_5_SONNET: ${{ env.VERTEX_REGION_CLAUDE_3_5_SONNET }} VERTEX_REGION_CLAUDE_3_7_SONNET: ${{ env.VERTEX_REGION_CLAUDE_3_7_SONNET }} + - name: Log after Claude Code + if: steps.prepare.outputs.contains_trigger == 'true' && always() + shell: bash + run: | + echo "[$(date -u +%Y-%m-%dT%H:%M:%S.%3NZ)] Claude Code base action completed with status: ${{ steps.claude-code.outcome }}" + echo "[$(date -u +%Y-%m-%dT%H:%M:%S.%3NZ)] Starting comment update..." + - name: Update comment with job link if: steps.prepare.outputs.contains_trigger == 'true' && steps.prepare.outputs.claude_comment_id && always() shell: bash @@ -200,3 +213,10 @@ runs: else echo "⚠️ Claude Code execution completed but no report file was generated" >> $GITHUB_STEP_SUMMARY fi + + - name: Log action completion + if: always() + shell: bash + run: | + echo "[$(date -u +%Y-%m-%dT%H:%M:%S.%3NZ)] Claude Code Action composite steps completed" + echo "[$(date -u +%Y-%m-%dT%H:%M:%S.%3NZ)] Waiting for job cleanup..." diff --git a/src/entrypoints/prepare.ts b/src/entrypoints/prepare.ts index 280ae7c..061df53 100644 --- a/src/entrypoints/prepare.ts +++ b/src/entrypoints/prepare.ts @@ -121,11 +121,14 @@ async function run() { branchInfo.currentBranch, ); core.setOutput("mcp_config", mcpConfig); + + console.log(`[${new Date().toISOString()}] Prepare step completed successfully`); } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); core.setFailed(`Prepare step failed with error: ${errorMessage}`); // Also output the clean error message for the action to capture core.setOutput("prepare_error", errorMessage); + console.log(`[${new Date().toISOString()}] Prepare step failed with error: ${errorMessage}`); process.exit(1); } } diff --git a/src/entrypoints/update-comment-link.ts b/src/entrypoints/update-comment-link.ts index 1121204..2c323dc 100644 --- a/src/entrypoints/update-comment-link.ts +++ b/src/entrypoints/update-comment-link.ts @@ -358,11 +358,14 @@ async function run() { throw updateError; } + console.log(`[${new Date().toISOString()}] Update comment completed successfully`); process.exit(0); } catch (error) { console.error("Error updating comment with job link:", error); + console.log(`[${new Date().toISOString()}] Update comment failed`); process.exit(1); } } +console.log(`[${new Date().toISOString()}] Starting update-comment-link.ts`); run(); diff --git a/src/mcp/gitea-mcp-server.ts b/src/mcp/gitea-mcp-server.ts index 5a60f4a..a9d4042 100644 --- a/src/mcp/gitea-mcp-server.ts +++ b/src/mcp/gitea-mcp-server.ts @@ -12,7 +12,7 @@ const BRANCH_NAME = process.env.BRANCH_NAME; const GITHUB_TOKEN = process.env.GITHUB_TOKEN; const GITEA_API_URL = process.env.GITEA_API_URL || "https://api.github.com"; -console.log(`[GITEA-MCP] Starting Gitea API Operations MCP Server`); +console.log(`[GITEA-MCP ${new Date().toISOString()}] Starting Gitea API Operations MCP Server`); console.log(`[GITEA-MCP] REPO_OWNER: ${REPO_OWNER}`); console.log(`[GITEA-MCP] REPO_NAME: ${REPO_NAME}`); console.log(`[GITEA-MCP] BRANCH_NAME: ${BRANCH_NAME}`); @@ -1268,9 +1268,20 @@ async function runServer() { await server.connect(transport); console.log(`[GITEA-MCP] Gitea MCP server connected and ready!`); process.on("exit", () => { - console.log(`[GITEA-MCP] Server shutting down...`); + console.log(`[GITEA-MCP ${new Date().toISOString()}] Server shutting down...`); server.close(); }); + + // Add more signal handlers for debugging + process.on("SIGTERM", () => { + console.log(`[GITEA-MCP ${new Date().toISOString()}] Received SIGTERM signal`); + process.exit(0); + }); + + process.on("SIGINT", () => { + console.log(`[GITEA-MCP ${new Date().toISOString()}] Received SIGINT signal`); + process.exit(0); + }); } console.log(`[GITEA-MCP] Calling runServer()...`); diff --git a/src/mcp/local-git-ops-server.ts b/src/mcp/local-git-ops-server.ts index 4373379..c797017 100644 --- a/src/mcp/local-git-ops-server.ts +++ b/src/mcp/local-git-ops-server.ts @@ -15,7 +15,7 @@ const REPO_DIR = process.env.REPO_DIR || process.cwd(); const GITHUB_TOKEN = process.env.GITHUB_TOKEN; const GITEA_API_URL = process.env.GITEA_API_URL || "https://api.github.com"; -console.log(`[LOCAL-GIT-MCP] Starting Local Git Operations MCP Server`); +console.log(`[LOCAL-GIT-MCP ${new Date().toISOString()}] Starting Local Git Operations MCP Server`); console.log(`[LOCAL-GIT-MCP] REPO_OWNER: ${REPO_OWNER}`); console.log(`[LOCAL-GIT-MCP] REPO_NAME: ${REPO_NAME}`); console.log(`[LOCAL-GIT-MCP] BRANCH_NAME: ${BRANCH_NAME}`); @@ -497,9 +497,20 @@ async function runServer() { await server.connect(transport); console.log(`[LOCAL-GIT-MCP] MCP server connected and ready!`); process.on("exit", () => { - console.log(`[LOCAL-GIT-MCP] Server shutting down...`); + console.log(`[LOCAL-GIT-MCP ${new Date().toISOString()}] Server shutting down...`); server.close(); }); + + // Add more signal handlers for debugging + process.on("SIGTERM", () => { + console.log(`[LOCAL-GIT-MCP ${new Date().toISOString()}] Received SIGTERM signal`); + process.exit(0); + }); + + process.on("SIGINT", () => { + console.log(`[LOCAL-GIT-MCP ${new Date().toISOString()}] Received SIGINT signal`); + process.exit(0); + }); } console.log(`[LOCAL-GIT-MCP] Calling runServer()...`);