Playwright Tests #137
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
name: Playwright Tests | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 9 * * 1' | |
jobs: | |
install: | |
name: Install | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout Repository | |
id: checkout-repository | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
id: setup-node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Cache Node Modules | |
id: cache-node-modules | |
uses: actions/cache@v4 | |
with: | |
path: | | |
node_modules | |
key: modules-${{ hashFiles('package-lock.json') }} | |
- name: Cache Playwright Binaries | |
id: cache-playwright | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/ms-playwright | |
key: playwright-${{ hashFiles('package-lock.json') }} | |
- name: Install dependencies | |
id: install-dependencies | |
if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: Install Playwright Browsers | |
id: install-playwright-browsers | |
if: steps.cache-playwright.outputs.cache-hit != 'true' | |
run: npx playwright install --with-deps | |
test: | |
name: Tests - ${{ matrix.project }} - Shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }} | |
runs-on: ubuntu-latest | |
needs: [install] | |
timeout-minutes: 60 | |
strategy: | |
fail-fast: false | |
matrix: | |
project: [chromium, firefox, webkit] | |
shardIndex: [1, 2] | |
shardTotal: [2] | |
services: | |
rbp-booking: | |
image: mwinteringham/restfulbookerplatform_booking:1.6.24c7b22 | |
ports: | |
- 3000:3000 | |
rbp-room: | |
image: mwinteringham/restfulbookerplatform_room:1.6.24c7b22 | |
ports: | |
- 3001:3001 | |
rbp-branding: | |
image: mwinteringham/restfulbookerplatform_branding:1.6.24c7b22 | |
ports: | |
- 3002:3002 | |
rbp-assets: | |
image: mwinteringham/restfulbookerplatform_assets:1.6.24c7b22 | |
ports: | |
- 3003:3003 | |
rbp-auth: | |
image: mwinteringham/restfulbookerplatform_auth:1.6.24c7b22 | |
ports: | |
- 3004:3004 | |
rbp-report: | |
image: mwinteringham/restfulbookerplatform_report:1.6.24c7b22 | |
ports: | |
- 3005:3005 | |
rbp-message: | |
image: mwinteringham/restfulbookerplatform_message:1.6.24c7b22 | |
ports: | |
- 3006:3006 | |
rbp-proxy: | |
image: mwinteringham/restfulbookerplatform_proxy:latest | |
ports: | |
- 80:80 | |
steps: | |
- name: Checkout Repository | |
id: checkout-repository | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
id: setup-node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Cache Node Modules | |
id: cache-node-modules | |
uses: actions/cache@v4 | |
with: | |
path: | | |
node_modules | |
key: modules-${{ hashFiles('package-lock.json') }} | |
- name: Cache Playwright Binaries | |
id: cache-playwright | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/ms-playwright | |
key: playwright-${{ hashFiles('package-lock.json') }} | |
# Playwright caches the browser binaries, but not their dependencies. | |
# Those extra browser dependencies must be installed separately when the cached browsers are restored. | |
- name: Install Playwright System Dependencies | |
id: install-playwright-system-dependencies | |
run: npx playwright install-deps ${{ matrix.project }} | |
- name: Run Playwright Tests | |
id: run-playwright-tests | |
run: npx playwright test --project=${{ matrix.project }} --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} | |
env: | |
ENV: local | |
BLOB_NAME: ${{ matrix.project }}-${{ matrix.shardIndex }} | |
- name: Upload Playwright Blob Report | |
id: upload-playwright-blob-report | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: playwright-blob-report-${{ matrix.project }}-${{ matrix.shardIndex }}_${{ matrix.shardTotal }} | |
path: playwright-blob-report | |
if-no-files-found: ignore | |
retention-days: 1 | |
- name: Upload Playwright Test Results | |
id: upload-playwright-test-results | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: test-results-${{ matrix.project }}-${{ matrix.shardIndex }}_${{ matrix.shardTotal }} | |
path: test-results/ | |
if-no-files-found: ignore | |
retention-days: 1 | |
- name: Upload Playwright Monocart Report | |
id: upload-playwright-monocart-report | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: monocart-report-${{ matrix.project }}-${{ matrix.shardIndex }}_${{ matrix.shardTotal }} | |
path: playwright-monocart-report/ | |
if-no-files-found: ignore | |
retention-days: 1 | |
- name: Upload Playwright Allure Results | |
id: upload-playwright-allure-results | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: playwright-allure-results-${{ matrix.project }}-${{ matrix.shardIndex }}_${{ matrix.shardTotal }} | |
path: playwright-allure-results/ | |
if-no-files-found: ignore | |
retention-days: 1 | |
report: | |
name: Merge and Publish Reports | |
if: ${{ always() }} | |
runs-on: ubuntu-latest | |
needs: [test] | |
timeout-minutes: 30 | |
permissions: | |
actions: write | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: 'pages' | |
cancel-in-progress: true | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Checkout Repository | |
id: checkout-repository | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
id: setup-node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Cache Node Modules | |
id: cache-node-modules | |
uses: actions/cache@v4 | |
with: | |
path: | | |
node_modules | |
key: modules-${{ hashFiles('package-lock.json') }} | |
- name: Cache Playwright Binaries | |
id: cache-playwright | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/ms-playwright | |
key: playwright-${{ hashFiles('package-lock.json') }} | |
- name: Download Playwright Blob Reports | |
id: download-blob-reports | |
uses: actions/download-artifact@v4 | |
with: | |
path: playwright-all-blob-reports | |
pattern: playwright-blob-report-* | |
merge-multiple: true | |
- name: Merge Playwright HTML Reports | |
id: merge-playwright-html-reports | |
run: npx playwright merge-reports --reporter html ./playwright-all-blob-reports | |
- name: Download Monocart Reports | |
id: download-monocart-reports | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: monocart-report-* | |
- name: Download Test Results | |
id: download-test-results | |
uses: actions/download-artifact@v4 | |
with: | |
path: merged-monocart-report/data | |
pattern: test-results-* | |
merge-multiple: true | |
- name: Merge Playwright Monocart Reports | |
id: merge-playwright-monocart-reports | |
run: | | |
curl -o previous-trend.json https://milos-pujic.github.io/playwright-e2e-tests/monocart/index.json | |
npm run merge:report:monocart | |
- name: Download Allure Results | |
id: download-allure-results | |
uses: actions/download-artifact@v4 | |
with: | |
path: playwright-allure-results | |
pattern: playwright-allure-results-* | |
merge-multiple: true | |
- name: Generate Allure Report | |
id: generate-allure-report | |
run: | | |
curl --create-dirs -o ./playwright-allure-results/history/categories-trend.json https://milos-pujic.github.io/playwright-e2e-tests/allure/history/categories-trend.json | |
curl --create-dirs -o ./playwright-allure-results/history/duration-trend.json https://milos-pujic.github.io/playwright-e2e-tests/allure/history/duration-trend.json | |
curl --create-dirs -o ./playwright-allure-results/history/history-trend.json https://milos-pujic.github.io/playwright-e2e-tests/allure/history/history-trend.json | |
curl --create-dirs -o ./playwright-allure-results/history/history.json https://milos-pujic.github.io/playwright-e2e-tests/allure/history/history.json | |
curl --create-dirs -o ./playwright-allure-results/history/retry-trend.json https://milos-pujic.github.io/playwright-e2e-tests/allure/history/retry-trend.json | |
npx allure generate playwright-allure-results -o playwright-allure-report --clean | |
- name: Move to Reports folder | |
id: move-to-reports-folder | |
run: | | |
mv playwright-report reports/playwright | |
mv merged-monocart-report reports/monocart | |
mv playwright-allure-report reports/allure | |
shell: bash | |
- name: Setup Pages | |
id: setup-pages | |
uses: actions/configure-pages@v5 | |
- name: Upload Pages Artifact | |
id: upload-pages-artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: reports/ | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
- name: Delete Unnecessary Artifacts | |
id: delete-unnecessary-artifacts | |
uses: geekyeggo/delete-artifact@v5 | |
with: | |
name: | | |
playwright-blob-report-* | |
test-results-* | |
monocart-report-* | |
playwright-allure-results-* | |
failOnError: false |