Skip to content

feat: add Playwright package for screenshot testing #8

feat: add Playwright package for screenshot testing

feat: add Playwright package for screenshot testing #8

name: PR Visual Tests
on:
pull_request:
jobs:
visual_tests:
name: Visual Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '18.x'
cache: 'npm'
- name: Install Packages
run: npm ci
- name: Install Demo Packages
run: cd demo && npm i
- name: Build Files
run: npm run build
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Visual Tests
run: npm run test
- name: Upload Playwright Report
uses: actions/upload-artifact@v4
if: github.event.workflow_run.event == 'pull_request'
with:
name: playwright-report
path: ./playwright-report
retention-days: 1
- name: Save PR ID
if: always()
run: |
pr="${{ github.event.pull_request.number }}"
echo $pr > ./pr-id.txt
shell: bash
- name: Create PR Artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: pr
path: ./pr-id.txt
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Extract PR Number
id: pr
run: echo "::set-output name=id::$(<pr/pr-id.txt)"
shell: bash
- name: Upload to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_AWS_KEY_ID }}
AWS_DEFAULT_REGION: ru-central1
AWS_EC2_METADATA_DISABLED: true
run: aws s3 cp playwright-report s3://diplodoc-playwright-reports/components/test-report/${{ steps.pr.outputs.id}}/ --endpoint-url=https://storage.yandexcloud.net --recursive
shell: bash
- name: Create Comment
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ steps.pr.outputs.id }}
header: visual tests report
message: '[Visual Tests Report](https://storage.yandexcloud.net/diplodoc-playwright-reports/components/test-report/${{ steps.pr.outputs.id }}/index.html) is ready.'