Skip to content

Commit 8647f8b

Browse files
committed
Merge branch 'main' of github.com:tensorzero/experimental-ci-bot into viraj/test-agent
2 parents 14ff8b5 + a89ae7b commit 8647f8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+84734
-16496
lines changed

.github/workflows/ci-failure-diagnosis.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ on:
66
types:
77
- completed
88

9-
# Workflow-level permissions (needed for Tailscale action to work)
10-
permissions:
11-
contents: write
12-
pull-requests: write
13-
actions: read
14-
159
jobs:
1610
generate-patch:
1711
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
@@ -49,14 +43,13 @@ jobs:
4943

5044
- name: Generate patch
5145
id: generate
52-
uses: tensorzero/experimental-ci-bot/generate-pr-patch@viraj/pr-only
46+
uses: tensorzero/experimental-ci-bot/generate-pr-patch@main
5347
env:
5448
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5549
with:
5650
token: ${{ secrets.GITHUB_TOKEN }}
5751
mode: patch-only
5852
tensorzero-base-url: http://localhost:3000
59-
tensorzero-diff-patched-successfully-metric-name: tensorzero_github_ci_bot_diff_patched_successfully
6053
output-artifacts-dir: debug-logs
6154
clickhouse-url: ${{ secrets.CI_BOT_CLICKHOUSE_URL }}
6255
clickhouse-table: GitHubBotPullRequestToInferenceMap

.github/workflows/provide-pull-request-feedback.yml

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,19 @@ jobs:
1414
runs-on: ubuntu-latest
1515
name: Create PR Feedback
1616
steps:
17-
- name: Checkout TensorZero config file
18-
uses: actions/checkout@v5
17+
- name: Connect to Tailscale
18+
uses: tailscale/github-action@v4
1919
with:
20-
repository: tensorzero/experimental-ci-bot
21-
sparse-checkout: |
22-
tensorzero
23-
24-
- name: Start TensorZero gateway
25-
run: |
26-
docker pull tensorzero/gateway:latest
27-
docker run -d --rm \
28-
--name tensorzero-gateway \
29-
-e TENSORZERO_CLICKHOUSE_URL=${{ secrets.CI_BOT_CLICKHOUSE_URL }} \
30-
-e OPENAI_API_KEY=${{ secrets.CI_BOT_OPENAI_API_KEY }} \
31-
-p 3000:3000 \
32-
--volume ./tensorzero:/action-config \
33-
tensorzero/gateway:latest --config-file /action-config/tensorzero.toml
34-
35-
for _i in {1..100}; do
36-
curl -fsS http://localhost:3000/health && exit 0
37-
sleep 3
38-
done
39-
echo "Gateway never became ready" >&2
40-
exit 1
20+
oauth-client-id: ${{ secrets.CI_BOT_TS_OAUTH_CLIENT_ID }}
21+
oauth-secret: ${{ secrets.CI_BOT_TS_OAUTH_CLIENT_SECRET }}
22+
tags: tag:ci
4123

4224
- name: Send PR Feedback
4325
# TODO: currently pinned to miniswe-agent branch; switch back to main when ready.
44-
uses: tensorzero/experimental-ci-bot/create-pr-feedback@viraj/pr-only
26+
uses: tensorzero/experimental-ci-bot/create-pr-feedback@main
4527
with:
46-
tensorzero-base-url: http://localhost:3000
28+
tensorzero-base-url: http://ci-bot-gateway:3000
4729
# TODO: Switch to tensorzero_github_ci_bot_agent_pr_merged for episode-level feedback when agent creates PRs
48-
tensorzero-pr-merged-metric-name: tensorzero_github_ci_bot_pr_merged
30+
tensorzero-pr-merged-metric-name: ci_fix_pr_merged_agent
4931
clickhouse-url: ${{ secrets.CI_BOT_CLICKHOUSE_URL }}
5032
clickhouse-table: GitHubBotPullRequestToInferenceMap
51-
52-
- name: Stop TensorZero gateway
53-
if: always()
54-
run: docker stop tensorzero-gateway
55-
continue-on-error: true

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Dependency directory
22
node_modules
33

