Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 11 additions & 196 deletions .github/workflows/tests_primary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,207 +26,22 @@ env:
DEBUG_GIT_COMMIT_INFO: 1

jobs:
test_linux:
name: ${{ matrix.os }} (${{ matrix.browser }} - Node.js ${{ matrix.node-version }})
environment: ${{ github.event_name == 'push' && 'allow-uploading-flakiness-results' || null }}
strategy:
fail-fast: false
matrix:
browser: [chromium, firefox, webkit]
os: [ubuntu-22.04]
node-version: [18]
include:
- os: ubuntu-22.04
node-version: 20
browser: chromium
- os: ubuntu-22.04
node-version: 22
browser: chromium
runs-on: ${{ matrix.os }}
permissions:
id-token: write # This is required for OIDC login (azure/login) to succeed
contents: read # This is required for actions/checkout to succeed
test_webkit_wsl:
name: Webkit WSL
runs-on: windows-2025
steps:
- uses: actions/checkout@v4
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
- uses: ./.github/actions/run-test
with:
node-version: ${{ matrix.node-version }}
browsers-to-install: ${{ matrix.browser }} chromium
command: npm run test -- --project=${{ matrix.browser }}-*
bot-name: "${{ matrix.browser }}-${{ matrix.os }}-node${{ matrix.node-version }}"
flakiness-client-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_CLIENT_ID }}
flakiness-tenant-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_TENANT_ID }}
flakiness-subscription-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_SUBSCRIPTION_ID }}

test_linux_chromium_tot:
name: ${{ matrix.os }} (chromium tip-of-tree)
environment: ${{ github.event_name == 'push' && 'allow-uploading-flakiness-results' || null }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
runs-on: ${{ matrix.os }}
permissions:
id-token: write # This is required for OIDC login (azure/login) to succeed
contents: read # This is required for actions/checkout to succeed
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/run-test
with:
browsers-to-install: chromium-tip-of-tree
command: npm run test -- --project=chromium-*
bot-name: "${{ matrix.os }}-chromium-tip-of-tree"
node-version: 22
browsers-to-install: webkit-wsl
command: npm run test -- --project=webkit-* --reporter=list
bot-name: "webkit-wsl-headed"
flakiness-client-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_CLIENT_ID }}
flakiness-tenant-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_TENANT_ID }}
flakiness-subscription-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_SUBSCRIPTION_ID }}
env:
PWTEST_CHANNEL: chromium-tip-of-tree

test_test_runner:
name: Test Runner
environment: ${{ github.event_name == 'push' && 'allow-uploading-flakiness-results' || null }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [18]
shardIndex: [1, 2]
shardTotal: [2]
include:
- os: ubuntu-latest
node-version: 20
shardIndex: 1
shardTotal: 2
- os: ubuntu-latest
node-version: 20
shardIndex: 2
shardTotal: 2
- os: ubuntu-latest
node-version: 22
shardIndex: 1
shardTotal: 2
- os: ubuntu-latest
node-version: 22
shardIndex: 2
shardTotal: 2
runs-on: ${{ matrix.os }}
permissions:
id-token: write # This is required for OIDC login (azure/login) to succeed
contents: read # This is required for actions/checkout to succeed
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/run-test
with:
node-version: ${{matrix.node-version}}
command: npm run ttest -- --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
bot-name: "${{ matrix.os }}-node${{ matrix.node-version }}-${{ matrix.shardIndex }}"
flakiness-client-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_CLIENT_ID }}
flakiness-tenant-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_TENANT_ID }}
flakiness-subscription-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_SUBSCRIPTION_ID }}
env:
PWTEST_CHANNEL: firefox-beta

test_web_components:
name: Web Components
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- run: npm ci
- run: npm run build

- run: npx playwright install --with-deps
- run: npm run test-html-reporter
env:
PWTEST_BOT_NAME: "web-components-html-reporter"
- name: Upload blob report
if: ${{ !cancelled() }}
uses: ./.github/actions/upload-blob-report
with:
report_dir: packages/html-reporter/blob-report
job_name: "web-components-html-reporter"

- run: npm run test-web
if: ${{ !cancelled() }}
env:
PWTEST_BOT_NAME: "web-components-web"
- name: Upload blob report
if: ${{ !cancelled() }}
uses: ./.github/actions/upload-blob-report
with:
report_dir: packages/web/blob-report
job_name: "web-components-web"

test_vscode_extension:
name: VSCode Extension
runs-on: ubuntu-latest
env:
PWTEST_BOT_NAME: "vscode-extension"
DEBUG_GIT_COMMIT_INFO: ""
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- run: npm ci
env:
DEBUG: pw:install
- run: npm run build
- run: npx playwright install chromium
- name: Checkout extension
run: git clone https://github.com/microsoft/playwright-vscode.git
- name: Print extension revision
run: git rev-parse HEAD
working-directory: ./playwright-vscode
- name: Remove @playwright/test from extension dependencies
run: node -e "const p = require('./package.json'); delete p.devDependencies['@playwright/test']; fs.writeFileSync('./package.json', JSON.stringify(p, null, 2));"
working-directory: ./playwright-vscode
- name: Build extension
run: npm ci && npm run build
working-directory: ./playwright-vscode
- name: Run extension tests
run: npm run test -- --workers=1
working-directory: ./playwright-vscode
- name: Upload blob report
if: ${{ !cancelled() }}
uses: ./.github/actions/upload-blob-report
with:
report_dir: playwright-vscode/blob-report
job_name: ${{ env.PWTEST_BOT_NAME }}

