Skip to content

Commit

Permalink
get the playwright version inside the action
Browse files Browse the repository at this point in the history
  • Loading branch information
iAmmar7 committed Dec 30, 2024
1 parent cc70ebf commit 585e1f2
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 44 deletions.
39 changes: 36 additions & 3 deletions .github/actions/playwright/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,53 @@ description: Install playwright and required browsers

inputs:
PLAYWRIGHT_VERSION:
required: true
description: Playwright version to use
description: If provided, the action will use this version directly
required: false
PACKAGE_JSON_PATH:
description: Path to package.json where '@playwright/test' is defined
required: false
default: './internal/e2e-js/package.json'

runs:
using: composite
steps:
- name: Validate input
shell: bash
run: |
# Ensure at least one of PLAYWRIGHT_VERSION or PACKAGE_JSON_PATH is passed
if [ -z "${{ inputs.PLAYWRIGHT_VERSION }}" ] && [ -z "${{ inputs.PACKAGE_JSON_PATH }}" ]; then
echo "Error: You must provide either PLAYWRIGHT_VERSION or PACKAGE_JSON_PATH."
exit 1
fi
- name: Get Playwright version
id: playwright-version
shell: bash
run: |
# If a version is explicitly provided, use that
if [ -n "${{ inputs.PLAYWRIGHT_VERSION }}" ]; then
DETECTED_VERSION="${{ inputs.PLAYWRIGHT_VERSION }}"
echo "Using explicit Playwright version: $DETECTED_VERSION"
else
# Otherwise, read it from package.json
echo "Reading Playwright version from ${{ inputs.PACKAGE_JSON_PATH }}"
DETECTED_VERSION=$(jq -r '.devDependencies["@playwright/test"]' "${{ inputs.PACKAGE_JSON_PATH }}")
DETECTED_VERSION=${DETECTED_VERSION#^} # Remove ^
echo "Detected Playwright version: $DETECTED_VERSION"
fi
echo "PLAYWRIGHT_VERSION=$DETECTED_VERSION" >> $GITHUB_ENV
- name: Cache playwright binaries
uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ inputs.PLAYWRIGHT_VERSION }}
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}

- if: steps.playwright-cache.outputs.cache-hit != 'true'
name: Install Playwright
shell: bash
run: npx playwright install --with-deps chromium

9 changes: 1 addition & 8 deletions .github/workflows/browser-js-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,10 @@ jobs:
uses: ./.github/actions/build
with:
NODE_VERSION: ${{ matrix.node-version }}
- name: Get Playwright version
id: playwright-version
run: |
PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-js/package.json)
PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^}
echo "Playwright version: $PLAYWRIGHT_VERSION"
echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
- name: Install Playwright
uses: ./.github/actions/playwright
with:
PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.playwright_version }}
PACKAGE_JSON_PATH: ./internal/e2e-js/package.json
- name: Test
run: npm run -w=@sw-internal/e2e-js dev -- --project ${{ matrix.project }}
env:
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/browser-js-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,10 @@ jobs:
uses: ./.github/actions/build
with:
NODE_VERSION: ${{ matrix.node-version }}
- name: Get Playwright version
id: playwright-version
run: |
PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-js/package.json)
PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^}
echo "Playwright version: $PLAYWRIGHT_VERSION"
echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
- name: Install Playwright
uses: ./.github/actions/playwright
with:
PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.playwright_version }}
PACKAGE_JSON_PATH: ./internal/e2e-js/package.json
- name: Test
run: npm run -w=@sw-internal/e2e-js dev -- --project ${{ matrix.project }}
env:
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/realtime-api-production-euswcom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,10 @@ jobs:
uses: ./.github/actions/build
with:
NODE_VERSION: ${{ matrix.node-version }}
- name: Get Playwright version
id: playwright-version
run: |
PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-realtime-api/package.json)
PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^}
echo "Playwright version: $PLAYWRIGHT_VERSION"
echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
- name: Install Playwright
uses: ./.github/actions/playwright
with:
PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.playwright_version }}
PACKAGE_JSON_PATH: ./internal/e2e-realtime-api/package.json
- name: Test
id: run-tests
run: npm run -w=@sw-internal/e2e-realtime-api dev
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/realtime-api-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,11 @@ jobs:
uses: ./.github/actions/build
with:
NODE_VERSION: ${{ matrix.node-version }}
- name: Get Playwright version
id: playwright-version
run: |
PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-realtime-api/package.json)
PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^}
echo "Playwright version: $PLAYWRIGHT_VERSION"
echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
- name: Install Playwright
if: matrix.test_command == 'dev:playwright'
uses: ./.github/actions/playwright
with:
PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.playwright_version }}
PACKAGE_JSON_PATH: ./internal/e2e-realtime-api/package.json
- name: Test
run: 'npm run -w=@sw-internal/e2e-realtime-api ${{ matrix.test_command }}'
env:
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/realtime-api-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,11 @@ jobs:
uses: ./.github/actions/build
with:
NODE_VERSION: ${{ matrix.node-version }}
- name: Get Playwright version
id: playwright-version
run: |
PLAYWRIGHT_VERSION=$(jq -r '.devDependencies["@playwright/test"]' ./internal/e2e-realtime-api/package.json)
PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION#^}
echo "Playwright version: $PLAYWRIGHT_VERSION"
echo "playwright_version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
- name: Install Playwright
if: matrix.test_command == 'dev:playwright'
uses: ./.github/actions/playwright
with:
PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.playwright_version }}
PACKAGE_JSON_PATH: ./internal/e2e-realtime-api/package.json
- name: Test
run: 'npm run -w=@sw-internal/e2e-realtime-api ${{ matrix.test_command }}'
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/v2-webrtc-calling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
- name: Install Playwright
uses: ./.github/actions/playwright
with:
PLAYWRIGHT_VERSION: '1.49.1' # TODO: Read from deps ?
PACKAGE_JSON_PATH: ./internal/e2e-js/package.json
- name: Run test for ${{ matrix.region.name }}
id: run-tests
run: npm run -w=@sw-internal/e2e-js dev -- v2WebrtcFromRest.spec.ts webrtcCalling.spec.ts
Expand Down

0 comments on commit 585e1f2

Please sign in to comment.