Deps: Update tests & performance npm deps #1885
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: | |
| get-playwright-version: | |
| name: Get Playwright Version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.get-playwright-version.outputs.version }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 | |
| - name: Get version from package.json | |
| id: get-playwright-version | |
| run: | | |
| cd tests | |
| version=$(jq -r '.devDependencies["@playwright/test"] // .dependencies["@playwright/test"]' package.json) | |
| test -n "$version" || { echo "No @playwright/test version found in package.json"; exit 1; } | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| echo "Version: " $version | |
| run-playwright: | |
| name: Run Playwright | |
| needs: get-playwright-version | |
| runs-on: ubuntu-latest | |
| container: | |
| image: mcr.microsoft.com/playwright:v${{needs.get-playwright-version.outputs.version}}-jammy | |
| steps: | |
| # Checkout the repository so the workflow has access to the code | |
| - name: Checkout code | |
| uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 | |
| - name: Setup Hugo | |
| uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0 | |
| with: | |
| hugo-version: '0.147.8' | |
| extended: true | |
| - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 #v6.0.0 | |
| with: | |
| go-version: '1.25.4' | |
| - name: Install dependencies | |
| run: cd tests && npm ci | |
| - name: Run Playwright tests | |
| id: test-ui | |
| # Check done to set the home variable. Workaround as browser is unable to launch if the $HOME folder isn't owned by the current user. | |
| if: ${{ runner.os == 'Linux' }} | |
| env: | |
| HOME: /root | |
| run: | | |
| git config --global --add safe.directory /__w/nginx-hugo-theme/nginx-hugo-theme | |
| cd tests && npx playwright test | 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@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| 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@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0 | |
| 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, | |
| }); |