Playwright Test #158
Workflow file for this run
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 Test | |
on: | |
deployment_status: | |
env: | |
HUSKY: 0 | |
jobs: | |
install: | |
timeout-minutes: 60 | |
name: Install | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.node-version' | |
cache: 'npm' | |
- name: Cache node_modules | |
uses: actions/cache@v4 | |
id: cache-node-modules | |
with: | |
path: | | |
node_modules | |
key: modules-${{ hashFiles('package-lock.json') }} | |
- name: Cache Playwright binaries | |
uses: actions/cache@v4 | |
id: cache-playwright | |
with: | |
path: | | |
~/.cache/ms-playwright | |
key: playwright-${{ hashFiles('package-lock.json') }} | |
- name: Install dependencies | |
if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: Install Playwright Browsers | |
if: steps.cache-playwright.outputs.cache-hit != 'true' | |
run: npx playwright install --with-deps | |
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 | |
needs: | |
- install | |
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' | |
cache: 'npm' | |
- 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 | |
uses: actions/cache@v4 | |
id: cache-playwright | |
with: | |
path: | | |
~/.cache/ms-playwright | |
key: playwright-${{ hashFiles('package-lock.json') }} | |
- name: Install dependencies | |
if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
run: npm ci | |
- 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 playwright-reports | |
mv blob-report playwright-reports/playwright-report-$SHARD_INDEX | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
if: ${{ success() || failure() }} | |
with: | |
name: playwright-report-${{ matrix.shardIndex }} | |
path: playwright-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: Checkout | |
uses: actions/checkout@v4 | |
- name: Download results | |
uses: actions/download-artifact@v4 | |
with: | |
path: playwright-reports | |
pattern: playwright-report-* | |
merge-multiple: true | |
- name: Merge reports | |
shell: bash | |
run: | | |
npx playwright merge-reports --reporter html ./playwright-reports | |
- name: Upload to S3 | |
run: | | |
aws s3 sync playwright 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/[email protected] | |
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 |