Repository navigation
refactor: Use composite GitHub Action for PR review workflow #1927
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 14 commits
4864ff2
9318dde
24ba17a
7393a5a
fcec737
5614298
983b44f
d510dbd
256a944
7c29c92
a0ac453
55d19b2
35f5d0a
8097053
62db20a
da2095e
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 | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,125 @@ | ||||||||
| --- | ||||||||
| name: OpenHands PR Review | ||||||||
| description: Automated PR review using OpenHands agent | ||||||||
| author: OpenHands | ||||||||
|
|
||||||||
| branding: | ||||||||
| icon: code | ||||||||
| color: blue | ||||||||
|
|
||||||||
| inputs: | ||||||||
| llm-model: | ||||||||
| description: LLM model to use for the review | ||||||||
| required: false | ||||||||
| default: anthropic/claude-sonnet-4-5-20250929 | ||||||||
| llm-base-url: | ||||||||
| description: LLM base URL (optional, for custom LLM endpoints) | ||||||||
| required: false | ||||||||
| default: '' | ||||||||
| review-style: | ||||||||
| description: "Review style: 'standard' (balanced review covering style, readability, and security) or 'roasted' (Linus Torvalds-style brutally honest | ||||||||
| feedback focusing on data structures, simplicity, and pragmatism)" | ||||||||
| required: false | ||||||||
| default: roasted | ||||||||
| sdk-version: | ||||||||
| description: Git ref to use for the SDK (tag, branch, or commit SHA, e.g., v1.0.0, main, or abc1234) | ||||||||
| required: false | ||||||||
| default: main | ||||||||
|
enyst marked this conversation as resolved.
Resolved
|
||||||||
| llm-api-key: | ||||||||
| description: LLM API key (required) | ||||||||
| required: true | ||||||||
| github-token: | ||||||||
| description: GitHub token for API access (required) | ||||||||
| required: true | ||||||||
|
enyst marked this conversation as resolved.
Resolved
|
||||||||
|
|
||||||||
| runs: | ||||||||
| using: composite | ||||||||
| steps: | ||||||||
| - name: Checkout software-agent-sdk repository | ||||||||
| uses: actions/checkout@v4 | ||||||||
| with: | ||||||||
| repository: OpenHands/software-agent-sdk | ||||||||
| ref: ${{ inputs.sdk-version }} | ||||||||
|
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. 🟡 Suggestion: Consider documenting the security implications of the |
||||||||
| path: software-agent-sdk | ||||||||
|
|
||||||||
| - name: Checkout PR repository | ||||||||
| uses: actions/checkout@v4 | ||||||||
| with: | ||||||||
| repository: ${{ github.event.pull_request.head.repo.full_name }} | ||||||||
| ref: ${{ github.event.pull_request.head.ref }} | ||||||||
| fetch-depth: 0 | ||||||||
| persist-credentials: false | ||||||||
| path: pr-repo | ||||||||
|
|
||||||||
| - 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 | ||||||||
| shell: bash | ||||||||
| run: | | ||||||||
| sudo apt-get update | ||||||||
| sudo apt-get install -y gh | ||||||||
|
|
||||||||
| - name: Install OpenHands dependencies | ||||||||
| shell: bash | ||||||||
| run: | | ||||||||
|
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. 🟢 Nit: Using
Suggested change
|
||||||||
| uv pip install --system ./software-agent-sdk/openhands-sdk ./software-agent-sdk/openhands-tools | ||||||||
|
|
||||||||
| - name: Check required configuration | ||||||||
| shell: bash | ||||||||
| env: | ||||||||
| LLM_API_KEY: ${{ inputs.llm-api-key }} | ||||||||
| GITHUB_TOKEN: ${{ inputs.github-token }} | ||||||||
| run: | | ||||||||
| if [ -z "$LLM_API_KEY" ]; then | ||||||||
| echo "Error: llm-api-key is required." | ||||||||
| exit 1 | ||||||||
| fi | ||||||||
| if [ -z "$GITHUB_TOKEN" ]; then | ||||||||
| echo "Error: github-token is required." | ||||||||
| exit 1 | ||||||||
| fi | ||||||||
|
|
||||||||
| echo "PR Number: ${{ github.event.pull_request.number }}" | ||||||||
| echo "PR Title: ${{ github.event.pull_request.title }}" | ||||||||
| echo "Repository: ${{ github.repository }}" | ||||||||
| echo "SDK Version: ${{ inputs.sdk-version }}" | ||||||||
| echo "LLM model: ${{ inputs.llm-model }}" | ||||||||
| if [ -n "${{ inputs.llm-base-url }}" ]; then | ||||||||
| echo "LLM base URL: ${{ inputs.llm-base-url }}" | ||||||||
| fi | ||||||||
|
|
||||||||
| - name: Run PR review | ||||||||
| shell: bash | ||||||||
| env: | ||||||||
| LLM_MODEL: ${{ inputs.llm-model }} | ||||||||
| LLM_BASE_URL: ${{ inputs.llm-base-url }} | ||||||||
|
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. 🟢 Nit: Empty string for |
||||||||
| REVIEW_STYLE: ${{ inputs.review-style }} | ||||||||
| LLM_API_KEY: ${{ inputs.llm-api-key }} | ||||||||
| GITHUB_TOKEN: ${{ inputs.github-token }} | ||||||||
| 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 }} | ||||||||
| run: | | ||||||||
| cd pr-repo | ||||||||
| uv run python ../software-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/ | ||||||||
|
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. 🔴 Critical: The artifact paths are incorrect. The script runs with Fix:
Suggested change
|
||||||||
| retention-days: 7 | ||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -37,91 +37,15 @@ jobs: | |||||||
| group: pr-review-${{ github.event.pull_request.number }} | ||||||||
| cancel-in-progress: true | ||||||||
| runs-on: ubuntu-24.04 | ||||||||
| env: | ||||||||
| LLM_MODEL: litellm_proxy/claude-sonnet-4-5-20250929 | ||||||||
| LLM_BASE_URL: https://llm-proxy.app.all-hands.dev | ||||||||
| # 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 software-agent-sdk repository | ||||||||
| uses: actions/checkout@v5 | ||||||||
| - name: Run PR Review | ||||||||
| uses: OpenHands/software-agent-sdk/.github/actions/pr-review@main | ||||||||
| with: | ||||||||
| repository: OpenHands/software-agent-sdk | ||||||||
| path: software-agent-sdk | ||||||||
|
|
||||||||
| - name: Checkout PR repository | ||||||||
| uses: actions/checkout@v5 | ||||||||
| with: | ||||||||
| # When using pull_request_target, explicitly checkout the PR branch | ||||||||
| # This ensures we review the actual PR code (including fork PRs) | ||||||||
| repository: ${{ github.event.pull_request.head.repo.full_name }} | ||||||||
| ref: ${{ github.event.pull_request.head.ref }} | ||||||||
| fetch-depth: 0 | ||||||||
| # Security: Don't persist credentials to prevent untrusted PR code from using them | ||||||||
| persist-credentials: false | ||||||||
| path: pr-repo | ||||||||
|
|
||||||||
| - name: Set up Python | ||||||||
| uses: actions/setup-python@v6 | ||||||||
| with: | ||||||||
| python-version: '3.13' | ||||||||
|
|
||||||||
| - name: Install uv | ||||||||
| uses: astral-sh/setup-uv@v7 | ||||||||
| 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 local checkout | ||||||||
| uv pip install --system ./software-agent-sdk/openhands-sdk ./software-agent-sdk/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.ALLHANDS_BOT_GITHUB_PAT }} | ||||||||
| LMNR_PROJECT_API_KEY: ${{ secrets.LMNR_SKILLS_API_KEY }} | ||||||||
| run: | | ||||||||
| # Change to the PR repository directory so agent can analyze the code | ||||||||
| cd pr-repo | ||||||||
|
|
||||||||
| # Run the PR review script from the software-agent-sdk checkout | ||||||||
| uv run python ../software-agent-sdk/examples/03_github_workflows/02_pr_review/agent_script.py | ||||||||
|
|
||||||||
| - name: Upload logs as artifact | ||||||||
| uses: actions/upload-artifact@v5 | ||||||||
| if: always() | ||||||||
| with: | ||||||||
| name: openhands-pr-review-logs | ||||||||
| path: | | ||||||||
| *.log | ||||||||
| output/ | ||||||||
| retention-days: 7 | ||||||||
| llm-model: anthropic/claude-sonnet-4-5-20250929 | ||||||||
| llm-base-url: '' | ||||||||
| # Review style: roasted (other option: standard) | ||||||||
| review-style: roasted | ||||||||
| # Use the PR's head commit SHA to test SDK changes on the SDK repo itself | ||||||||
| sdk-version: ${{ github.event.pull_request.head.sha }} | ||||||||
|
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. 🟢 Nit: This is clever for testing SDK changes on the SDK repo itself, but consider adding a comment explaining why this differs from the example workflow. It helps future maintainers understand the self-referential testing pattern.
Suggested change
|
||||||||
| llm-api-key: ${{ secrets.LLM_API_KEY }} | ||||||||
| github-token: ${{ secrets.ALLHANDS_BOT_GITHUB_PAT }} | ||||||||
|
xingyaoww marked this conversation as resolved.
Resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../../.github/actions/pr-review/action.yml |
Uh oh!
There was an error while loading. Please reload this page.