test_package_installations:
name: "Installation Test ${{ matrix.os }}"
environment: ${{ github.event_name == 'push' && 'allow-uploading-flakiness-results' || null }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
timeout-minutes: 30
permissions:
id-token: write # This is required for OIDC login (azure/login) to succeed
contents: read # This is required for actions/checkout to succeed
steps:
- uses: actions/checkout@v4
- run: npm install -g yarn@1
- run: npm install -g pnpm@8
- name: Setup Ubuntu Binary Installation # TODO: Remove when https://github.com/electron/electron/issues/42510 is fixed
if: ${{ runner.os == 'Linux' }}
run: |
if grep -q "Ubuntu 24" /etc/os-release; then
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
fi
shell: bash
- uses: ./.github/actions/run-test
with:
command: npm run itest
bot-name: "package-installations-${{ matrix.os }}"
shell: ${{ matrix.os == 'windows-latest' && 'pwsh' || 'bash' }}
flakiness-client-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_CLIENT_ID }}
flakiness-tenant-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_TENANT_ID }}
flakiness-subscription-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_SUBSCRIPTION_ID }}
PWTEST_CHANNEL: webkit-wsl
DEBUG: pw:api,pw:browser
29 changes: 15 additions & 14 deletions examples/todomvc/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default defineConfig({
/* Maximum time one test can run for. */
timeout: 15_000,

captureGitInfo: { commit: true, diff: true },
captureGitInfo: { commit: false, diff: false },

expect: {

Expand Down Expand Up @@ -50,26 +50,27 @@ export default defineConfig({

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
// {
// name: 'chromium',

/* Project-specific settings. */
use: {
...devices['Desktop Chrome'],
},
},
// /* Project-specific settings. */
// use: {
// ...devices['Desktop Chrome'],
// },
// },

{
name: 'firefox',
use: {
...devices['Desktop Firefox'],
},
},
// {
// name: 'firefox',
// use: {
// ...devices['Desktop Firefox'],
// },
// },

{
name: 'webkit',
use: {
...devices['Desktop Safari'],
channel: 'webkit-wsl',
},
},

Expand Down
28 changes: 28 additions & 0 deletions packages/playwright-core/bin/install_webkit_wsl.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
$ErrorActionPreference = 'Stop'

$Distribution = "playwright"
$Username = "pwuser"

$distributions = (wsl --list --quiet) -split "\r?\n"
if ($distributions -contains $Distribution) {
Write-Host "WSL distribution '$Distribution' already exists. Skipping installation."
} else {
Write-Host "Installing new WSL distribution '$Distribution'..."
wsl --install -d Ubuntu-24.04 --name $Distribution --no-launch
wsl -d $Distribution -u root adduser --gecos GECOS --disabled-password $Username
}

$pwshDirname = (Resolve-Path -Path $PSScriptRoot).Path;
$playwrightCoreRoot = Resolve-Path (Join-Path $pwshDirname "..")

$initScript = @"
if ! command -v node >/dev/null 2>&1; then
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
apt-get install -y nodejs
fi
node cli.js install-deps
cp bin/webkit-wsl-pipe-wrapper.mjs /home/$Username/
sudo -u $Username PLAYWRIGHT_SKIP_BROWSER_GC=1 node cli.js install webkit
"@ -replace "\r\n", "`n"

wsl -d $Distribution --cd $playwrightCoreRoot -u root -- bash -c "$initScript"
49 changes: 49 additions & 0 deletions packages/playwright-core/bin/webkit-wsl-pipe-wrapper.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// @ts-check
import net from 'net';
import { execSync, spawn } from 'child_process';
import { readFileSync } from 'fs';

const socketPort = process.env.SOCKET_ADDRESS;

if (!socketPort)
throw new Error('SOCKET_ADDRESS is not set');
const address = (() => {
if (execSync('wslinfo --networking-mode', { encoding: 'utf8' }).trim() === 'nat') {
const nameserverLine = readFileSync('/etc/resolv.conf', 'utf8').split('\n').find(line => line.startsWith('nameserver'));
return nameserverLine?.split(' ')[1] || '127.0.0.1';
}
return '127.0.0.1';
})();

const socket = net.createConnection(parseInt(socketPort), address);
socket.on('error', (error) => console.log('socket error from wrapper', error));

await new Promise((resolve, reject) => {
socket.on('connect', resolve);
socket.on('error', reject);
});

const [executable, ...args] = process.argv.slice(2);

// 3 is readFD and 4 is writeFD
const child = spawn(executable, args, {
stdio: ['inherit', 'inherit', 'inherit', 'pipe', 'pipe']
});

// Connect socket to child process pipes
socket.pipe(child.stdio[3]);
child.stdio[4].pipe(socket);

// Handle cleanup
socket.on('end', () => {
child.kill();
});

child.on('exit', () => {
socket.end();
});

await new Promise((resolve, reject) => {
child.on('exit', resolve);
child.on('error', reject);
});
1 change: 1 addition & 0 deletions packages/playwright-core/src/server/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export abstract class Browser extends SdkObject {
const download = this._downloads.get(uuid);
if (!download)
return;
console.log('downloadFilenameSuggested', uuid, suggestedFilename);
download._filenameSuggested(suggestedFilename);
}

Expand Down
Loading
Loading