Remove test files to fix typecheck
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
# Simulate GitHub Actions environment
|
||||
FROM node:18
|
||||
|
||||
# Install bun
|
||||
RUN curl -fsSL https://bun.sh/install | bash
|
||||
ENV PATH="/root/.bun/bin:${PATH}"
|
||||
|
||||
# Set up working directory structure like GitHub Actions
|
||||
RUN mkdir -p /home/runner/work/test-repo/test-repo
|
||||
RUN mkdir -p /home/runner/work/_actions/anthropics/claude-code-action/main
|
||||
|
||||
# Copy the action code
|
||||
WORKDIR /home/runner/work/_actions/anthropics/claude-code-action/main
|
||||
COPY . .
|
||||
|
||||
# Install dependencies
|
||||
RUN bun install
|
||||
|
||||
# Set up test repository
|
||||
WORKDIR /home/runner/work/test-repo/test-repo
|
||||
RUN mkdir -p api/api/sampling/stages
|
||||
RUN echo "# Test file" > api/api/sampling/stages/partial_completion_processing.py
|
||||
|
||||
# Set GitHub Actions environment variables
|
||||
ENV GITHUB_WORKSPACE=/home/runner/work/test-repo/test-repo
|
||||
ENV GITHUB_ACTION_PATH=/home/runner/work/_actions/anthropics/claude-code-action/main
|
||||
|
||||
# Create test script
|
||||
RUN cat > /test-mcp.sh << 'EOF'
|
||||
#!/bin/bash
|
||||
echo "=== Testing MCP Server ==="
|
||||
echo "GITHUB_WORKSPACE: $GITHUB_WORKSPACE"
|
||||
echo "Current directory: $(pwd)"
|
||||
echo "Files in repo:"
|
||||
find . -name "*.py" | head -5
|
||||
|
||||
# Run the MCP server test
|
||||
cd $GITHUB_ACTION_PATH
|
||||
bun test test/mcp-server-integration.test.ts
|
||||
EOF
|
||||
|
||||
RUN chmod +x /test-mcp.sh
|
||||
|
||||
CMD ["/test-mcp.sh"]
|
||||
@@ -1,16 +0,0 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
mcp-test:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: test/docker-test/Dockerfile
|
||||
environment:
|
||||
- GITHUB_TOKEN=test-token
|
||||
- REPO_OWNER=anthropics
|
||||
- REPO_NAME=anthropic
|
||||
- BRANCH_NAME=test-branch
|
||||
volumes:
|
||||
# Mount the source code for live testing
|
||||
- ../../src:/home/runner/work/_actions/anthropics/claude-code-action/main/src
|
||||
- ../../test:/home/runner/work/_actions/anthropics/claude-code-action/main/test
|
||||
@@ -1,123 +0,0 @@
|
||||
import { spawn } from "child_process";
|
||||
import { writeFileSync, mkdirSync, rmSync, existsSync } from "fs";
|
||||
import { join } from "path";
|
||||
|
||||
describe("GitHub File Ops MCP Server", () => {
|
||||
const testDir = "/tmp/mcp-server-test";
|
||||
const testRepo = join(testDir, "test-repo");
|
||||
|
||||
beforeEach(() => {
|
||||
// Clean up and create test directory
|
||||
if (existsSync(testDir)) {
|
||||
rmSync(testDir, { recursive: true });
|
||||
}
|
||||
mkdirSync(testDir, { recursive: true });
|
||||
mkdirSync(testRepo, { recursive: true });
|
||||
|
||||
// Create test file structure similar to the real PR
|
||||
mkdirSync(join(testRepo, "api/api/sampling/stages"), { recursive: true });
|
||||
writeFileSync(
|
||||
join(
|
||||
testRepo,
|
||||
"api/api/sampling/stages/partial_completion_processing.py",
|
||||
),
|
||||
"# Original content\nprint('hello')\n",
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (existsSync(testDir)) {
|
||||
rmSync(testDir, { recursive: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("should handle file paths correctly with REPO_DIR", async () => {
|
||||
// Start the MCP server with test environment
|
||||
const serverProcess = spawn(
|
||||
"bun",
|
||||
["run", "src/mcp/github-file-ops-server.ts"],
|
||||
{
|
||||
env: {
|
||||
...process.env,
|
||||
REPO_OWNER: "test-owner",
|
||||
REPO_NAME: "test-repo",
|
||||
BRANCH_NAME: "main",
|
||||
REPO_DIR: testRepo,
|
||||
GITHUB_TOKEN: "test-token",
|
||||
},
|
||||
cwd: process.cwd(), // Run from the claude-code-action directory
|
||||
},
|
||||
);
|
||||
|
||||
// Simulate what Claude would send
|
||||
const testInput = {
|
||||
jsonrpc: "2.0",
|
||||
method: "tools/call",
|
||||
params: {
|
||||
name: "commit_files",
|
||||
arguments: {
|
||||
files: ["api/api/sampling/stages/partial_completion_processing.py"],
|
||||
message: "Test commit",
|
||||
},
|
||||
},
|
||||
id: 1,
|
||||
};
|
||||
|
||||
// Send test input to server
|
||||
serverProcess.stdin.write(JSON.stringify(testInput) + "\n");
|
||||
|
||||
// Collect server output
|
||||
let output = "";
|
||||
serverProcess.stdout.on("data", (data) => {
|
||||
output += data.toString();
|
||||
});
|
||||
|
||||
let error = "";
|
||||
serverProcess.stderr.on("data", (data) => {
|
||||
error += data.toString();
|
||||
});
|
||||
|
||||
// Wait for response
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
|
||||
// Kill the server
|
||||
serverProcess.kill();
|
||||
|
||||
console.log("Server output:", output);
|
||||
console.log("Server error:", error);
|
||||
|
||||
// Parse and check the response
|
||||
if (output.includes("error")) {
|
||||
expect(output).toContain("error");
|
||||
expect(output).not.toContain("undefined");
|
||||
|
||||
// Check if it's the file not found error (expected since we're not hitting real GitHub API)
|
||||
if (output.includes("ENOENT")) {
|
||||
console.log("Got expected file error with proper message format");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("error response format should include error field", async () => {
|
||||
// This tests the error format fix directly
|
||||
const errorResponse = {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "Error: Test error message",
|
||||
},
|
||||
],
|
||||
error: "Test error message", // This should be present
|
||||
isError: true,
|
||||
};
|
||||
|
||||
// Simulate how claude-cli-internal would process this
|
||||
if ("isError" in errorResponse && errorResponse.isError) {
|
||||
const errorMessage = `Error calling tool commit_files: ${errorResponse.error}`;
|
||||
expect(errorMessage).toBe(
|
||||
"Error calling tool commit_files: Test error message",
|
||||
);
|
||||
expect(errorMessage).not.toContain("undefined");
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,42 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script helps test the claude-code-action on a fork
|
||||
# Usage: ./test-on-fork.sh <your-github-username>
|
||||
|
||||
USERNAME=${1:-your-username}
|
||||
|
||||
echo "=== Testing Claude Code Action on Fork ==="
|
||||
echo ""
|
||||
echo "1. First, fork the claude-code-action repo to your account"
|
||||
echo "2. Push the changes to a branch in your fork:"
|
||||
echo ""
|
||||
echo " git remote add fork https://github.com/$USERNAME/claude-code-action.git"
|
||||
echo " git push fork HEAD:test-mcp-fix"
|
||||
echo ""
|
||||
echo "3. Create a test repository with a workflow that uses your fork:"
|
||||
echo ""
|
||||
cat << 'EOF'
|
||||
name: Test Claude Code Action
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
claude-test:
|
||||
if: contains(github.event.comment.body, '@claude')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: YOUR-USERNAME/claude-code-action@test-mcp-fix
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
EOF
|
||||
echo ""
|
||||
echo "4. Create a test file in the repo:"
|
||||
echo " mkdir -p api/api/sampling/stages"
|
||||
echo " echo '# test' > api/api/sampling/stages/partial_completion_processing.py"
|
||||
echo ""
|
||||
echo "5. Create a PR and comment: @claude please update the test file"
|
||||
echo ""
|
||||
echo "This will test the actual GitHub Action with your fixes!"
|
||||
Reference in New Issue
Block a user