Skip to content

Commit 703c929

Browse files
authored
Workflow: Switch to official image in playwright workflow (#444)
* Workflow: Add cache to playwright * Workflow: Fixed running issues * Workflow: Add only-shell flag for CI * Workflow: Switched to container * Workflow: Get playwright version from package.json * Workflow: Pin setupgo version * Workflow: Add comment to runner os check
1 parent 4c57ed5 commit 703c929

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

.github/workflows/playwright.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,31 @@ on:
99

1010
env:
1111
FRONT_DOOR_USERNAME: ${{ secrets.FRONT_DOOR_USERNAME }}
12-
FRONT_DOOR_PASSWORD: ${{ secrets.FRONT_DOOR_PASSWORD }}
12+
FRONT_DOOR_PASSWORD: ${{ secrets.FRONT_DOOR_PASSWORD }}
1313
COVEO_CREDENTIALS_BASE_URL: ${{ secrets.COVEO_CREDENTIALS_BASE_URL }}
1414
jobs:
15-
playwright:
15+
get-playwright-version:
16+
name: Get Playwright Version
17+
runs-on: ubuntu-latest
18+
outputs:
19+
version: ${{ steps.get-playwright-version.outputs.version }}
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
23+
- name: Get version from package.json
24+
id: get-playwright-version
25+
run: |
26+
cd tests
27+
version=$(jq -r '.devDependencies["@playwright/test"] // .dependencies["@playwright/test"]' package.json)
28+
test -n "$version" || { echo "No @playwright/test version found in package.json"; exit 1; }
29+
echo "version=$version" >> $GITHUB_OUTPUT
30+
echo "Version: " $version
31+
run-playwright:
1632
name: Run Playwright
33+
needs: get-playwright-version
1734
runs-on: ubuntu-latest
35+
container:
36+
image: mcr.microsoft.com/playwright:v${{needs.get-playwright-version.outputs.version}}-jammy
1837
steps:
1938
# Checkout the repository so the workflow has access to the code
2039
- name: Checkout code
@@ -24,12 +43,20 @@ jobs:
2443
with:
2544
hugo-version: '0.147.8'
2645
extended: true
27-
- name: Install dependencies and playwright browsers
28-
run: cd tests && npm ci && npx playwright install --with-deps
46+
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 #v6.0.0
47+
with:
48+
go-version: '1.24.6'
49+
- name: Install dependencies
50+
run: cd tests && npm ci
2951
- name: Run Playwright tests
3052
id: test-ui
53+
# 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.
54+
if: ${{ runner.os == 'Linux' }}
55+
env:
56+
HOME: /root
3157
run: |
32-
make tests | tee output.log
58+
git config --global --add safe.directory /__w/nginx-hugo-theme/nginx-hugo-theme
59+
cd tests && npx playwright test | tee output.log
3360
if grep -q "failed" output.log; then
3461
echo "Playwright tests failed. Please view the Playwright report to see full error."
3562
exit 1

0 commit comments

Comments
 (0)