From 17d21dae1b5e873dfc320905260f1b1b98bac3ba Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Fri, 7 Nov 2025 12:48:31 -0800 Subject: [PATCH 1/7] Workflow: Add cache to playwright --- .github/workflows/playwright.yml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 2b520c06..214a5c43 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -24,8 +24,28 @@ jobs: with: hugo-version: '0.147.8' extended: true - - name: Install dependencies and playwright browsers - run: cd tests && npm ci && npx playwright install --with-deps + - name: Install dependencies + run: cd tests && npm ci + - name: Check playwright version + id: check-playwright-version + run: | + cd tests + 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 playwright dependencies + if: steps.restore-cache.outputs.cache-hit != 'true' + run: cd tests && npx playwright install --with-deps - name: Run Playwright tests id: test-ui run: | From 823c895529dbf9ca41a27fa786322c1c24a2ba3a Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Fri, 7 Nov 2025 13:26:18 -0800 Subject: [PATCH 2/7] Workflow: Fixed running issues --- .github/workflows/playwright.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 214a5c43..33f12ae4 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -11,6 +11,7 @@ env: FRONT_DOOR_USERNAME: ${{ secrets.FRONT_DOOR_USERNAME }} FRONT_DOOR_PASSWORD: ${{ secrets.FRONT_DOOR_PASSWORD }} COVEO_CREDENTIALS_BASE_URL: ${{ secrets.COVEO_CREDENTIALS_BASE_URL }} + BROWSERS: "webkit firefox" jobs: playwright: name: Run Playwright @@ -32,7 +33,6 @@ jobs: cd tests 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 @@ -43,9 +43,12 @@ jobs: # Fallback, if version changed, use the most recent cached version. restore-keys: | ${{ runner.os }}-playwright- - - name: Install playwright dependencies + - name: Install playwright with dependencies if: steps.restore-cache.outputs.cache-hit != 'true' - run: cd tests && npx playwright install --with-deps + run: cd tests && npx playwright install --with-deps ${{ env.BROWSERS }} + - name: Install playwright dependencies + if: steps.restore-cache.outputs.cache-hit == 'true' + run: cd tests && npx playwright install-deps ${{ env.BROWSERS }} - name: Run Playwright tests id: test-ui run: | From 58679cb740d9729f939775bc281ede4c792b7b7b Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Fri, 7 Nov 2025 14:51:08 -0800 Subject: [PATCH 3/7] Workflow: Add only-shell flag for CI --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 33f12ae4..2a4a472f 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -45,7 +45,7 @@ jobs: ${{ runner.os }}-playwright- - name: Install playwright with dependencies if: steps.restore-cache.outputs.cache-hit != 'true' - run: cd tests && npx playwright install --with-deps ${{ env.BROWSERS }} + run: cd tests && npx playwright install --with-deps ${{ env.BROWSERS }} --only-shell - name: Install playwright dependencies if: steps.restore-cache.outputs.cache-hit == 'true' run: cd tests && npx playwright install-deps ${{ env.BROWSERS }} From a121085cfe66aff8dfbb1dafbe2e544fe2fa2948 Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Fri, 7 Nov 2025 15:59:51 -0800 Subject: [PATCH 4/7] Workflow: Switched to container --- .github/workflows/playwright.yml | 33 ++++++++++---------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 2a4a472f..95451352 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -16,6 +16,8 @@ jobs: playwright: name: Run Playwright runs-on: ubuntu-latest + container: + image: mcr.microsoft.com/playwright:v1.55.1-jammy steps: # Checkout the repository so the workflow has access to the code - name: Checkout code @@ -25,34 +27,19 @@ jobs: with: hugo-version: '0.147.8' extended: true + - uses: actions/setup-go@v6 + with: + go-version: '1.24.6' - name: Install dependencies run: cd tests && npm ci - - name: Check playwright version - id: check-playwright-version - run: | - cd tests - version=$(npm list @playwright/test --json | jq -r '.dependencies["@playwright/test"].version') - echo "version=$version" >> $GITHUB_OUTPUT - - 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 playwright with dependencies - if: steps.restore-cache.outputs.cache-hit != 'true' - run: cd tests && npx playwright install --with-deps ${{ env.BROWSERS }} --only-shell - - name: Install playwright dependencies - if: steps.restore-cache.outputs.cache-hit == 'true' - run: cd tests && npx playwright install-deps ${{ env.BROWSERS }} - name: Run Playwright tests id: test-ui + if: ${{ runner.os == 'Linux' }} + env: + HOME: /root run: | - make tests | tee output.log + 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 From 3b9014f6a18fb871e8e1aeb39df9175848bff23a Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Fri, 7 Nov 2025 16:47:21 -0800 Subject: [PATCH 5/7] Workflow: Get playwright version from package.json --- .github/workflows/playwright.yml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 95451352..3d0c5660 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -9,15 +9,31 @@ on: env: FRONT_DOOR_USERNAME: ${{ secrets.FRONT_DOOR_USERNAME }} - FRONT_DOOR_PASSWORD: ${{ secrets.FRONT_DOOR_PASSWORD }} + FRONT_DOOR_PASSWORD: ${{ secrets.FRONT_DOOR_PASSWORD }} COVEO_CREDENTIALS_BASE_URL: ${{ secrets.COVEO_CREDENTIALS_BASE_URL }} - BROWSERS: "webkit firefox" jobs: - playwright: + 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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - 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:v1.55.1-jammy + 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 From a3adbe4dee66fba6603cfe006d4c15d5e2d7f600 Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Mon, 10 Nov 2025 12:18:04 -0800 Subject: [PATCH 6/7] Workflow: Pin setupgo version --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 3d0c5660..99ce3f54 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -43,7 +43,7 @@ jobs: with: hugo-version: '0.147.8' extended: true - - uses: actions/setup-go@v6 + - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 #v6.0.0 with: go-version: '1.24.6' - name: Install dependencies From c99099a7c03ba0fb6b794dc52a4bb05f35a03380 Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Mon, 10 Nov 2025 15:09:34 -0800 Subject: [PATCH 7/7] Workflow: Add comment to runner os check --- .github/workflows/playwright.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 99ce3f54..7364ec77 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -50,6 +50,7 @@ jobs: 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