-
Notifications
You must be signed in to change notification settings - Fork 82
feat: post check runs on PRs with Amber session link #1201
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ permissions: | |
| contents: read | ||
| issues: write | ||
| pull-requests: write | ||
| checks: write | ||
|
|
||
| jobs: | ||
| # -- Issue: labeled ambient-code:auto-fix → fresh session prompt -- | ||
|
|
@@ -274,10 +275,45 @@ jobs: | |
| wait: 'true' | ||
| timeout: '0' | ||
|
|
||
| - name: Post check run on PR | ||
| if: >- | ||
| always() | ||
| && steps.context.outputs.is_fork != 'true' | ||
| && steps.context.outputs.type == 'pr' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| SESSION_NAME="${{ steps.fix-session.outputs.session-name || steps.fix-issue-session.outputs.session-name || steps.custom-session.outputs.session-name }}" | ||
| SESSION_URL="${{ steps.fix-session.outputs.session-url || steps.fix-issue-session.outputs.session-url || steps.custom-session.outputs.session-url }}" | ||
| SESSION_PHASE="${{ steps.fix-session.outputs.session-phase || steps.fix-issue-session.outputs.session-phase || steps.custom-session.outputs.session-phase }}" | ||
|
|
||
| if [ -z "$SESSION_NAME" ]; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Get PR head SHA | ||
| HEAD_SHA=$(gh pr view ${{ steps.context.outputs.number }} --repo "${{ github.repository }}" --json headRefOid --jq '.headRefOid') | ||
|
|
||
| # Map session phase to check conclusion | ||
| case "$SESSION_PHASE" in | ||
| Completed|Running) CONCLUSION="success" ;; | ||
| Error|Failed) CONCLUSION="failure" ;; | ||
| *) CONCLUSION="neutral" ;; | ||
| esac | ||
|
|
||
| gh api "repos/${{ github.repository }}/check-runs" \ | ||
| -X POST \ | ||
| -f "name=Amber Session" \ | ||
| -f "head_sha=$HEAD_SHA" \ | ||
| -f "status=completed" \ | ||
| -f "conclusion=$CONCLUSION" \ | ||
| -f "details_url=$SESSION_URL" \ | ||
| -f "output[title]=Amber — ${{ steps.context.outputs.prompt_type }} prompt" \ | ||
| -f "output[summary]=Session \`$SESSION_NAME\` (phase: $SESSION_PHASE)" || true | ||
|
|
||
| - name: Session summary | ||
| if: always() && steps.context.outputs.is_fork != 'true' | ||
| run: | | ||
| # Get session name from whichever step ran (only one will have output) | ||
| SESSION_NAME="${{ steps.fix-session.outputs.session-name || steps.fix-issue-session.outputs.session-name || steps.custom-session.outputs.session-name }}" | ||
| SESSION_PHASE="${{ steps.fix-session.outputs.session-phase || steps.fix-issue-session.outputs.session-phase || steps.custom-session.outputs.session-phase }}" | ||
|
|
||
|
|
@@ -369,6 +405,24 @@ jobs: | |
| print(f" Failed to start session: {e}") | ||
| return False | ||
|
|
||
| def post_check_run(pr_number, session_name, status="in_progress"): | ||
| """Post a check run on the PR linking to the Amber session.""" | ||
| head_sha = gh("pr", "view", str(pr_number), "--repo", REPO, "--json", "headRefOid", "--jq", ".headRefOid") | ||
| if not head_sha: | ||
| return | ||
| api_url_base = API_URL.rstrip("/").replace("/api", "") | ||
| session_url = f"{api_url_base}/projects/{PROJECT}/sessions/{session_name}" | ||
| conclusion = "success" if status == "completed" else "neutral" | ||
| gh("api", f"repos/{REPO}/check-runs", | ||
| "-X", "POST", | ||
| "-f", "name=Amber Session", | ||
| "-f", f"head_sha={head_sha}", | ||
| "-f", "status=completed", | ||
| "-f", f"conclusion={conclusion}", | ||
| "-f", f"details_url={session_url}", | ||
| "-f", "output[title]=Amber — batch fix", | ||
| "-f", f"output[summary]=Session `{session_name}` triggered for PR #{pr_number}") | ||
|
|
||
|
Comment on lines
+408
to
+425
Contributor
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. 🧩 Analysis chain🏁 Script executed: find . -type f -name "amber-issue-handler.yml" | head -20Repository: ambient-code/platform Length of output: 108 🏁 Script executed: wc -l ./.github/workflows/amber-issue-handler.ymlRepository: ambient-code/platform Length of output: 112 🏁 Script executed: sed -n '400,440p' ./.github/workflows/amber-issue-handler.ymlRepository: ambient-code/platform Length of output: 2246 🏁 Script executed: sed -n '440,480p' ./.github/workflows/amber-issue-handler.ymlRepository: ambient-code/platform Length of output: 2365 🏁 Script executed: sed -n '480,530p' ./.github/workflows/amber-issue-handler.ymlRepository: ambient-code/platform Length of output: 2471 🏁 Script executed: sed -n '530,558p' ./.github/workflows/amber-issue-handler.ymlRepository: ambient-code/platform Length of output: 1552 Check runs posted to wrong commit; status hardcoded and parameter ignored.
Additionally, line 420 hardcodes Applies to lines 408–425 and the call site at 533–535. 🤖 Prompt for AI Agents |
||
| def create_session_api(prompt, session_name="", model="claude-opus-4-6"): | ||
| """Create a new session or send message to existing one.""" | ||
|
|
||
|
|
@@ -476,7 +530,9 @@ jobs: | |
| 5. Do not merge. Do not close. Do not force-push. | ||
| 6. If fundamentally broken beyond repair, add a comment explaining and stop.""" | ||
|
|
||
| create_session_api(prompt, session_name=session_id) | ||
| result_name = create_session_api(prompt, session_name=session_id) | ||
| if result_name: | ||
| post_check_run(number, result_name) | ||
|
|
||
| # Increment retry_count in frontmatter so circuit breaker advances | ||
| if fm: | ||
|
|
||
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.
Don't hide check-run creation failures.
Line 312 turns any
gh apirejection into a green step, so a bad payload/URL/permission regression will surface only as “the check never appeared.” If this must stay non-blocking, emit a warning with the API error instead of|| true.🤖 Prompt for AI Agents