-
Notifications
You must be signed in to change notification settings - Fork 3
Add YAML file support to sync_code_blocks.py #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
08f63e2
89a302b
16c524f
c50bae1
bc4ebd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,8 +11,125 @@ Automatically review pull requests, providing feedback on code quality, security | |
| - Requesting `openhands-agent` as a reviewer | ||
| - Adding the `review-this` label to the PR | ||
|
|
||
| ```yaml icon="yaml" expandable agent-sdk/examples/03_github_workflows/01_basic_action/workflow.yml | ||
|
|
||
| <Note> | ||
| The reference workflow triggers on either the "review-this" label or when the openhands-agent account is requested as a reviewer. In OpenHands organization repositories, openhands-agent has access, so this works as-is. In your own repositories, requesting openhands-agent will only work if that account is added as a collaborator or is part of a team with access. If you don't plan to grant access, use the label trigger instead, or change the condition to a reviewer handle that exists in your repo. | ||
| </Note> | ||
|
|
||
| ```yaml icon="yaml" expandable examples/03_github_workflows/02_pr_review/workflow.yml | ||
| --- | ||
| # To set this up: | ||
| # 1. Copy this file to .github/workflows/pr-review.yml in your repository | ||
| # 2. Add your LLM_API_KEY to the repository secrets | ||
| # 3. Commit this file to your repository | ||
| # 4. Trigger the review by either: | ||
| # - Adding the "review-this" label to any PR, OR | ||
| # - Requesting openhands-agent as a reviewer | ||
| name: PR Review by OpenHands | ||
|
|
||
| on: | ||
| # Trigger when a label is added or a reviewer is requested | ||
| pull_request: | ||
| types: [labeled, review_requested] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| issues: write | ||
|
|
||
| jobs: | ||
| pr-review: | ||
| # Run when review-this label is added OR openhands-agent is requested as reviewer | ||
| if: | | ||
| github.event.label.name == 'review-this' || | ||
| github.event.requested_reviewer.login == 'openhands-agent' | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| # Configuration (modify these values as needed) | ||
| LLM_MODEL: <YOUR_LLM_MODEL> | ||
| LLM_BASE_URL: <YOUR_LLM_BASE_URL> | ||
| # PR context will be automatically provided by the agent script | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| PR_TITLE: ${{ github.event.pull_request.title }} | ||
| PR_BODY: ${{ github.event.pull_request.body }} | ||
| PR_BASE_BRANCH: ${{ github.event.pull_request.base.ref }} | ||
| PR_HEAD_BRANCH: ${{ github.event.pull_request.head.ref }} | ||
| REPO_NAME: ${{ github.repository }} | ||
| steps: | ||
| - name: Checkout agent-sdk repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: OpenHands/agent-sdk | ||
| path: agent-sdk | ||
|
|
||
| - name: Checkout PR repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| # Fetch the full history to get the diff | ||
| fetch-depth: 0 | ||
| path: pr-repo | ||
| # Check out the feature branch so agent can inspect the PR changes | ||
| ref: ${{ github.event.pull_request.head.ref }} | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v6 | ||
| with: | ||
| enable-cache: true | ||
|
|
||
| - name: Install GitHub CLI | ||
| run: | | ||
| # Install GitHub CLI for posting review comments | ||
| sudo apt-get update | ||
| sudo apt-get install -y gh | ||
|
|
||
| - name: Install OpenHands dependencies | ||
| run: | | ||
| # Install OpenHands SDK and tools from git repository | ||
| uv pip install --system "openhands-sdk @ git+https://github.com/OpenHands/agent-sdk.git@main#subdirectory=openhands-sdk" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we say 1.0.0 ? 🤔
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or install from pypi
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is actually the example workflow in the SDK repo, not this repo. cc @simonrosenberg - maybe we do want to point it to latest pypi wheel
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, sure 😅 |
||
| uv pip install --system "openhands-tools @ git+https://github.com/OpenHands/agent-sdk.git@main#subdirectory=openhands-tools" | ||
|
|
||
| - name: Check required configuration | ||
| env: | ||
| LLM_API_KEY: ${{ secrets.LLM_API_KEY }} | ||
| run: | | ||
| if [ -z "$LLM_API_KEY" ]; then | ||
| echo "Error: LLM_API_KEY secret is not set." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "PR Number: $PR_NUMBER" | ||
| echo "PR Title: $PR_TITLE" | ||
| echo "Repository: $REPO_NAME" | ||
| echo "LLM model: $LLM_MODEL" | ||
| if [ -n "$LLM_BASE_URL" ]; then | ||
| echo "LLM base URL: $LLM_BASE_URL" | ||
| fi | ||
|
|
||
| - name: Run PR review | ||
| env: | ||
| LLM_API_KEY: ${{ secrets.LLM_API_KEY }} | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| # Change to the PR repository directory so agent can analyze the code | ||
| cd pr-repo | ||
|
|
||
| # Run the PR review script from the agent-sdk checkout | ||
| uv run python ../agent-sdk/examples/03_github_workflows/02_pr_review/agent_script.py | ||
|
|
||
| - name: Upload logs as artifact | ||
| uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: openhands-pr-review-logs | ||
| path: | | ||
| *.log | ||
| output/ | ||
| retention-days: 7 | ||
| ``` | ||
|
|
||
| ## Quick Start | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks correct to me (right?), maybe a bit too verbose, but idk, readable.
WDYT, should we keep it? @xingyaoww @simonrosenberg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems useful info to keep?