mirror of
https://github.com/cstaelen/shazarr.git
synced 2026-10-19 01:31:11 -05:00
85 lines
2.9 KiB
YAML
85 lines
2.9 KiB
YAML
name: Playwright Tests
|
|
on:
|
|
push:
|
|
branches-ignore: [ gh-pages ]
|
|
concurrency:
|
|
group: ${{ github.ref }}
|
|
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
|
|
jobs:
|
|
test:
|
|
timeout-minutes: 60
|
|
runs-on: ubuntu-latest
|
|
name: 'Playwright Tests'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "20.x"
|
|
- name: Install dependencies
|
|
run: npm install
|
|
- name: Run Playwright tests
|
|
run: npm run testing:ci
|
|
- uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: playwright-report
|
|
path: ./testing/playwright-report/
|
|
retention-days: 30
|
|
|
|
publish_report:
|
|
name: Publish HTML Report
|
|
# using always() is not ideal here, because it would also run if the workflow was cancelled
|
|
if: "success() || needs.test.result == 'failure'"
|
|
needs: [test]
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: true
|
|
env:
|
|
# Unique URL path for each workflow run attempt
|
|
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
|
|
# see: https://github.com/actions/checkout/issues/13#issuecomment-724415212
|
|
run: |
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
echo ${{ env.HTML_REPORT_URL_PATH }}
|
|
- name: Download zipped HTML report
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: playwright-report
|
|
path: ${{ env.HTML_REPORT_URL_PATH }}
|
|
- name: Log
|
|
run: |
|
|
pwd
|
|
ls -la
|
|
ls -la reports
|
|
- name: Push HTML Report
|
|
timeout-minutes: 3
|
|
# commit report, then try push-rebase-loop until it's able to merge the HTML report to the gh-pages branch
|
|
# this is necessary when this job is running at least twice at the same time (e.g. through two pushes at the same time)
|
|
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 Worfklow Annotation
|
|
run: |
|
|
FULL_HTML_REPORT_URL=https://cstaelen.github.io/shazarr-app/$HTML_REPORT_URL_PATH
|
|
|
|
echo "::notice title=📋 Published Playwright Test Report::$FULL_HTML_REPORT_URL" |