Improve playwright workflow installing performance #1822
Workflow file for this run
This file contains hidden or 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: Running Playwright test on UI | |
| # Run the workflow when code is pushed or when a pull request is created | |
| on: | |
| push: | |
| branches: | |
| - 'main' | |
| pull_request: | |
| env: | |
| FRONT_DOOR_USERNAME: ${{ secrets.FRONT_DOOR_USERNAME }} | |
| FRONT_DOOR_PASSWORD: ${{ secrets.FRONT_DOOR_PASSWORD }} | |
| COVEO_CREDENTIALS_BASE_URL: ${{ secrets.COVEO_CREDENTIALS_BASE_URL }} | |
| jobs: | |
| playwright: | |
| name: Run Playwright | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout the repository so the workflow has access to the code | |
| - name: Checkout code | |
| uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
| - name: Setup Hugo | |
| uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0 | |
| with: | |
| hugo-version: '0.147.8' | |
| extended: true | |
| - name: Check playwright version | |
| id: check-playwright-version | |
| run: | | |
| version=$(npm list @playwright/test --json | jq -r '.dependencies["@playwright/test"].version') | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| echo "Version:" $version | |
| - name: Attempt to restore cache | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| id: restore-cache | |
| with: | |
| # By default this path is hardcoded by OS - https://playwright.dev/python/docs/browsers#managing-browser-binaries | |
| path: '~/.cache/ms-playwright' | |
| key: '${{ runner.os }}-playwright-${{ steps.check-playwright-version.outputs.version }}' | |
| # Fallback, if version changed, use the most recent cached version. | |
| restore-keys: | | |
| ${{ runner.os }}-playwright- | |
| - name: Install dependencies | |
| run: cd tests && npm ci | |
| - name: Install playwright dependecies | |
| if: steps.restore-cache.outputs.cache-hit != 'true' | |
| run: npx playwright install --with-deps | |
| - name: Run Playwright tests | |
| id: test-ui | |
| run: | | |
| make tests | tee output.log | |
| if grep -q "failed" output.log; then | |
| echo "Playwright tests failed. Please view the Playwright report to see full error." | |
| exit 1 | |
| fi | |
| - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 | |
| id: artifact-upload | |
| if: ${{ !cancelled() && failure() && steps.test-ui.conclusion == 'failure' }} | |
| with: | |
| name: playwright-report | |
| path: tests/playwright-report/ | |
| retention-days: 3 | |
| - name: Comment on PR with Playwright report | |
| uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
| if: ${{ failure() }} | |
| with: | |
| script: | | |
| const body = `### <span aria-hidden="true">❌</span> Playwright differences were detected. | |
| View the [Playwright report](${{ steps.artifact-upload.outputs.artifact-url }})`; | |
| await github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: body, | |
| }); |