|
| 1 | +# GitHub Issue Auto Debug Script Usage Guide |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +`prometheus/script/github_issue_debug.py` is an automated script for: |
| 6 | +1. Retrieving detailed information (title, body, comments, etc.) of a specified issue from the GitHub API. |
| 7 | +2. Automatically uploading the GitHub repository to Prometheus. |
| 8 | +3. Using Prometheus's AI analysis capabilities to debug the issue. |
| 9 | +4. Returning analysis results, fix patches, etc. |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | + |
| 13 | +### 1. Start Prometheus Service |
| 14 | +Ensure the Prometheus service is running: |
| 15 | +```bash |
| 16 | +# Start using docker-compose |
| 17 | +docker-compose up --build |
| 18 | +``` |
| 19 | + |
| 20 | +### 2. Obtain GitHub Personal Access Token |
| 21 | +1. Visit https://github.com/settings/tokens |
| 22 | +2. Click "Generate new token (classic)" |
| 23 | +3. Select the appropriate permission scope: |
| 24 | + - `repo` (access private repositories) |
| 25 | + - `public_repo` (access public repositories) |
| 26 | +4. Generate and save the token. |
| 27 | + |
| 28 | +### 3. Install Python Dependencies |
| 29 | +```bash |
| 30 | +pip install requests |
| 31 | +``` |
| 32 | + |
| 33 | +## Basic Usage |
| 34 | + |
| 35 | +### Simple Example |
| 36 | +```bash |
| 37 | +python github_issue_debug.py \ |
| 38 | + --github-token "your_token_here" \ |
| 39 | + --repo "owner/repository" \ |
| 40 | + --issue-number 42 |
| 41 | +``` |
| 42 | + |
| 43 | +### Full Parameter Example |
| 44 | +```bash |
| 45 | +python github_issue_debug.py \ |
| 46 | + --github-token "ghp_xxxxxxxxxxxxxxxxxxxx" \ |
| 47 | + --repo "microsoft/vscode" \ |
| 48 | + --issue-number 123 \ |
| 49 | + --prometheus-url "http://localhost:9002/v1.2" \ |
| 50 | + --output-file "debug_result.json" \ |
| 51 | + --run-build \ |
| 52 | + --run-test \ |
| 53 | + --run-reproduction-test \ |
| 54 | + --run-regression-test \ |
| 55 | + --push-to-remote \ |
| 56 | + --image-name "python:3.11-slim" \ |
| 57 | + --workdir "/app" \ |
| 58 | + --build-commands "pip install -r requirements.txt" "python setup.py build" \ |
| 59 | + --test-commands "pytest tests/" \ |
| 60 | + --candidate-patches 3 |
| 61 | +``` |
| 62 | + |
| 63 | +## Parameter Details |
| 64 | + |
| 65 | +### Required Parameters |
| 66 | +- `--github-token`: GitHub Personal Access Token |
| 67 | +- `--repo`: GitHub repository name in the format `owner/repo` |
| 68 | +- `--issue-number`: Issue number to process |
| 69 | + |
| 70 | +### Optional Parameters |
| 71 | +- `--prometheus-url`: Prometheus service address (default: http://localhost:8000) |
| 72 | +- `--output-file`: Path to the result output file (if not specified, output to console) |
| 73 | + |
| 74 | +### Validation Options |
| 75 | +- `--run-build`: Run build validation for the generated patch |
| 76 | +- `--run-test`: Run test validation for the generated patch |
| 77 | +- `--run-reproduction-test`: Run reproduction test to verify if the issue can be reproduced |
| 78 | +- `--run-regression-test`: Run regression test to ensure existing functionality is not broken |
| 79 | +- `--push-to-remote`: Push the fix to a remote Git branch |
| 80 | + |
| 81 | +### Docker Environment Configuration |
| 82 | +- `--dockerfile-content`: Specify Dockerfile content directly |
| 83 | +- `--image-name`: Use a predefined Docker image |
| 84 | +- `--workdir`: Working directory inside the container (default: /app) |
| 85 | +- `--build-commands`: List of build commands |
| 86 | +- `--test-commands`: List of test commands |
| 87 | + |
| 88 | +### Other Options |
| 89 | +- `--candidate-patches`: Number of candidate patches (default: 6) |
| 90 | + |
| 91 | +## Usage Scenarios |
| 92 | + |
| 93 | +### Scenario 1: Simple Bug Report Analysis |
| 94 | +```bash |
| 95 | +# Analyze a simple bug report without running any validation |
| 96 | +python github_issue_debug.py \ |
| 97 | + --github-token "your_token" \ |
| 98 | + --repo "pytorch/pytorch" \ |
| 99 | + --issue-number 89123 |
| 100 | +``` |
| 101 | + |
| 102 | +### Scenario 2: Python Project with Test Validation |
| 103 | +```bash |
| 104 | +# Perform a complete debug for a Python project, including build and test validation |
| 105 | +python github_issue_debug.py \ |
| 106 | + --github-token "your_token" \ |
| 107 | + --repo "requests/requests" \ |
| 108 | + --issue-number 5678 \ |
| 109 | + --run-build \ |
| 110 | + --run-test \ |
| 111 | + --run-reproduction-test \ |
| 112 | + --run-regression-test \ |
| 113 | + --image-name "python:3.11-slim" \ |
| 114 | + --build-commands "pip install -e ." \ |
| 115 | + --test-commands "pytest tests/test_requests.py" |
| 116 | +``` |
| 117 | + |
| 118 | +### Scenario 3: Node.js Project with Auto Push |
| 119 | +```bash |
| 120 | +# Process an issue for a Node.js project and automatically push the fix to a remote branch |
| 121 | +python github_issue_debug.py \ |
| 122 | + --github-token "your_token" \ |
| 123 | + --repo "facebook/react" \ |
| 124 | + --issue-number 9876 \ |
| 125 | + --run-build \ |
| 126 | + --run-test \ |
| 127 | + --run-reproduction-test \ |
| 128 | + --run-regression-test \ |
| 129 | + --push-to-remote \ |
| 130 | + --image-name "node:18-slim" \ |
| 131 | + --build-commands "npm ci" "npm run build" \ |
| 132 | + --test-commands "npm test" |
| 133 | +``` |
| 134 | + |
| 135 | +### Scenario 4: Custom Docker Environment |
| 136 | +```bash |
| 137 | +# Use a custom Dockerfile for debugging |
| 138 | +python github_issue_debug.py \ |
| 139 | + --github-token "your_token" \ |
| 140 | + --repo "tensorflow/tensorflow" \ |
| 141 | + --issue-number 4321 \ |
| 142 | + --run-build \ |
| 143 | + --dockerfile-content "FROM tensorflow/tensorflow:latest-gpu |
| 144 | +WORKDIR /app |
| 145 | +COPY . /app |
| 146 | +RUN pip install -r requirements.txt" \ |
| 147 | + --workdir "/app" \ |
| 148 | + --build-commands "python setup.py build_ext --inplace" \ |
| 149 | + --test-commands "python -m pytest tests/unit/" |
| 150 | +``` |
| 151 | + |
| 152 | +## Output Result Explanation |
| 153 | + |
| 154 | +After execution, the script outputs results in JSON format, including the following fields: |
| 155 | + |
| 156 | +```json |
| 157 | +{ |
| 158 | + "success": true, |
| 159 | + "issue_info": { |
| 160 | + "repo": "owner/repo", |
| 161 | + "number": 123, |
| 162 | + "title": "Issue Title", |
| 163 | + "url": "https://github.com/owner/repo/issues/123", |
| 164 | + "state": "open" |
| 165 | + }, |
| 166 | + "prometheus_result": { |
| 167 | + "patch": "Generated code patch", |
| 168 | + "passed_reproducing_test": true, |
| 169 | + "passed_build": true, |
| 170 | + "passed_existing_test": false, |
| 171 | + "passed_regression_test": true, |
| 172 | + "passed_reproduction_test": true, |
| 173 | + "issue_response": "AI-generated issue response" |
| 174 | + }, |
| 175 | + "created_branch_and_pushed": true, |
| 176 | + "branch_name": "fix-issue-123" |
| 177 | +} |
| 178 | +``` |
| 179 | + |
| 180 | +### Result Field Description |
| 181 | +- `success`: Whether the process was successful |
| 182 | +- `issue_info`: Basic information about the GitHub issue |
| 183 | +- `prometheus_result.patch`: Code fix patch generated by Prometheus |
| 184 | +- `prometheus_result.passed_*`: Status of various validations |
| 185 | +- `prometheus_result.issue_response`: AI-generated issue analysis and response |
0 commit comments