Skip to content

Playwright Test

Playwright Test #180

Workflow file for this run

name: Playwright Test
on:
deployment_status:
env:
HUSKY: 0
jobs:
Run:
name: Shard ${{ matrix.shardIndex }}
if: github.event.deployment_status.state == 'success' && github.event.deployment_status.environment == 'Preview'
timeout-minutes: 60
runs-on: ubuntu-latest
env:
SHARD_INDEX: ${{ matrix.shardIndex }}
SHARD_TOTAL: 3
strategy:
fail-fast: false
matrix:
shardIndex:
- 1
- 2
- 3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test --shard=$SHARD_INDEX/$SHARD_TOTAL
env:
PLAYWRIGHT_TEST_BASE_URL: ${{ github.event.deployment_status.target_url }}
PLAYWRIGHT_PRODUCT_NAME_INSTOCK: ${{ vars.PLAYWRIGHT_PRODUCT_NAME_INSTOCK }}
PLAYWRIGHT_PRODUCT_SIZE_INSTOCK: ${{ vars.PLAYWRIGHT_PRODUCT_SIZE_INSTOCK }}
PLAYWRIGHT_PRODUCT_COLOR_INSTOCK: ${{ vars.PLAYWRIGHT_PRODUCT_COLOR_INSTOCK }}
PLAYWRIGHT_COLLECTION_NAME: ${{ vars.PLAYWRIGHT_COLLECTION_NAME }}
PLAYWRIGHT_PRODUCT_NAME_OUTOFSTOCK: ${{ vars.PLAYWRIGHT_PRODUCT_NAME_OUTOFSTOCK }}
PLAYWRIGHT_PRODUCT_SIZE_OUTOFSTOCK: ${{ vars.PLAYWRIGHT_PRODUCT_SIZE_OUTOFSTOCK }}
PLAYWRIGHT_PRODUCT_COLOR_OUTOFSTOCK: ${{ vars.PLAYWRIGHT_PRODUCT_COLOR_OUTOFSTOCK }}
PLAYWRIGHT_BRAND_NAME: ${{ vars.PLAYWRIGHT_BRAND_NAME }}
PLAYWRIGHT_USER_EMAIL: ${{ vars.PLAYWRIGHT_USER_EMAIL }}
PLAYWRIGHT_USER_PASSWORD: ${{ vars.PLAYWRIGHT_USER_PASSWORD }}
- name: Move Playwright report
if: ${{ success() || failure() }}
shell: bash
run: |
mkdir blob-reports
mv blob-report blob-reports/blob-report-$SHARD_INDEX
- name: Upload artifact
uses: actions/upload-artifact@v4
if: ${{ success() || failure() }}
with:
name: blob-report-${{ matrix.shardIndex }}
path: blob-reports
retention-days: 1
report:
name: Report
if: ${{ vars.PLAYWRIGHT_S3_URL != '' && (success() || failure()) }}
runs-on: ubuntu-latest
needs:
- Run
env:
HTML_REPORT_URL_PATH: reports/${{ github.sha }}/${{ github.run_attempt }}
steps:
- name: Download results
uses: actions/download-artifact@v4
with:
path: blob-reports
pattern: blob-report-*
merge-multiple: true
- name: Merge reports
shell: bash
run: |
mv ./blob-reports/**/*.zip ./blob-reports
npx playwright merge-reports --reporter html ./blob-reports
mkdir -p ./playwright-report-upload/$HTML_REPORT_URL_PATH
mv ./playwright-report/* ./playwright-report-upload/$HTML_REPORT_URL_PATH
- name: Upload to S3
run: |
aws s3 sync ./playwright-report-upload s3://$S3_BUCKET
env:
S3_BUCKET: ${{ vars.PLAYWRIGHT_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.PLAYWRIGHT_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.PLAYWRIGHT_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ vars.PLAYWRIGHT_S3_REGION }}
- name: Add link to summary
env:
REPORT_URL: ${{ vars.PLAYWRIGHT_S3_URL }}${{ env.HTML_REPORT_URL_PATH }}/index.html
shell: bash
run: |
echo "[Playwright Report]($REPORT_URL)" >> $GITHUB_STEP_SUMMARY
- name: Post status
if: ${{ success() || failure() }}
uses: guibranco/github-status-action-v2@v1.1.13
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
context: Playwright Report
state: ${{ needs.Run.result }}
sha: ${{ github.sha }}
target_url: ${{ vars.PLAYWRIGHT_S3_URL }}${{ env.HTML_REPORT_URL_PATH }}/index.html