Skip to content

Deps: Update GH Action Deps (major) #1886

Deps: Update GH Action Deps (major)

Deps: Update GH Action Deps (major) #1886

Workflow file for this run

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@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.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@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.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@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.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@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.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,
});