Files
mcp-use__mcp-use/.github/workflows/conformance-comment.yml
Ayaan Gazali bf30ab5431 ci(conformance): post fork scores from the workflow_run path (#2310)
Review feedback on #2310: rather than skipping the score comment for
forks, make the workflow_run companion the only writer and teach it to
resolve fork pull requests.

conformance.yml's report-conformance job is removed. It ran in the
unprivileged pull_request context, so on a fork PR it could only fail
with "Resource not accessible by integration". conformance-comment.yml
already runs in the privileged workflow_run context and posted the Python
score on those same fork PRs.

Its TypeScript path could not, because it resolved the pull request from
workflow_run.pull_requests[0], which GitHub leaves empty for
fork-originated runs. It now resolves from the run's own head:

  head = `${run.head_repository.owner.login}:${run.head_branch}`

and only comments when an open pull request at that head still points at
run.head_sha, so a slow run cannot overwrite a newer result. The pull
request number is never read from the downloaded artifact, which a fork
controls.

Verified the resolution against a live fork PR:

  #2350 head=ayaangazali:docs/cli-readme sha=f1fa0469
  resolved #2350 head_sha=f1fa0469
2026-08-30 10:43:22 -07:00

123 lines
4.5 KiB
YAML

name: Post Conformance Comment
on:
workflow_run:
workflows: ["MCP Conformance Tests"]
types:
- completed
permissions:
pull-requests: write
issues: write
jobs:
comment:
name: Post Conformance Results Comment
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion != 'cancelled' &&
github.event.workflow_run.conclusion != 'skipped'
steps:
- name: Download conformance results
id: download-results
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: conformance-results
path: conformance-results
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Post comment using action
if: steps.download-results.outcome == 'success'
uses: mcp-use/mcp-conformance-action@v1
with:
mode: comment
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-mode: update
- name: Download TypeScript v2 results
id: download-typescript-results
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: typescript-v2-conformance-results
path: typescript-v2-conformance-results
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Post current-head TypeScript scores
if: steps.download-typescript-results.outcome == 'success'
uses: actions/github-script@v7
env:
RESULTS_ROOT: typescript-v2-conformance-results
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs')
const path = require('path')
const root = process.env.RESULTS_ROOT
const summaryPath = path.join(root, 'summary.md')
if (!fs.existsSync(summaryPath)) {
core.setFailed(`Missing TypeScript conformance summary: ${summaryPath}`)
return
}
const body = fs.readFileSync(summaryPath, 'utf8').trim()
const marker = '<!-- mcp-use-typescript-conformance-results -->'
// `workflow_run.pull_requests` is empty for fork-originated runs, so
// resolve the pull request from the run's own head instead. The PR
// number is never read from the downloaded artifact, which a fork
// controls.
const run = context.payload.workflow_run
const headOwner = run.head_repository?.owner?.login
const headBranch = run.head_branch
if (!headOwner || !headBranch) {
core.info('Conformance run carried no head repository or branch')
return
}
const { data: candidates } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${headOwner}:${headBranch}`,
per_page: 10,
})
// Only comment when the open PR still points at the commit this run
// scored, so a slow run cannot overwrite a newer result.
const issue = candidates.find((pr) => pr.head.sha === run.head_sha)
if (!issue) {
core.info(
`No open pull request at ${headOwner}:${headBranch} with head ${run.head_sha}`
)
return
}
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
per_page: 100,
})
const comment = `${marker}\n## TypeScript Conformance (current head)\n\n${body}`
const existing = comments.find((item) => item.body?.includes(marker))
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body: comment,
})
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: comment,
})
}