Skip to content

Commit

Permalink
chore: replace integration-tests karma with playwright (#887)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joozty authored Dec 11, 2024
1 parent 22dbf70 commit 16570e7
Show file tree
Hide file tree
Showing 172 changed files with 6,323 additions and 4,880 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
59 changes: 3 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,59 +26,6 @@ jobs:
- name: Unit test (nodejs)
run: npm run test:unit:ci-node

saucelabs-integration-tests:
runs-on: ubuntu-latest
permissions: read-all
environment: integration
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
SAUCE_TUNNEL_ID: ${{ secrets.SAUCE_TUNNEL_ID }}
strategy:
fail-fast: false
matrix:
browser: [edge]
steps:
- name: Setup sauce connect
uses: saucelabs/[email protected]
with:
username: ${{ secrets.SAUCE_USERNAME }}
accessKey: ${{ secrets.SAUCE_ACCESS_KEY }}
tunnelName: ${{ secrets.SAUCE_TUNNEL_ID }}
- name: Checkout
uses: actions/[email protected]

- name: Setup
uses: ./.github/actions/setup

- name: Add to hosts file
run: echo "127.0.0.1 local.test" | sudo tee -a /etc/hosts
- name: Run integration tests in Saucelabs
run: npm run test:integration:remote -- --env ${{ matrix.browser }}
timeout-minutes: 15

local-integration-tests:
runs-on: ubuntu-latest
permissions: read-all
strategy:
fail-fast: false
matrix:
browser: [headlessChrome, headlessFirefox]
steps:
- name: Checkout
uses: actions/[email protected]

- name: Setup
uses: ./.github/actions/setup

- name: Local integration tests using ${{ matrix.browser }}
run: npm run test:integration:local:${{ matrix.browser }}:_execute

- name: Upload test logs
uses: actions/[email protected]
if: ${{ failure() }}
with:
name: test-results ${{ matrix.browser }}
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 16570e7

Please sign in to comment.