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