From 18015aa3cac40e7aae11fcec308bd7f96a1c5daf Mon Sep 17 00:00:00 2001 From: claude Date: Thu, 31 Jul 2025 13:56:44 +0000 Subject: [PATCH] more twesks for perf --- action.yml | 14 ++++++++------ src/entrypoints/prepare.ts | 21 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index 8b215cb..e4c54cf 100644 --- a/action.yml +++ b/action.yml @@ -80,11 +80,13 @@ outputs: runs: using: "composite" steps: - - name: Install Bun - uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # https://github.com/oven-sh/setup-bun/releases/tag/v2.0.2 - with: - bun-version: 1.2.11 - cache: false + - name: Verify Bun Installation + shell: bash + run: | + # Bun is pre-installed in the Docker image + echo "Using pre-installed Bun:" + which bun || (echo "ERROR: Bun not found!" && exit 1) + bun --version - name: Install Dependencies shell: bash @@ -121,7 +123,7 @@ runs: - name: Run Claude Code id: claude-code if: steps.prepare.outputs.contains_trigger == 'true' - uses: anthropics/claude-code-base-action@v0.0.48 + uses: anthropics/claude-code-base-action@beta with: prompt_file: /tmp/claude-prompts/claude-prompt.txt allowed_tools: ${{ env.ALLOWED_TOOLS }} diff --git a/src/entrypoints/prepare.ts b/src/entrypoints/prepare.ts index d7ad271..8726bc1 100644 --- a/src/entrypoints/prepare.ts +++ b/src/entrypoints/prepare.ts @@ -21,8 +21,12 @@ import { parseGitHubContext } from "../github/context"; import { setupOAuthCredentials } from "../claude/oauth-setup"; async function run() { + const startTime = Date.now(); + console.log(`[${new Date().toISOString()}] Starting prepare step...`); + try { // Step 1: Setup OAuth credentials if provided + console.log(`[${new Date().toISOString()}] Step 1: Checking OAuth credentials...`); const claudeCredentials = process.env.CLAUDE_CREDENTIALS; const anthropicApiKey = process.env.ANTHROPIC_API_KEY; @@ -51,13 +55,16 @@ async function run() { } // Step 2: Setup GitHub token + console.log(`[${new Date().toISOString()}] Step 2: Setting up GitHub token...`); const githubToken = await setupGitHubToken(); const client = createClient(githubToken); // Step 3: Parse GitHub context (once for all operations) + console.log(`[${new Date().toISOString()}] Step 3: Parsing GitHub context...`); const context = parseGitHubContext(); // Step 4: Check write permissions + console.log(`[${new Date().toISOString()}] Step 4: Checking write permissions...`); const hasWritePermissions = await checkWritePermissions( client.api, context, @@ -69,6 +76,7 @@ async function run() { } // Step 5: Check trigger conditions + console.log(`[${new Date().toISOString()}] Step 5: Checking trigger conditions...`); const containsTrigger = await checkTriggerAction(context); // Set outputs that are always needed @@ -81,13 +89,17 @@ async function run() { } // Step 6: Check if actor is human + console.log(`[${new Date().toISOString()}] Step 6: Checking if actor is human...`); await checkHumanActor(client.api, context); // Step 7: Create initial tracking comment + console.log(`[${new Date().toISOString()}] Step 7: Creating initial tracking comment...`); const commentId = await createInitialComment(client.api, context); core.setOutput("claude_comment_id", commentId.toString()); + console.log(`[${new Date().toISOString()}] Created comment with ID: ${commentId}`); // Step 8: Fetch GitHub data (once for both branch setup and prompt creation) + console.log(`[${new Date().toISOString()}] Step 8: Fetching GitHub data...`); const githubData = await fetchGitHubData({ client: client, repository: `${context.repository.owner}/${context.repository.repo}`, @@ -96,6 +108,7 @@ async function run() { }); // Step 9: Setup branch + console.log(`[${new Date().toISOString()}] Step 9: Setting up branch...`); const branchInfo = await setupBranch(client, githubData, context); core.setOutput("BASE_BRANCH", branchInfo.baseBranch); if (branchInfo.claudeBranch) { @@ -104,6 +117,7 @@ async function run() { // Step 10: Update initial comment with branch link (only if a claude branch was created) if (branchInfo.claudeBranch) { + console.log(`[${new Date().toISOString()}] Step 10: Updating comment with branch link...`); await updateTrackingComment( client, context, @@ -113,6 +127,7 @@ async function run() { } // Step 11: Create prompt file + console.log(`[${new Date().toISOString()}] Step 11: Creating prompt file...`); await createPrompt( commentId, branchInfo.baseBranch, @@ -122,6 +137,8 @@ async function run() { ); // Step 12: Get MCP configuration + console.log(`[${new Date().toISOString()}] Step 12: Preparing MCP configuration...`); + const mcpStartTime = Date.now(); const mcpConfig = await prepareMcpConfig( githubToken, context.repository.owner, @@ -129,8 +146,10 @@ async function run() { branchInfo.currentBranch, ); core.setOutput("mcp_config", mcpConfig); + console.log(`[${new Date().toISOString()}] MCP configuration completed in ${Date.now() - mcpStartTime}ms`); - console.log(`[${new Date().toISOString()}] Prepare step completed successfully`); + const totalTime = Date.now() - startTime; + console.log(`[${new Date().toISOString()}] Prepare step completed successfully in ${totalTime}ms`); } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); core.setFailed(`Prepare step failed with error: ${errorMessage}`);