Skip to content

Commit

Permalink
chore: replace karma with playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
Joozty committed Nov 7, 2024
1 parent c205f18 commit 38e9a1b
Show file tree
Hide file tree
Showing 22 changed files with 3,184 additions and 178 deletions.
37 changes: 37 additions & 0 deletions .github/actions/install-playwright/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'Install playwright'
description: 'Install Playwright browser binaries and OS dependencies'
runs:
using: 'composite'
steps:
- name: Get installed Playwright version
id: playwright-version
shell: bash
working-directory: ./packages/integration-tests
run: |
PLAYWRIGHT_VERSION=$(npm ls --json "@playwright/test" | jq --raw-output '.dependencies["@playwright/test"].version')
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Set up path for Playwright cache
shell: bash
run: echo "PLAYWRIGHT_CACHE_PATH=$(if [[ $RUNNER_OS == 'macOS' ]]; then echo '~/Library/Caches/ms-playwright'; else echo '~/.cache/ms-playwright'; fi)" >> $GITHUB_ENV

- name: Cache Playwright binaries
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
id: playwright-cache
with:
path: ${{ env.PLAYWRIGHT_CACHE_PATH }}
key: '${{ runner.os }}-playwright-cache-${{ env.PLAYWRIGHT_VERSION }}-splunk-otel-js-web-artifacts'

- name: Install Playwright browser binaries
if: steps.playwright-cache.outputs.cache-hit != 'true'
shell: bash
run: |
npx playwright install --with-deps
npx playwright install chrome
npx playwright install msedge
npx playwright install webkit
- name: Install Playwright OS dependencies
if: steps.playwright-cache.outputs.cache-hit != 'true'
shell: bash
run: npx playwright install-deps
4 changes: 4 additions & 0 deletions .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ jobs:
uses: ./.github/actions/setup
- name: Local integration tests using ${{ matrix.browser }}
run: npm run test:integration:local:${{ matrix.browser }}:_execute

playwright:
uses: ./.github/workflows/tests.yml
secrets: inherit
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,7 @@ jobs:
path: |
packages/web/tests_output/
packages/web/logs/
playwright:
uses: ./.github/workflows/tests.yml
secrets: inherit
118 changes: 118 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Playwright tests
on:
workflow_call:

jobs:
playwright:
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
browser: [chromium, firefox, chrome, edge]
name: Playwright Tests - ${{ matrix.browser }}
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: '18'
cache: 'npm'
- run: npm ci
- run: npm run compile

- name: Install playwright
uses: ./.github/actions/install-playwright

- name: Run Playwright tests
run: |
npx playwright test --project=${{ matrix.browser }}
working-directory: ./packages/integration-tests

- name: Upload blob report to GitHub Actions Artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
with:
name: blob-report-${{ matrix.browser }}-attempt-${{ github.run_attempt }}
path: packages/integration-tests/blob-report
retention-days: 1

playwright-macos:
timeout-minutes: 60
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
browser: [webkit]
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: '18'
cache: 'npm'
- run: npm ci
- run: npm run compile

- name: Install playwright
uses: ./.github/actions/install-playwright

- name: Run Playwright tests
run: |
npx playwright test --project=${{ matrix.browser }}
working-directory: ./packages/integration-tests

- name: Upload blob report to GitHub Actions Artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
with:
name: blob-report-${{ matrix.browser }}-attempt-${{ github.run_attempt }}
path: packages/integration-tests/blob-report
retention-days: 1

merge-reports:
if: ${{ !cancelled() }}
needs: [playwright, playwright-macos]

runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: '18'
cache: 'npm'
- run: npm ci
- run: npm run compile

- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
path: packages/integration-tests/all-blob-reports
pattern: blob-report-*
merge-multiple: true

- name: Merge into HTML Report
run: npx playwright merge-reports --reporter html ./all-blob-reports -c playwright.config.ts
working-directory: ./packages/integration-tests

- name: Upload HTML report
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
with:
name: playwright-report--attempt-${{ github.run_attempt }}
path: packages/integration-tests/playwright-report
retention-days: 14

check-failure:
needs: [playwright, playwright-macos, merge-reports]
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Check if any playwright tests failed
run: |
if [ "${{ needs.playwright.result }}" != "success" ] || [ "${{ needs['playwright-macos'].result }}" != "success" ]; then
echo "One or more tests failed."
exit 1
else
echo "All tests passed."
fi
Loading

0 comments on commit 38e9a1b

Please sign in to comment.