4+
45
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
56
# Logs
67
logs
@@ -100,3 +101,14 @@ __tests__/runner/*
100101
# IDE files
101102
.idea
102103
*.code-workspace
104+
105+
# Python
106+
.venv
107+
venv
108+
env
109+
__pycache__
110+
*.py[cod]
111+
*$py.class
112+
*.so
113+
.Python
114+
.envrc

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,10 @@
33
dist/
44
node_modules/
55
coverage/
6+
7+
# Python
8+
.venv/
9+
venv/
10+
env/
11+
__pycache__/
12+
*.pyc

README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,111 @@
66
[![CodeQL](https://github.com/actions/typescript-action/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/actions/typescript-action/actions/workflows/codeql-analysis.yml)
77
[![Coverage](./badges/coverage.svg)](./badges/coverage.svg)
88

9+
## Running Locally
10+
11+
You can run the mini-swe-agent locally to test PRs before deploying to GitHub
12+
Actions.
13+
14+
### Prerequisites
15+
16+
1. Install dependencies:
17+
18+
```bash
19+
npm install
20+
npm run bundle # Build the CLI
21+
```
22+
23+
1. Set up required environment variables:
24+
25+
```bash
26+
# GitHub authentication (choose one):
27+
export GITHUB_TOKEN=$(gh auth token) # If using gh CLI
28+
# OR
29+
export GITHUB_TOKEN=ghp_your_token_here
30+
31+
# Model API keys (at least one required):
32+
export ANTHROPIC_API_KEY=your_anthropic_key
33+
# OR
34+
export OPENAI_API_KEY=your_openai_key
35+
```
36+
37+
### Usage
38+
39+
#### Dry Run (Local Testing)
40+
41+
Test the agent without creating PRs or comments on GitHub:
42+
43+
```bash
44+
npm run cli -- --repo owner/repo --pr 123 --dry-run
45+
```
46+
47+
This will:
48+
49+
- Clone the PR repository
50+
- Run the mini-swe-agent to analyze and fix issues
51+
- Display the generated patch locally
52+
- Not make any changes to GitHub
53+
54+
#### Live Mode (Create PRs/Comments)
55+
56+
Run the agent and create actual PRs or inline comments on GitHub:
57+
58+
```bash
59+
npm run cli -- --repo owner/repo --pr 456
60+
```
61+
62+
This will:
63+
64+
- Clone the PR repository
65+
- Run the mini-swe-agent
66+
- Create a follow-up PR or post inline comments based on the agent's decision
67+
68+
#### With CI Failure Context
69+
70+
If you have a specific workflow run that failed, you can provide its ID:
71+
72+
```bash
73+
npm run cli -- --repo owner/repo --pr 789 --workflow-run-id 12345
74+
```
75+
76+
### CLI Options
77+
78+
```text
79+
-r, --repo <owner/repo> Repository in "owner/repo" format
80+
-p, --pr <number> Pull request number (required)
81+
-d, --dry-run Show patch locally without PRs/comments
82+
-t, --token <token> GitHub token (default: GITHUB_TOKEN or gh)
83+
-w, --workflow-run-id <id> Workflow run ID for failure logs
84+
-o, --output-dir <path> Directory for debug artifacts
85+
--clickhouse-url <url> ClickHouse URL for tracking
86+
--clickhouse-table <name> ClickHouse table name
87+
-c, --cost-limit <dollars> Cost limit (default: 3.0)
88+
--timeout <minutes> Timeout in minutes (default: 30)
89+
-h, --help Show help message
90+
```
91+
92+
### Examples
93+
94+
```bash
95+
# Dry run on a public repository
96+
npm run cli -- --repo tensorzero/tensorzero --pr 100 --dry-run
97+
98+
# Run on your own repository with custom settings
99+
export GITHUB_TOKEN=$(gh auth token)
100+
npm run cli -- \
101+
--repo myorg/myrepo \
102+
--pr 42 \
103+
--cost-limit 5.0 \
104+
--timeout 45 \
105+
--output-dir ./debug-output
106+
107+
# Analyze a specific failed workflow run
108+
npm run cli -- \
109+
--repo owner/repo \
110+
--pr 123 \
111+
--workflow-run-id 9876543210
112+
```
113+
9114
## Developing
10115

11116
- `npm install`

0 commit comments

Comments
 (0)