Skip to content

automatically upload E2E test report #38

automatically upload E2E test report

automatically upload E2E test report #38

Workflow file for this run

name: Playwright Tests
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
branches: [main]
jobs:
playwright-tests:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- name: Check if Pull Request
if: github.event_name != 'pull_request'
run: echo "Not a pull request, exiting early." && exit 0
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Wait for Netlify Deploy
uses: jakepartusch/wait-for-netlify-action@v1
id: netlify
with:
site_name: "parrit"
- name: Run Playwright tests
run: URL=${{steps.netlify.outputs.url}} npx playwright test
- name: Check filesystem for test results
if: ${{ !cancelled() }}
run: |
ls -ls
ls -la playwright-report/
- name: Upload HTML report
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
publish-report:
name: Publish HTML Playwright Report
if: ${{ !cancelled() }}
needs: playwright-tests
runs-on: ubuntu-latest
continue-on-error: true
env:
HTML_REPORT_URL_PATH: reports/${{ github.ref_name }}/${{ github.run_id }}/${{ github.run_attempt }}
steps:
- name: Checkout GitHub Pages Branch
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Set Git User
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Download zipped HTML report
uses: actions/download-artifact@v4
with:
name: playwright-report
path: ${{env.HTML_REPORT_URL_PATH}}
- name: Push HTML Report
timeout-minutes: 3
run: |
git add .
git commit -m "workflow: add HTML report for run-id ${{ github.run_id }} (attempt: ${{ github.run_attempt }})"
while true; do
git pull --rebase
if [ $? -ne 0 ]; then
echo "Failed to rebase. Please review manually."
exit 1
fi
git push
if [ $? -eq 0 ]; then
echo "Successfully pushed HTML report to repo."
exit 0
fi
done
- name: Output Report URL as Workflow Annotation
run: |
FULL_HTML_REPORT_URL=https://parrit.github.io/playwright-gh-actions-gh-pages/$HTML_REPORT_URL_PATH
echo "::notice title=📋 Published Playwright Test Report::$FULL_HTML_REPORT_URL"