-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #720 from KshitijThareja/vt-ghaction
[Visual Testing] Update comment job in workflow to use custom script
- Loading branch information
Showing
2 changed files
with
85 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
async function generateComment(percyUrl) { | ||
return ` | ||
### Percy Visual Test Results | ||
**Percy Dashboard:** [View Detailed Report](${percyUrl}) | ||
**Environment:** | ||
- **Node.js Version:** 18.x | ||
- **OS:** Ubuntu-latest | ||
**Instructions for Reviewers:** | ||
- Click on the [Percy Dashboard](${percyUrl}) link to view detailed visual diffs. | ||
- Review the visual changes highlighted in the report. | ||
- Approve or request changes based on the visual differences. | ||
`; | ||
} | ||
|
||
async function findComment(github, context, issue_number) { | ||
let comment; | ||
let page = 1 | ||
while (!comment) { | ||
const request = await github.rest.issues.listComments({ | ||
issue_number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
page, | ||
}) | ||
const comments = request.data | ||
if (!comments.length) { | ||
return; | ||
} | ||
comment = comments.find(c => c.body && c.body.includes('### Percy Visual Test Results')); | ||
if (comment) { | ||
return comment.id.toString() | ||
} | ||
page += 1; | ||
} | ||
} | ||
|
||
module.exports = { | ||
findComment, | ||
generateComment, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters