Added playwright for visual regression test #5
This file contains hidden or 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
name: Update screenshot on comment | |
on: | |
pull_request: | |
jobs: | |
update-screenshots: | |
name: Update Screenshot | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- uses: xt0rted/pull-request-comment-branch@v3 | |
id: comment-branch | |
- uses: actions/checkout@v4 | |
if: success() | |
with: | |
ref: ${{ steps.comment-branch.outputs.head_ref }} | |
- name: Comment on PR with Playwright updates | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
if: ${{ failure() && env.SNAPSHOT_DIFFERENCES == 'true' }} | |
with: | |
script: | | |
const body = `### Updating snapshots. Click [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) to see the status.`; | |
await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: body, | |
}); | |
- name: Install dependencies | |
run: cd tests && npm ci | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0 | |
with: | |
hugo-version: "0.134.2" | |
extended: true | |
- name: Install Playwright browsers | |
run: npx playwright install --with-deps | |
- name: Run Playwright update snapshots | |
id: test-visual | |
run: make tests-update-screenshots | |
- uses: actions/upload-artifact@v4 | |
id: artifact-upload | |
with: | |
name: screenshots | |
path: tests/src/__screenshots__ | |
- name: Comment on PR with success | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
with: | |
script: | | |
const body = `### Please download the artifacts [here](${{ steps.artifact-upload.outputs.artifact-url }}) and commit your updated screenshots.`; | |
await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: body, | |
}); |