Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/actions/ui-judge-comment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# UI Judge Comment

Creates or updates a pull request comment with `@lynx-js/ui-judge` results.

The action expects JSON shaped as one `UiJudgeResult`, an array of results, or
an object with a `results` array.

```yaml
permissions:
pull-requests: write

steps:
- run: pnpm --filter @lynx-js/ui-judge test
env:
UI_JUDGE_RESULT_FILE: ${{ github.workspace }}/ui-judge-results.json

- uses: ./.github/actions/ui-judge-comment
with:
result-file: ui-judge-results.json
```

Example result payload:

```json
{
"results": [
{
"dimension": "visual-correctness",
"score": 5,
"steps": [],
"url": "http://127.0.0.1:3000/render.html?demo=recs"
}
]
}
```

Inputs:

- `result-file`: path to a JSON result file.
- `result-json`: inline JSON result payload. Use this instead of
`result-file`.
- `pr-number`: pull request number. Defaults to the `pull_request` event.
- `title`: comment heading. Defaults to `UI Judge`.
- `marker`: hidden marker used to update a previous comment.
- `update-existing`: update the previous marked comment. Defaults to `true`.
- `dry-run`: print the comment body without calling the GitHub API.
- `github-token`: token for the GitHub API. Defaults to `github.token`.
66 changes: 66 additions & 0 deletions .github/actions/ui-judge-comment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: UI Judge Comment

description: Create or update a pull request comment with @lynx-js/ui-judge results.

inputs:
result-file:
description: Path to a JSON file containing a UiJudgeResult, an array of results, or an object with a results array.
required: false
result-json:
description: Inline JSON containing a UiJudgeResult, an array of results, or an object with a results array.
required: false
pr-number:
description: Pull request number. Defaults to the pull_request payload number.
required: false
title:
description: Heading shown in the pull request comment.
default: UI Judge
required: false
marker:
description: Hidden marker used to find and update the previous UI Judge comment.
default: <!-- ui-judge-comment -->
required: false
update-existing:
description: Update the previous marked comment instead of creating a new one.
default: "true"
required: false
dry-run:
description: Print the rendered comment without calling the GitHub API.
default: "false"
required: false
github-token:
description: Token used to create or update the pull request comment.
required: false

outputs:
body:
description: The rendered pull request comment body.
value: ${{ steps.comment.outputs.body }}
comment-id:
description: The created or updated issue comment id.
value: ${{ steps.comment.outputs.comment-id }}
comment-url:
description: The created or updated issue comment URL.
value: ${{ steps.comment.outputs.comment-url }}

runs:
using: composite
steps:
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: "22"
package-manager-cache: false
- name: Create or update UI Judge comment
id: comment
shell: bash
run: node "$GITHUB_ACTION_PATH/comment.mjs"
env:
INPUT_RESULT_FILE: ${{ inputs.result-file }}
INPUT_RESULT_JSON: ${{ inputs.result-json }}
INPUT_PR_NUMBER: ${{ inputs.pr-number }}
INPUT_TITLE: ${{ inputs.title }}
INPUT_MARKER: ${{ inputs.marker }}
INPUT_UPDATE_EXISTING: ${{ inputs.update-existing }}
INPUT_DRY_RUN: ${{ inputs.dry-run }}
INPUT_GITHUB_TOKEN: ${{ inputs.github-token }}
GITHUB_TOKEN: ${{ inputs.github-token || github.token }}
Loading
Loading