From a1fe251c5bbe3f56a9f841018057a5c0358e2540 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 19 Aug 2026 22:37:35 +0200 Subject: [PATCH] ci(playwright): skip browser installation on CI an reuse action provided chrome Signed-off-by: Ferdinand Thiessen --- .github/workflows/playwright.yml | 4 ++-- package.json | 2 +- playwright.config.ts | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 601fce8d0a183..1286331faec40 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -121,7 +121,7 @@ jobs: npm run build --if-present - name: Install Playwright browsers - run: npx playwright install --with-deps + run: npm run playwright:install-ci --if-present - name: Run Playwright tests run: npm run playwright -- --shard='${{ matrix.shardIndex }}/${{ matrix.shardTotal }}' @@ -228,7 +228,7 @@ jobs: npm run build --if-present - name: Install Playwright browsers - run: npx playwright install --with-deps + run: npm run playwright:install-ci --if-present - name: Run Playwright setup tests run: npm run playwright:setup diff --git a/package.json b/package.json index 65ad42ace059b..c9a4b84d3b23a 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "postlint": "build/demi.sh lint", "lint:fix": "concurrently 'npm run lint -- --fix' 'build/demi.sh lint:fix'", "playwright": "playwright test --project=default --project=admin-settings", - "playwright:install": "playwright install chromium-headless-shell", + "playwright:install": "playwright install chromium", "playwright:setup": "playwright test --project=setup", "sass": "sass --style compressed --load-path core/css core/css/ $(for cssdir in $(find apps -mindepth 2 -maxdepth 2 -name \"css\"); do if ! $(git check-ignore -q $cssdir); then printf \"$cssdir \"; fi; done)", "sass:icons": "node build/icons.mjs", diff --git a/playwright.config.ts b/playwright.config.ts index 079c33ef445b3..3e34aa3eb0a34 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -2,9 +2,18 @@ * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ +/// import { defineConfig, devices } from '@playwright/test' +type DeviceDescriptor = typeof devices[string] +const BROWSWER_CONFIG_CHROME: DeviceDescriptor & { channel: string } = { + ...devices['Desktop Chrome'], + channel: process.env.CI + ? 'chrome' // on CI use the chrome browser provided by the GitHub Actions runner + : 'chromium', // locally use the default playwright chromium browser +} + export default defineConfig({ testDir: './tests/playwright/e2e', fullyParallel: true, @@ -26,7 +35,7 @@ export default defineConfig({ workers: 1, grep: /@setup/, use: { - ...devices['Desktop Chrome'], + ...BROWSWER_CONFIG_CHROME, }, }, @@ -36,7 +45,7 @@ export default defineConfig({ workers: 1, // only one admin setting test can run at a time due to shared state testMatch: '**/admin-settings*.spec.ts', use: { - ...devices['Desktop Chrome'], + ...BROWSWER_CONFIG_CHROME, }, }, @@ -45,10 +54,11 @@ export default defineConfig({ testMatch: /\/(?!admin-settings)[^/]*\.spec\.ts$/, grepInvert: /@setup/, use: { - ...devices['Desktop Chrome'], + ...BROWSWER_CONFIG_CHROME, }, }, ], + webServer: { command: 'node tests/playwright/start-nextcloud-server.js', env: {